| java.lang.Object org.apache.cocoon.util.location.LocationUtils
LocationUtils | public class LocationUtils (Code) | | Location-related utility methods.
version: $Id: LocationUtils.java 446956 2006-09-16 21:32:15Z vgritsenko $ since: 2.1.8 |
Inner Class :public interface LocationFinder | |
Field Summary | |
final public static String | UNKNOWN_STRING The string representation of an unknown location: "[unknown location] ". |
Method Summary | |
public static void | addFinder(LocationFinder finder) Add a
LocationFinder to the list of finders that will be queried for an object's
location by
LocationUtils.getLocation(Object,String) .
Important: LocationUtils internally stores a weak reference to the finder. | public static Location | getLocation(Object obj) Get the location of an object. | public static Location | getLocation(Object obj, String description) Get the location of an object. | public static boolean | isKnown(Location location) Checks if a location is known, i.e. | public static boolean | isUnknown(Location location) Checks if a location is unknown, i.e. | public static LocationImpl | parse(String text) Parse a location string of the form "uri:line:column " (e.g.
"path/to/file.xml:3:40 ") to a Location object. | public static String | toString(Location location) Builds a string representation of a location, in the
"descripton - uri:line:column "
format (e.g. |
UNKNOWN_STRING | final public static String UNKNOWN_STRING(Code) | | The string representation of an unknown location: "[unknown location] ".
|
addFinder | public static void addFinder(LocationFinder finder)(Code) | | Add a
LocationFinder to the list of finders that will be queried for an object's
location by
LocationUtils.getLocation(Object,String) .
Important: LocationUtils internally stores a weak reference to the finder. This
avoids creating strong links between the classloader holding this class and the finder's
classloader, which can cause some weird memory leaks if the finder's classloader is to
be reloaded. Therefore, you have to keep a strong reference to the finder in the
calling code, e.g.:
private static LocationUtils.LocationFinder myFinder =
new LocationUtils.LocationFinder() {
public Location getLocation(Object obj, String desc) {
...
}
};
static {
LocationUtils.addFinder(myFinder);
}
Parameters: finder - the location finder to add |
getLocation | public static Location getLocation(Object obj)(Code) | | Get the location of an object. Some well-known located classes built in the JDK are handled
by this method. Handling of other located classes can be handled by adding new location finders.
Parameters: obj - the object of which to get the location the object's location, or Location.UNKNOWN if no location could be found |
getLocation | public static Location getLocation(Object obj, String description)(Code) | | Get the location of an object. Some well-known located classes built in the JDK are handled
by this method. Handling of other located classes can be handled by adding new location finders.
Parameters: obj - the object of which to get the location Parameters: description - an optional description of the object's location, used if a Location objecthas to be created. the object's location, or Location.UNKNOWN if no location could be found |
isKnown | public static boolean isKnown(Location location)(Code) | | Checks if a location is known, i.e. it is not null nor equal to
Location.UNKNOWN .
Parameters: location - the location to check true if the location is known |
isUnknown | public static boolean isUnknown(Location location)(Code) | | Checks if a location is unknown, i.e. it is either null or equal to
Location.UNKNOWN .
Parameters: location - the location to check true if the location is unknown |
parse | public static LocationImpl parse(String text) throws IllegalArgumentException(Code) | | Parse a location string of the form "uri:line:column " (e.g.
"path/to/file.xml:3:40 ") to a Location object. Additionally, a description may
also optionally be present, separated with an hyphen (e.g. "foo - path/to/file.xml:3.40 ").
Parameters: text - the text to parse the location (possibly null if text was null or in an incorrect format) |
|
|