jgb.builder
Interface TagHandler

All Known Implementing Classes:
AbstractTagHandler

public interface TagHandler

The base interface that all TagHandlers must implement.

All Builder instances use TagHandler instances to parse the document's content.

All methods of TagHandler are based on the equivalent ContentHandler interface. The difference is that the TagHandler interface prepends a tagContext parameter to all methods. This parameter is guaranteed to be the same accross all calls to all TagHandler methods. TagHandlers are encouraged to keep context information in this Map to refer to it later as other elements are encountered.

For example usage of the tagContext parameter, look at the current implementation.

Since:
0.1a
Author:
Francois Beausoleil, fbos@users.sourceforge.net
See Also:
ContentHandler

Field Summary
static String CALL_RETURN_CLASS_KEY
          Key to access the last <methodCall>'s return value's class.
static String CALL_RETURN_VALUE_KEY
          Key to access the last <methodCall>'s return value.
static String CONSTANTS_MAP_KEY
          Key to access the context's Map of constants.
static String CONTROLS_STACK_KEY
          Deprecated. Replaced by CURRENT_OBJECTS_STACK_KEY.
static String CURRENT_CONSTRAINTS_KEY
          Key to access the next control's constraints.
static String CURRENT_MODEL_ADAPTER
          Model keys
static String CURRENT_MODEL_ATTRIBUTE
          Model keys
static String CURRENT_OBJECT_ID_KEY
          Key to access the current construction's ID.
static String CURRENT_OBJECT_KEY
          Deprecated. Replaced by AbstractTagHandler.getCurrentObject(). The default implementation should not use this key anymore.
static String CURRENT_OBJECTS_STACK_KEY
          Key to access the context's current objects stack.
static String CURRENT_PARM_ACC_KEY
          Key to access the context's current ConstructorCall object.
static String CURRENT_WINDOW_ID_KEY
          Key to access the context's current window's ID.
static String CURRENT_WINDOW_KEY
          Key to access the context's current window reference.
static String DOCUMENT_LOCATOR_KEY
          Key to access the current document's locator.
static String MODEL_ID
          Model keys
static String OBJECTS_MAP_KEY
          Key to access the context's Map of built objects.
static String PARAMETER_CLASS_KEY
          Key to access the current parameter or property class.
static String PARAMETER_VALUE_KEY
          Key to access the current parameter or property class.
static String PROPERTY_NAME_KEY
          Key to access the current parameter or property name.
static String TAG_HANDLER_FACTORY_STACK_KEY
          Key to access the context's TagHandlerFactory stack.
static String WINDOW_CONTEXT_KEY
          The WindowContext which is building the current window.
static String WINDOW_KEY
          The builder itself
 
Method Summary
 void endElement(String qName, Map tagContext)
          Signals the end of an element in the XML source.
 void startElement(String qName, Map tagContext, Map atts)
          Signals the start of a new element in the XML source.
 

Field Detail

CURRENT_OBJECTS_STACK_KEY

public static final String CURRENT_OBJECTS_STACK_KEY
Key to access the context's current objects stack.

Initialized in Builder.

Never removed

Contains: a reference to a Stack object.

See Also:
Constant Field Values

CURRENT_PARM_ACC_KEY

public static final String CURRENT_PARM_ACC_KEY
Key to access the context's current ConstructorCall object.

Use this key when implementing TagHandlers that must update information on how the current object will be instantiated (parameters to constructor, for instance). For an example, see exitElement().

Initialized in ObjectTagHandler.

Removed in ParameterTagHandler.

Contains: a reference to a ConstructorCall object.

See Also:
Constant Field Values

OBJECTS_MAP_KEY

public static final String OBJECTS_MAP_KEY
Key to access the context's Map of built objects.

Use this key when referring to previously built objects in the current file.

Initialized in Builder.

Never removed

Contains: a reference to a Map object.

See Also:
Constant Field Values

CURRENT_WINDOW_KEY

public static final String CURRENT_WINDOW_KEY
Key to access the context's current window reference.

When the builder encounters a <window> element, it instantiates a window and saves the reference in the context. This way, descendants may use the context to get the current window, when they need it.

Initialized in WindowTagHandler.

Removed in WindowTagHandler.

Contains: a reference to a Window object. This depends on the type attribute that was encountered earlier on.

See Also:
Constant Field Values

CURRENT_WINDOW_ID_KEY

public static final String CURRENT_WINDOW_ID_KEY
Key to access the context's current window's ID.

When the builder encounters a <window> element, it saves the element's ID in the context. This way, descendants may refer to the window's ID to get the object when they need it.

Initialized in WindowTagHandler.

Removed in WindowTagHandler.

Contains: a reference to a String object.

See Also:
Constant Field Values

CONTROLS_STACK_KEY

public static final String CONTROLS_STACK_KEY
Deprecated. Replaced by CURRENT_OBJECTS_STACK_KEY.

Key to access the stack of controls being built.

When the builder encounters a <controls> element, it pushes the current window's content pane on a stack, which it stores under this key. As new controls are encountered, they are pushed on the stack. Once all controls have been built, the stack should be empty, and will be removed.

Initialized in ControlsTagHandler.

Removed in ControlsTagHandler.

Contains: a reference to a Stack object.

See Also:
Constant Field Values

CONSTANTS_MAP_KEY

public static final String CONSTANTS_MAP_KEY
Key to access the context's Map of constants.

This map must contain two items per constant definition:

This item will be used by ConstantTagHandler to find the map of constant names to values.

Initialized in Builder.

Never removed.

Contains: a reference to a Map object.

See Also:
Constant Field Values

CURRENT_OBJECT_KEY

public static final String CURRENT_OBJECT_KEY
Deprecated. Replaced by AbstractTagHandler.getCurrentObject(). The default implementation should not use this key anymore.

Key to access the object that has just been built.

Use this key when you need to refer to the object that has been built. This reference is valid until another object is being built, or the current scope terminates.

Initialized in ObjectTagHandler.

Removed in ObjectTagHandler.

Contains: a reference to a Object object (actually, the constructed object's class).

See Also:
Constant Field Values

CURRENT_OBJECT_ID_KEY

public static final String CURRENT_OBJECT_ID_KEY
Key to access the current construction's ID.

This key refers to the id attribute of the <object> element.

Initialized in ObjectTagHandler.

Removed in ObjectTagHandler.

Contains: a reference to a String object.

See Also:
Constant Field Values

CURRENT_CONSTRAINTS_KEY

public static final String CURRENT_CONSTRAINTS_KEY
Key to access the next control's constraints.

When the builder encounters <constraints>, it copies whatever was in the element's value and puts it in the context under this key. When the next controls are added, they will use these constraints.

Initialized in ConstraintsTagHandler.

Removed in ControlsTagHandler.

Contains: a reference to a Object.

See Also:
Constant Field Values

PROPERTY_NAME_KEY

public static final String PROPERTY_NAME_KEY
Key to access the current parameter or property name.

While building properties accessors and parameters, this key refers to the entity's name.

Initialized in ParameterTagHandler or PropertyTagHandler

Removed in ParameterTagHandler or PropertyTagHandler

Contains: a reference to a String object.

See Also:
Constant Field Values

PARAMETER_CLASS_KEY

public static final String PARAMETER_CLASS_KEY
Key to access the current parameter or property class.

While building properties accessors and parameters, this key refers to the entity's class.

Initialized in ParameterTagHandler or PropertyTagHandler

Removed in ParameterTagHandler or PropertyTagHandler

Contains: a reference to a Class object.

See Also:
Constant Field Values

PARAMETER_VALUE_KEY

public static final String PARAMETER_VALUE_KEY
Key to access the current parameter or property class.

While building properties accessors and parameters, this key refers to the entity's instantiated object.

If the value property was set using <constant>, the class will be set to the class of the reference's class. If the value property was set using <ref>, the class will be set to the class of the reference.

Initialized in ValueTagHandler, ConstantTagHandler or RefTagHandler.

Removed in ValueTagHandler, ConstantTagHandler or RefTagHandler.

Contains: a reference to a Object object.

See Also:
Constant Field Values

CALL_RETURN_CLASS_KEY

public static final String CALL_RETURN_CLASS_KEY
Key to access the last <methodCall>'s return value's class.

MethodCalls store the return value's class in this context property.

Initialized in MethodCallTagHandler.

Removed in MethodCallTagHandler.

Contains: a reference to a Class object.

See Also:
Constant Field Values

CALL_RETURN_VALUE_KEY

public static final String CALL_RETURN_VALUE_KEY
Key to access the last <methodCall>'s return value.

MethodCalls store the return value in this context property.

Initialized in MethodCallTagHandler.

Removed in MethodCallTagHandler.

Contains: a reference to a Object object.

See Also:
Constant Field Values

TAG_HANDLER_FACTORY_STACK_KEY

public static final String TAG_HANDLER_FACTORY_STACK_KEY
Key to access the context's TagHandlerFactory stack.

The top of this stack must always be the current factory. It is illegal for this stack to become empty. The default builder stores it's factory on this stack when it starts up. Elements which update this stack must ensure to always leave it as it was when they are done. Usually, this means pushing a new factory when opening the element, and popping the same factory when closing the element.

Initialized in Builder.

Removed in Builder.

Contains: a reference to a Stack.

See Also:
Constant Field Values

DOCUMENT_LOCATOR_KEY

public static final String DOCUMENT_LOCATOR_KEY
Key to access the current document's locator.

This locator key might not even exist because locators are the responsibility of the SAX parser, and are not required to provide one.

Initialized in Builder.

Never removed.

Contains: a reference to a Locator.

See Also:
Constant Field Values

MODEL_ID

public static final String MODEL_ID
Model keys

See Also:
Constant Field Values

CURRENT_MODEL_ATTRIBUTE

public static final String CURRENT_MODEL_ATTRIBUTE
Model keys

See Also:
Constant Field Values

CURRENT_MODEL_ADAPTER

public static final String CURRENT_MODEL_ADAPTER
Model keys

See Also:
Constant Field Values

WINDOW_KEY

public static final String WINDOW_KEY
The builder itself

See Also:
Constant Field Values

WINDOW_CONTEXT_KEY

public static final String WINDOW_CONTEXT_KEY
The WindowContext which is building the current window.

See Also:
Constant Field Values
Method Detail

startElement

public void startElement(String qName,
                         Map tagContext,
                         Map atts)
                  throws org.xml.sax.SAXException
Signals the start of a new element in the XML source.

The Builder object will call this method whenever it encounters a new element.

Parameters:
qName - The qualified name of the element as it was encountered.
tagContext - A map of context information that is kept accross all calls to TagHandlers.
atts - A map of the attributes that were passed to this element.
org.xml.sax.SAXException

endElement

public void endElement(String qName,
                       Map tagContext)
                throws org.xml.sax.SAXException
Signals the end of an element in the XML source.

The Builder object will call this method whenever an element ends.

Parameters:
qName - The qualified name of the element as it was encountered.
tagContext - A map of context information that is kept accross all calls to TagHandlers.
org.xml.sax.SAXException


Copyright 2002-2003, François Beausoleil, All Rights Reserved