com.taursys.xml
Class AbstractField

java.lang.Object
  extended bycom.taursys.xml.Component
      extended bycom.taursys.xml.Parameter
          extended bycom.taursys.xml.AbstractField
All Implemented Interfaces:
DocumentComponent, Element, MapperComponent
Direct Known Subclasses:
AttributeField, CheckboxField, SelectField, TextField

public abstract class AbstractField
extends Parameter
implements Element

A Component which receives input and/or renders value to a Document. It responds to InputEvents and holds the given value. By default, this component uses a VariantTextModel. You can change this by overriding the createDefaultModel method or explicitly setting the model property.

This component can render its value to an xml Document (thru the DocumentAdapter). The id property indicates which element to render in the Document. The attributeName property is only used with an AttributeTextFieldRenderer to indicate which attribute to store the value in. Subclasses must override the processRenderEvent method and should delegate the work to a rendering subcomponent.


Constructor Summary
AbstractField()
          Constructs a new AbstractField with a default model.
AbstractField(int javaDataType)
          Creates a new AbstractField with a DefaultTextModel and VariantValueHolder of the given type.
 
Method Summary
 void addAttribute(Attribute attribute)
          Add the given Attribute to this Element.
 void addNotify()
          Registers this component with dispatcher to be notified of ParameterEvents This method invokes the lazyAddNotify method to perform the work
 void addTextNode(TextNode t)
          Add the given TextNode to this Element.
 Attribute createAttribute(java.lang.String attributeName)
          Creates and binds an Attribute with the given name to this Element.
 Attribute createAttribute(java.lang.String attributeName, int dataType)
          Creates and binds an Attribute of the given type with the given name to this Element.
 Attribute createAttribute(java.lang.String attributeName, java.lang.String propertyName, ValueHolder holder)
          Creates and binds an Attribute with the given name to this Element.
 Attribute createBoundAttribute(java.lang.String attributeName, java.lang.String propertyName)
          Creates and binds an Attribute with the given name to this Element.
 TextNode createBoundTextNode(java.lang.String propertyName)
          Creates and binds a TextNode with the given name to this Element.
 TextNode createTextNode()
          Creates and binds a TextNode to this Element.
 TextNode createTextNode(int dataType)
          Creates and binds a TextNode of the given type to this Element.
 TextNode createTextNode(java.lang.String propertyName, ValueHolder holder)
          Creates and binds a TextNode with the given name to this Element.
 Attribute getAttribute(java.lang.String attributeName)
          Gets an Attribute by name or null if it does not exist
 java.lang.String getAttributeName()
          Returns the name of the Element's attribute where the value should be rendered.
 java.lang.String getAttributeText(java.lang.String attributeName)
          Gets an Attribute's text value by name or null if it does not exist
 java.lang.Object getAttributeValue(java.lang.String attributeName)
          Gets an Attribute's Object value by name or null if it does not exist
 ElementDelegate getElementDelegate()
          Get the ElementDelegate for this component.
 java.lang.String getId()
          Returns the id of the Element this component is bound to.
 TextNode getTextNode()
          Gets the TextNode or null if it does not exist
 java.lang.String getTextNodeText()
          Gets the TextNode's text value or null if it does not exist
 java.lang.Object getTextNodeValue()
          Gets the TextNode's Object value or null if it does not exist
 boolean isEarlyInputNotify()
          Get flag for early input notification.
protected  void processInputEvent(InputEvent e)
          Store value and fires input event if event has correct input name.
abstract  void processRenderEvent(RenderEvent e)
          Responds to a render event for this component.
 void removeAttribute(Attribute attribute)
          Removes the given Attribute from this Element and sets its parent to null.
 void removeAttribute(java.lang.String attributeName)
          Removes the Attribute with the given name from this Container if found.
 void removeNotify()
          Un-Registers this component with dispatcher.
 void removeTextNode()
          Removes the TextNode from this Container if exists.
 void removeTextNode(TextNode t)
          Removes the given TextNode from this Element and sets its parent to null.
 void setAttributeName(java.lang.String newAttributeName)
          Sets the name of the Element's attribute where the value should be rendered.
 void setAttributeText(java.lang.String attributeName, java.lang.String value)
          Sets an Attribute's text value by name or does nothing if it does not exist.
 void setAttributeValue(java.lang.String attributeName, java.lang.Object value)
          Sets an Attribute's Object value by name or does nothing if it does not exist.
 void setEarlyInputNotify(boolean earlyInputNotify)
          Set flag for early input notification.
 void setId(java.lang.String newId)
          Sets the id of the Element this component is bound to.
 void setTextNodeText(java.lang.String value)
          Sets the TextNode's text value or does nothing if it does not exist.
 void setTextNodeValue(java.lang.Object value)
          Sets the TextNode's Object value or does nothing if it does not exist.
 void setValueHolder(ValueHolder newValueHolder)
          Sets the valueHolder for the model.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class com.taursys.xml.Parameter
createDefaultModel, createDefaultModel, getDefaultValue, getFormat, getFormatPattern, getModel, getParameter, getPropertyName, getText, getValue, getValueHolder, processParameterEvent, setDefaultValue, setFormat, setFormatPattern, setModel, setParameter, setPropertyName, setText, setValue
 
Methods inherited from class com.taursys.xml.Component
addEventType, addInputListener, addParameterListener, addRecycleListener, addRenderListener, addTriggerListener, dispatchEvent, fireActionPerformed, fireInputReceived, fireParameterReceived, fireRecycle, fireRender, getEventTypeList, getParent, isNotifySet, isVisible, lazyAddNotify, lazyRemoveNotify, processEvent, processRecycleEvent, processTriggerEvent, removeEventType, removeInputListener, removeParameterListener, removeRecycleListener, removeRenderListener, removeTriggerListener, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractField

public AbstractField()
Constructs a new AbstractField with a default model. The default model, a VariantTextModel, is created via the createDefaultModel method in the Parameter superclass.


AbstractField

public AbstractField(int javaDataType)
Creates a new AbstractField with a DefaultTextModel and VariantValueHolder of the given type. See com.taursys.util.DataTypes for defined data type constants TYPE_XXXXXX.

Method Detail

processInputEvent

protected void processInputEvent(InputEvent e)
                          throws java.lang.Exception
Store value and fires input event if event has correct input name.

Overrides:
processInputEvent in class Component
Throws:
java.lang.Exception

processRenderEvent

public abstract void processRenderEvent(RenderEvent e)
                                 throws RenderException
Responds to a render event for this component. Subclasses must override the processRenderEvent method and should delegate the work to a rendering subcomponent.

Overrides:
processRenderEvent in class Component
Parameters:
e - the RenderEvent to process
Throws:
RenderException - for any problems during rendering

setEarlyInputNotify

public void setEarlyInputNotify(boolean earlyInputNotify)
Set flag for early input notification. Normally this field registers to receive InputEvents. If earlyInputNofity is true, it will register to receive ParameterEvents instead. It will then be notified of input at the same time as Parameter components. This method will also force new registration if isNotifySet is true.

Parameters:
earlyInputNotify - flag for early input notification.

isEarlyInputNotify

public boolean isEarlyInputNotify()
Get flag for early input notification. Normally this field registers to receive InputEvents. If earlyInputNofity is true, it will register to receive ParameterEvents instead. It will then be notified of input at the same time as Parameter components. This method will also force new registration if isNotifySet is true.

Returns:
earlyInputNotify flag for early input notification.

setId

public void setId(java.lang.String newId)
Sets the id of the Element this component is bound to. This is the Element where the component will render its value.

Specified by:
setId in interface DocumentComponent

getId

public java.lang.String getId()
Returns the id of the Element this component is bound to. This is the Element where the component will render its value.

Specified by:
getId in interface DocumentComponent

setAttributeName

public void setAttributeName(java.lang.String newAttributeName)
Sets the name of the Element's attribute where the value should be rendered. This property is only used when a AttributeTextFieldRenderer is used. The default is "value".


getAttributeName

public java.lang.String getAttributeName()
Returns the name of the Element's attribute where the value should be rendered. This property is only used when a AttributeTextFieldRenderer is used. The default is "value".


getElementDelegate

public ElementDelegate getElementDelegate()
Get the ElementDelegate for this component.

Returns:
the ElementDelegate for this component.

toString

public java.lang.String toString()
Returns a string representation of this object. This contains the object identity and state information.

Overrides:
toString in class Parameter
Returns:
a string representation of this object

addAttribute

public void addAttribute(Attribute attribute)
Description copied from interface: Element
Add the given Attribute to this Element. No action is taken if the attribute already belongs to this Element. If the Attribute belongs to another Element as indicated by its parent, it is first removed from the old Element before it is added to this Element. Finally, it is added to this Element and its parent is set to this Element. The Attribute's addNotify method is also invoked so it will be notified of events it is interested in.

Specified by:
addAttribute in interface Element
Parameters:
attribute - the Attribute to add

removeAttribute

public void removeAttribute(Attribute attribute)
Description copied from interface: Element
Removes the given Attribute from this Element and sets its parent to null. Also invokes removeNotify on the given Attribute so it will un-register itself with any dispatchers.

Specified by:
removeAttribute in interface Element
Parameters:
attribute - the Attribute to remove

createAttribute

public Attribute createAttribute(java.lang.String attributeName)
Description copied from interface: Element
Creates and binds an Attribute with the given name to this Element. If the Attribute already exists, the existing one is returned.

Specified by:
createAttribute in interface Element
Parameters:
attributeName - name of the new Attribute
Returns:
the newly created and bound Attribute

createAttribute

public Attribute createAttribute(java.lang.String attributeName,
                                 int dataType)
Description copied from interface: Element
Creates and binds an Attribute of the given type with the given name to this Element. If the Attribute already exists, the existing one is returned.

Specified by:
createAttribute in interface Element
Parameters:
attributeName - name of the new Attribute
dataType - the data type for the new Attribute
Returns:
the newly created and bound Attribute
See Also:
DataTypes

createBoundAttribute

public Attribute createBoundAttribute(java.lang.String attributeName,
                                      java.lang.String propertyName)
Description copied from interface: Element
Creates and binds an Attribute with the given name to this Element. The Attribute is bound to this Element's valueHolder with the given propertyName. If the Attribute already exists, the propertyName is changed and the existing Attribute is returned.

Specified by:
createBoundAttribute in interface Element
Parameters:
attributeName - name of the new Attribute
propertyName - for the new Attribute
Returns:
the newly created and bound Attribute

createAttribute

public Attribute createAttribute(java.lang.String attributeName,
                                 java.lang.String propertyName,
                                 ValueHolder holder)
Description copied from interface: Element
Creates and binds an Attribute with the given name to this Element. The Attribute is bound to the given valueHolder with the given propertyName. If the Attribute already exists, the valueHolder and propertyName are changed and the existing Attribute is returned. The Attribute is also un-bound from this Element's valueHolder.

Specified by:
createAttribute in interface Element
Parameters:
attributeName - name of the new Attribute
propertyName - for the new Attribute
holder - ValueHolder for the new Attribute
Returns:
the newly created and bound Attribute

getAttribute

public Attribute getAttribute(java.lang.String attributeName)
Description copied from interface: Element
Gets an Attribute by name or null if it does not exist

Specified by:
getAttribute in interface Element
Parameters:
attributeName - the name of the Attribute
Returns:
an Attribute by name or null if it does not exist

getAttributeText

public java.lang.String getAttributeText(java.lang.String attributeName)
                                  throws ModelException
Description copied from interface: Element
Gets an Attribute's text value by name or null if it does not exist

Specified by:
getAttributeText in interface Element
Parameters:
attributeName - the name of the Attribute
Returns:
an Attribute's text value by name or null if it does not exist
Throws:
ModelException

getAttributeValue

public java.lang.Object getAttributeValue(java.lang.String attributeName)
                                   throws ModelException
Description copied from interface: Element
Gets an Attribute's Object value by name or null if it does not exist

Specified by:
getAttributeValue in interface Element
Parameters:
attributeName -
Returns:
Throws:
ModelException

removeAttribute

public void removeAttribute(java.lang.String attributeName)
Description copied from interface: Element
Removes the Attribute with the given name from this Container if found. It does NOT alter the properties of the Attribute in any way.

Specified by:
removeAttribute in interface Element
Parameters:
attributeName - to remove

setAttributeText

public void setAttributeText(java.lang.String attributeName,
                             java.lang.String value)
                      throws ModelException
Description copied from interface: Element
Sets an Attribute's text value by name or does nothing if it does not exist. Logs a warning if attribute does not exist.

Specified by:
setAttributeText in interface Element
Parameters:
attributeName - the name of the Attribute
value - the new String value for the Attribute
Throws:
ModelException

setAttributeValue

public void setAttributeValue(java.lang.String attributeName,
                              java.lang.Object value)
                       throws ModelException
Description copied from interface: Element
Sets an Attribute's Object value by name or does nothing if it does not exist. Logs a warning if attribute does not exist.

Specified by:
setAttributeValue in interface Element
Parameters:
attributeName -
value -
Throws:
ModelException

addTextNode

public void addTextNode(TextNode t)
Description copied from interface: Element
Add the given TextNode to this Element. No action is taken if a textNode already belongs to this Element. If the TextNode belongs to another Element as indicated by its parent, it is first removed from the old Element before it is added to this Element. Finally, it is added to this Element and its parent is set to this Element. The TextNode's addNotify method is also invoked so it will be notified of events it is interested in.

Specified by:
addTextNode in interface Element

createBoundTextNode

public TextNode createBoundTextNode(java.lang.String propertyName)
Description copied from interface: Element
Creates and binds a TextNode with the given name to this Element. The TextNode is bound to this Element's valueHolder with the given propertyName. If the TextNode already exists, the propertyName is changed and the existing TextNode is returned.

Specified by:
createBoundTextNode in interface Element
Parameters:
propertyName - for the new TextNode
Returns:
the newly created and bound TextNode

createTextNode

public TextNode createTextNode()
Description copied from interface: Element
Creates and binds a TextNode to this Element. If the TextNode already exists, the existing one is returned.

Specified by:
createTextNode in interface Element
Returns:
the newly created and bound TextNode

createTextNode

public TextNode createTextNode(int dataType)
Description copied from interface: Element
Creates and binds a TextNode of the given type to this Element. If the TextNode already exists, the existing one is returned.

Specified by:
createTextNode in interface Element
Parameters:
dataType - the data type for the new TextNode
Returns:
the newly created and bound TextNode
See Also:
DataTypes

createTextNode

public TextNode createTextNode(java.lang.String propertyName,
                               ValueHolder holder)
Description copied from interface: Element
Creates and binds a TextNode with the given name to this Element. The TextNode is bound to the given valueHolder with the given propertyName. If the TextNode already exists, the valueHolder and propertyName are changed and the existing TextNode is returned. The TextNode is also un-bound from this Element's valueHolder.

Specified by:
createTextNode in interface Element
Parameters:
propertyName - for the new TextNode
holder - ValueHolder for the new TextNode
Returns:
the newly created and bound TextNode

getTextNode

public TextNode getTextNode()
Description copied from interface: Element
Gets the TextNode or null if it does not exist

Specified by:
getTextNode in interface Element
Returns:
the TextNode or null if it does not exist

getTextNodeText

public java.lang.String getTextNodeText()
                                 throws ModelException
Description copied from interface: Element
Gets the TextNode's text value or null if it does not exist

Specified by:
getTextNodeText in interface Element
Returns:
the TextNode's text value or null if it does not exist
Throws:
ModelException

getTextNodeValue

public java.lang.Object getTextNodeValue()
                                  throws ModelException
Description copied from interface: Element
Gets the TextNode's Object value or null if it does not exist

Specified by:
getTextNodeValue in interface Element
Returns:
the TextNode's Object value or null if it does not exist
Throws:
ModelException

removeTextNode

public void removeTextNode()
Description copied from interface: Element
Removes the TextNode from this Container if exists. It does NOT alter the properties of the TextNode in any way.

Specified by:
removeTextNode in interface Element

removeTextNode

public void removeTextNode(TextNode t)
Description copied from interface: Element
Removes the given TextNode from this Element and sets its parent to null. Also invokes removeNotify on the given TextNode so it will un-register itself with any dispatchers.

Specified by:
removeTextNode in interface Element

setTextNodeText

public void setTextNodeText(java.lang.String value)
                     throws ModelException
Description copied from interface: Element
Sets the TextNode's text value or does nothing if it does not exist.

Specified by:
setTextNodeText in interface Element
Parameters:
value - the new String value for the TextNode
Throws:
ModelException

setTextNodeValue

public void setTextNodeValue(java.lang.Object value)
                      throws ModelException
Description copied from interface: Element
Sets the TextNode's Object value or does nothing if it does not exist.

Specified by:
setTextNodeValue in interface Element
Parameters:
value - the new Object value for the TextNode
Throws:
ModelException

addNotify

public void addNotify()
Description copied from class: Component
Registers this component with dispatcher to be notified of ParameterEvents This method invokes the lazyAddNotify method to perform the work

Overrides:
addNotify in class Component

removeNotify

public void removeNotify()
Description copied from class: Component
Un-Registers this component with dispatcher. This method invokes the lazyRemoveNotify method to perform the work

Overrides:
removeNotify in class Component

setValueHolder

public void setValueHolder(ValueHolder newValueHolder)
Description copied from class: Parameter
Sets the valueHolder for the model. The valueHolder is the object which holds the Object where the model stores the value. The default valueHolder is a VariantValueHolder with a javaDataType of String.

Overrides:
setValueHolder in class Parameter


Copyright © 2007 Martin T Phelan. All Rights Reserved.