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="O__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 HashStructure
In 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.ResourceBundleProviderKEY_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, setResourceBundleProviderpublic 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)
ElementVisitorThis implementation does nothing.
start in class ElementVisitorcontext - information about the xml start tag.public final void end(ElementEndContext context)
ElementVisitorThis implementation does nothing.
end in class ElementVisitorcontext - information about the xml end tag.public void merge(HashStructureElementVisitor separateElementVisitor)
separateElementVisitor -public void turnElementCounterOn()