Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.1.0)

E17493-02

oracle.ide.extension
Class HashStructureElementVisitor

java.lang.Object
  extended by javax.ide.extension.ElementVisitor
      extended by oracle.ide.extension.HashStructureElementVisitor

public final class HashStructureElementVisitor
extends ElementVisitor

A generic 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 HashStructure
In greater detail, the unmarshalling occurs according to the following rules: The macro-like expressions such as ${KILLER_APP} are resolved and expanded according to the following rules:
  1. If the macro name matches a pre-defined JSR 198 macro, it is expanded to that value.
  2. Otherwise, if the macro name matches a resource key in the extension's resource bundle, it is expanded to that resource value.
  3. Otherwise, the text is taken literally.
After macros have been expanded, there are two special syntaxes recognized: This class is currently final because it has no behavior that can be overridden in a subclass. To provide customized behavior based on this class, use the decorator design pattern instead.

Since:
11.0

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.ide.extension.ElementVisitor
ElementVisitor.ResourceBundleProvider
 
Field Summary
 
Fields inherited from class javax.ide.extension.ElementVisitor
KEY_LOCATOR
 
Constructor Summary
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.
 
Method Summary
 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.
 
Methods inherited from class javax.ide.extension.ElementVisitor
getAttributeHelper, getClassLoader, getMetaClassLoader, getResourceBundle, getResourceBundleProvider, getTextHelper, log, log, setResourceBundleProvider
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashStructureElementVisitor

public HashStructureElementVisitor()
Creates a new HashStructureElementVisitor which will store unmarshalled properties into a new HashStructure instance.


HashStructureElementVisitor

public HashStructureElementVisitor(HashStructure root)
Creates a new HashStructureElementVisitor which will store unmarshalled properties into the specified HashStructure instance.

Parameters:
root - The HashStructure where properties unmarshalled from the extension manifest will be stored.
Method Detail

getHashStructure

public final HashStructure getHashStructure()
Returns the HashStructure where this HashStructureElementVisitor unmarshalled its properties.

Returns:
the HashStructure containing unmarshalled extension.xml properties

start

public final void start(ElementStartContext context)
Description copied from class: ElementVisitor
Visit the start tag of an xml element.

This implementation does nothing.

Overrides:
start in class ElementVisitor
Parameters:
context - information about the xml start tag.

end

public final void end(ElementEndContext context)
Description copied from class: ElementVisitor
Visit the end tag of an xml element.

This implementation does nothing.

Overrides:
end in class ElementVisitor
Parameters:
context - information about the xml end tag.

merge

public void merge(HashStructureElementVisitor separateElementVisitor)
Copies the data from the given HashStructureElementVisitor instance into this HashStructureElementVisitor's HashStructure. The data is merged together in the same way as if this visitor had been used to parse the data originally.

Parameters:
separateElementVisitor -

turnElementCounterOn

public void turnElementCounterOn()
Turns element counting so that their order can be reconstructed later from the hash structure content.


Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.1.0)

E17493-02

Copyright © 1997, 2011, Oracle. All rights reserved.