org.jbehave.core.io
Class CodeLocations

java.lang.Object
  extended by org.jbehave.core.io.CodeLocations

public class CodeLocations
extends Object

Collection of utility methods to create code location URLs


Nested Class Summary
static class CodeLocations.InvalidCodeLocation
           
 
Constructor Summary
CodeLocations()
           
 
Method Summary
static URL codeLocationFromClass(Class<?> codeLocationClass)
          Creates a code location URL from a class
static URL codeLocationFromPath(String filePath)
          Creates a code location URL from a file path
static URL codeLocationFromURL(String url)
          Creates a code location URL from a URL
static String getPathFromURL(URL url)
          Get absolute path from URL objects starting with file: This method takes care of decoding %-encoded chars, e.g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CodeLocations

public CodeLocations()
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


Copyright © 2003-2012. All Rights Reserved.