|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.cocoon.util.location.LocationAttributes
public class LocationAttributes
A class to handle location information stored in attributes.
These attributes are typically setup using LocationAttributes.Pipe
which augments the SAX stream with additional attributes, e.g.:
<root xmlns:loc="http://apache.org/cocoon/location" loc:src="file://path/to/file.xml" loc:line="1" loc:column="1"> <foo loc:src="file://path/to/file.xml" loc:line="2" loc:column="3"/> </root>
LocationAttributes.Pipe
Nested Class Summary | |
---|---|
static class |
LocationAttributes.Pipe
A SAX filter that adds the information available from the Locator as attributes. |
Field Summary | |
---|---|
static String |
COL_ATTR
Attribute name for the column number |
static String |
LINE_ATTR
Attribute name for the line number |
static String |
PREFIX
Prefix for the location namespace |
static String |
Q_COL_ATTR
Attribute qualified name for the column number |
static String |
Q_LINE_ATTR
Attribute qualified name for the line number |
static String |
Q_SRC_ATTR
Attribute qualified name for the location URI |
static String |
SRC_ATTR
Attribute name for the location URI |
static String |
URI
Namespace URI for location attributes |
Method Summary | |
---|---|
static Attributes |
addLocationAttributes(Locator locator,
Attributes attrs)
Add location attributes to a set of SAX attributes. |
static int |
getColumn(Attributes attrs)
Returns the column number of an element (SAX flavor) |
static int |
getColumn(Element elem)
Returns the column number of an element (DOM flavor) |
static int |
getLine(Attributes attrs)
Returns the line number of an element (SAX flavor) |
static int |
getLine(Element elem)
Returns the line number of an element (DOM flavor) |
static Location |
getLocation(Attributes attrs,
String description)
Returns the Location of an element (SAX flavor). |
static Location |
getLocation(Element elem)
Same as getLocation(elem, null) . |
static Location |
getLocation(Element elem,
String description)
Returns the Location of an element (DOM flavor). |
static String |
getLocationString(Attributes attrs)
Returns the location of an element (SAX flavor). |
static String |
getLocationString(Element elem)
Returns the location of an element that has been processed by this pipe (DOM flavor). |
static String |
getURI(Attributes attrs)
Returns the URI of an element (SAX flavor) |
static String |
getURI(Element elem)
Returns the URI of an element (DOM flavor) |
static void |
remove(Element elem,
boolean recurse)
Remove the location attributes from a DOM element. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String PREFIX
public static final String URI
public static final String SRC_ATTR
public static final String LINE_ATTR
public static final String COL_ATTR
public static final String Q_SRC_ATTR
public static final String Q_LINE_ATTR
public static final String Q_COL_ATTR
Method Detail |
---|
public static Attributes addLocationAttributes(Locator locator, Attributes attrs)
locator
- the Locator
(can be null)attrs
- the Attributes
where locator information should be addedpublic static Location getLocation(Attributes attrs, String description)
Location
of an element (SAX flavor).
attrs
- the element's attributes that hold the location informationdescription
- a description for the location (can be null)
Location
objectpublic static String getLocationString(Attributes attrs)
getLocation(Attributes, String)
and the Locatable
interface.
attrs
- the element's attributes that hold the location information
Location#toString()
.public static String getURI(Attributes attrs)
attrs
- the element's attributes that hold the location information
[unknown location]
" if attrs
has no location information.public static int getLine(Attributes attrs)
attrs
- the element's attributes that hold the location information
-1
if attrs
has no location information.public static int getColumn(Attributes attrs)
attrs
- the element's attributes that hold the location information
-1
if attrs
has no location information.public static Location getLocation(Element elem, String description)
Location
of an element (DOM flavor).
elem
- the element that holds the location informationdescription
- a description for the location (if null
, the element's name is used)
Location
objectpublic static Location getLocation(Element elem)
getLocation(elem, null)
.
public static String getLocationString(Element elem)
getLocation(Element)
and the Locatable
interface.
elem
- the element that holds the location information
Location#toString()
.public static String getURI(Element elem)
elem
- the element that holds the location information
[unknown location]
" if elem
has no location information.public static int getLine(Element elem)
elem
- the element that holds the location information
-1
if elem
has no location information.public static int getColumn(Element elem)
elem
- the element that holds the location information
-1
if elem
has no location information.public static void remove(Element elem, boolean recurse)
elem
- the element to remove the location attributes from.recurse
- if true
, also remove location attributes on descendant elements.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |