ilog.cpl.storage
Class IlpSAXAttributeValueHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by ilog.cpl.storage.IlpAbstractSAXHandler
          extended by ilog.cpl.storage.IlpAbstractChainedSAXHandler
              extended by ilog.cpl.storage.IlpSAXAttributeValueHandler
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler
Direct Known Subclasses:
IlpGeographicPolyPointsSAXInfo.IlpSAXPolyPointsHandler, IlpGeographicPositionSAXInfo.IlpSAXGeographicPositionHandler, IlpPointSAXInfo.IlpSAXPointHandler, IlpPolyPointsSAXInfo.IlpSAXPolyPointsHandler, IlpShelfItemPositionSAXInfo.IlpSAXShelfItemHandler, IlpSlotSizesSAXInfo.IlpSAXSlotSizesHandler, IltAlarmSeverityAttribute.IlpSAXAlarmSeverityHandler

public class IlpSAXAttributeValueHandler
extends IlpAbstractChainedSAXHandler

Default SAX handler for attribute values.

This class is used to retrieve the values of attributes in an XML file or stream.

The values may be default values of attributes, or the values of attributes of an instance.

By default, the value of an attribute is directly the text of the attribute element converted to the "right" class.

This class may either be specified in the XML file or come from the IlpAttribute.

To change this behavior, you can derive this class and provide your custom implementation for your attribute classes or IlpAttribute using the IlpSAXSerializable interface.

Since:
JTGO 3.0
See Also:
IlpSAXSerializable

Nested Class Summary
static interface IlpSAXAttributeValueHandler.ResultHandler
          Internal use.
 
Constructor Summary
IlpSAXAttributeValueHandler()
           
 
Method Summary
 void endElement(String namespaceURI, String localName, String qName)
          Notifies that the end of an element is reached.
protected  Object getAttributeValue()
          This method is called at the end of the finalTag element.
protected  String getFinalTag()
          Returns the tag used to finalize the element.
protected  IlpSAXAttributeValueHandler.ResultHandler getResultHandler()
          Returns the result handler.
 Class getTargetClass()
          Returns the target class.
 IlpTypeConverter getTypeConverter()
          Returns the type converter.
protected  boolean isNull()
          Returns true if the result is null.
 void readValue(IlpAbstractSAXHandler parent, String finalTag, IlpSAXAttributeValueHandler.ResultHandler resultHandler, Class targetClass, IlpTypeConverter typeConverter)
           
 void startElement(String namespaceURI, String localName, String qName, Attributes atts)
          Notifies the beginning of an element.
 
Methods inherited from class ilog.cpl.storage.IlpAbstractChainedSAXHandler
getLocator, getLogger, getParent, getXMLReader, setParent
 
Methods inherited from class ilog.cpl.storage.IlpAbstractSAXHandler
characters, checkState, clearContent, clearState, error, fatalError, getContent, getState, ignoreUntil, log, logIgnoreElement, processSAXParseException, removeState, setState, throwSAXParseException, warning
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlpSAXAttributeValueHandler

public IlpSAXAttributeValueHandler()
Method Detail

getTargetClass

public Class getTargetClass()
Returns the target class. The target class is the class of the object read by this handler. It may be not be abstract in this default implementation, but nothing prevents it from being so in your own implementation.
The target class is either read from the XML file (javaClass) XML attribute, or comes from IlpAttribute (see IlpAttribute.getValueClass().


getTypeConverter

public IlpTypeConverter getTypeConverter()
Returns the type converter. This type converter is used to transform the element's text into the target Java class in the regular attribute value handler. You may use it or not.


isNull

protected boolean isNull()
Returns true if the result is null.

Internal method or field: do not use!

getFinalTag

protected String getFinalTag()
Returns the tag used to finalize the element.

Returns:
Final tag
Since:
JViews 7.5
Internal method or field: do not use!

getResultHandler

protected IlpSAXAttributeValueHandler.ResultHandler getResultHandler()
Returns the result handler.

Returns:
Result handler
Since:
JViews 7.5
Internal method or field: do not use!

readValue

public void readValue(IlpAbstractSAXHandler parent,
                      String finalTag,
                      IlpSAXAttributeValueHandler.ResultHandler resultHandler,
                      Class targetClass,
                      IlpTypeConverter typeConverter)
Internal method or field: do not use!

startElement

public void startElement(String namespaceURI,
                         String localName,
                         String qName,
                         Attributes atts)
                  throws SAXException
Notifies the beginning of an element. By default, this method checks if there is a null XML attribute and clears the content of the element. If you redefine this method, take care of always calling this implementation.

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler
Throws:
SAXException

endElement

public void endElement(String namespaceURI,
                       String localName,
                       String qName)
                throws SAXException
Notifies that the end of an element is reached. When the this method is called for the finalTag element, the getAttributeValue method is called if the null XML attribute is not true, the resultHandler.setAttributeValue method is called and the parsing continues with the parent contentHandler. If you redefine this method, make sure you always call this implementation.

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class DefaultHandler
Throws:
SAXException

getAttributeValue

protected Object getAttributeValue()
This method is called at the end of the finalTag element. By default, it converts the content to the target class using the type converter. It is not even called if isNull() returns true; that is, if the null XML attribute was set to true.



Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.   . All Rights Reserved.