public final class HashStructureElementVisitor extends ElementVisitor
ElementVisitor
for unmarshalling extension manifest
(extension.xml) elements into a HashStructure
. In order for
the automatic unmarshalling to occur without errors, the XML must follow
a particular format. Consider the following example, where the
<my-hook> element is unmarshalled by HashStructureElementVisitor:
<my-hook version="2.0"> <feature name="${KILLER_APP}" id="killer.app.id"> <display description="${KILLER_APP_DESCRIPTION}" icon="res:${KILLER_APP_ICON}" welcome-page="uri:oracle.killerapp/welcome.html"> Text within the display element. </display> </feature> <thing name="one">1</thing> <thing name="two">2</thing> </my-hook>If the unmarshalled HashStructure for
<my-hook>
were
assigned to a variable named myhook
, the properties
within my-hook
could be obtained using the following code:
String version = myhook.getString( "version" ); // "2.0" String name = myhook.getString( "feature/name" ); // dereferenced value of ${KILLER_APP} String id = myhook.getString( "feature/id" ); // "killer.app.id" String description = myhook.getString( "feature/display/description" ); URL icon = myhook.getURL( "feature/display/icon" ); URL welcomePage = myhook.getURL( "feature/display/welcome-page" ); String text = myhook.getString( "feature/display/#text" ); // Whitespace is trimmed List things = myhook.getAsList( "thing" ); // Each item will be a HashStructureIn greater detail, the unmarshalling occurs according to the following rules:
HashStructure.getAsList(java.lang.String)
method to
get a List
every time.
${KILLER_APP}
are
resolved and expanded according to the following rules:
getResource()
on it to resolve the path to a URL.
This form is most often used when referencing icons, images,
or configuration files that can be found on the classpath.
ElementVisitor.ResourceBundleProvider
KEY_LOCATOR
Constructor and Description |
---|
HashStructureElementVisitor()
Creates a new HashStructureElementVisitor which will store
unmarshalled properties into a new HashStructure instance.
|
HashStructureElementVisitor(HashStructure root)
Creates a new HashStructureElementVisitor which will store
unmarshalled properties into the specified HashStructure instance.
|
Modifier and Type | Method and Description |
---|---|
void |
end(ElementEndContext context)
Visit the end tag of an xml element.
|
HashStructure |
getHashStructure()
Returns the HashStructure where this HashStructureElementVisitor
unmarshalled its properties.
|
void |
merge(HashStructureElementVisitor separateElementVisitor)
Copies the data from the given HashStructureElementVisitor instance
into this HashStructureElementVisitor's HashStructure.
|
void |
start(ElementStartContext context)
Visit the start tag of an xml element.
|
void |
turnElementCounterOn()
Turns element counting so that their order can be reconstructed later
from the hash structure content.
|
getAttributeHelper, getClassLoader, getMetaClassLoader, getResourceBundle, getResourceBundleProvider, getTextHelper, log, log, setResourceBundleProvider
public HashStructureElementVisitor()
public HashStructureElementVisitor(HashStructure root)
root
- The HashStructure where properties unmarshalled from
the extension manifest will be stored.public final HashStructure getHashStructure()
public final void start(ElementStartContext context)
ElementVisitor
This implementation does nothing.
start
in class ElementVisitor
context
- information about the xml start tag.public final void end(ElementEndContext context)
ElementVisitor
This implementation does nothing.
end
in class ElementVisitor
context
- information about the xml end tag.public void merge(HashStructureElementVisitor separateElementVisitor)
separateElementVisitor
- public void turnElementCounterOn()