|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.cocoon.util.location.LocationUtils
public class LocationUtils
Location-related utility methods.
Nested Class Summary | |
---|---|
static interface |
LocationUtils.LocationFinder
An finder or object locations |
Field Summary | |
---|---|
static String |
UNKNOWN_STRING
The string representation of an unknown location: " [unknown location] ". |
Method Summary | |
---|---|
static void |
addFinder(LocationUtils.LocationFinder finder)
Add a LocationUtils.LocationFinder to the list of finders that will be queried for an object's
location by getLocation(Object, String) . |
static Location |
getLocation(Object obj)
Get the location of an object. |
static Location |
getLocation(Object obj,
String description)
Get the location of an object. |
static boolean |
isKnown(Location location)
Checks if a location is known, i.e. it is not null nor equal to Location.UNKNOWN . |
static boolean |
isUnknown(Location location)
Checks if a location is unknown, i.e. it is either null or equal to Location.UNKNOWN . |
static LocationImpl |
parse(String text)
Parse a location string of the form " uri:line:column " (e.g. |
static String |
toString(Location location)
Builds a string representation of a location, in the " descripton - uri:line:column "
format (e.g. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String UNKNOWN_STRING
[unknown location]
".
Method Detail |
---|
public static String toString(Location location)
descripton - uri:line:column
"
format (e.g. "foo - file://path/to/file.xml:3:40
"). For an unknown location
, returns
UNKNOWN_STRING
.
public static LocationImpl parse(String text) throws IllegalArgumentException
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
").
text
- the text to parse
null
if text was null or in an incorrect format)
IllegalArgumentException
public static boolean isKnown(Location location)
Location.UNKNOWN
.
location
- the location to check
true
if the location is knownpublic static boolean isUnknown(Location location)
Location.UNKNOWN
.
location
- the location to check
true
if the location is unknownpublic static void addFinder(LocationUtils.LocationFinder finder)
LocationUtils.LocationFinder
to the list of finders that will be queried for an object's
location by 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); }
finder
- the location finder to addpublic static Location getLocation(Object obj)
obj
- the object of which to get the location
Location.UNKNOWN
if no location could be foundpublic static Location getLocation(Object obj, String description)
obj
- the object of which to get the locationdescription
- an optional description of the object's location, used if a Location object
has to be created.
Location.UNKNOWN
if no location could be found
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |