Package org.jbehave.core.io
Class CodeLocations
- java.lang.Object
-
- org.jbehave.core.io.CodeLocations
-
public class CodeLocations extends Object
Collection of utility methods to create code location URLs
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCodeLocations.InvalidCodeLocation
-
Constructor Summary
Constructors Constructor Description CodeLocations()
-
Method Summary
Modifier and Type Method Description static URLcodeLocationFromClass(Class<?> codeLocationClass)Creates a code location URL from a classstatic URLcodeLocationFromPath(String filePath)Creates a code location URL from a file pathstatic URLcodeLocationFromURL(String url)Creates a code location URL from a URLstatic StringgetPathFromURL(URL url)Get absolute path from URL objects starting with file: This method takes care of decoding %-encoded chars, e.g.
-
-
-
Method Detail
-
codeLocationFromClass
public static URL codeLocationFromClass(Class<?> codeLocationClass)
Creates a code location URL from a class- Parameters:
codeLocationClass- the class- Returns:
- A URL created from Class
- Throws:
CodeLocations.InvalidCodeLocation- if URL creation fails
-
codeLocationFromPath
public static URL codeLocationFromPath(String filePath)
Creates a code location URL from a file path- Parameters:
filePath- the file path- Returns:
- A URL created from File
- Throws:
CodeLocations.InvalidCodeLocation- if URL creation fails
-
codeLocationFromURL
public static URL codeLocationFromURL(String url)
Creates a code location URL from a URL- Parameters:
url- the URL external form- Returns:
- A URL created from URL
- Throws:
CodeLocations.InvalidCodeLocation- if URL creation fails
-
getPathFromURL
public static String getPathFromURL(URL url)
Get absolute path from URL objects starting with file: This method takes care of decoding %-encoded chars, e.g. %20 -> space etc Since we do not use a File object, the system specific path encoding is not used (e.g. C:\ on Windows). This is necessary to facilitate the removal of a class file with path in codeLocationFromClass- Parameters:
url- the file-URL- Returns:
- String absolute decoded path
- Throws:
CodeLocations.InvalidCodeLocation- if URL contains format errors
-
-