org.geotools.xml.schema
Interface Type

All Known Subinterfaces:
ComplexType, SimpleType
All Known Implementing Classes:
ComplexTypeGT, FilterComplexTypes.SortOrderType, org.geotools.xml.filter.FilterSchema.FilterComplexType, org.geotools.xml.gml.GMLSchema.GMLComplexType, SimpleTypeGT, org.geotools.data.wms.xml.WMSSchema.WMSComplexType, XSISimpleTypes.AnyType, XSISimpleTypes.XSISimpleType

public interface Type

This is a convinience interface to help speed up the code, allowing for any type definition to handled in a consistent manner, independant of whether it's nested or not.

Author:
dzwiers www.refractions.net
See Also:
SimpleType, ComplexType

Method Summary
 boolean canEncode(Element element, java.lang.Object value, java.util.Map hints)
          Can I write this object out as element specified?
 void encode(Element element, java.lang.Object value, PrintHandler output, java.util.Map hints)
          Encode value as element on the provided output.
 Element findChildElement(java.lang.String name)
          Convinience method used to search this type's children for the requested element by localName.
 java.lang.Class getInstanceType()
           This will return the intended Java Class for this element type.
 java.lang.String getName()
           This returns the XML Schema declaration name of this type (both complex and simple types have names ...)
 java.net.URI getNamespace()
           This is used for validation of an XML document, and represents the targetNamespace of that this type resides in.
 java.lang.Object getValue(Element element, ElementValue[] value, org.xml.sax.Attributes attrs, java.util.Map hints)
           This method is intended to receive the child elements in the form of ElementValues (@see ElementValue).
 

Method Detail

getValue

public java.lang.Object getValue(Element element,
                                 ElementValue[] value,
                                 org.xml.sax.Attributes attrs,
                                 java.util.Map hints)
                          throws org.xml.sax.SAXException,
                                 javax.naming.OperationNotSupportedException

This method is intended to receive the child elements in the form of ElementValues (@see ElementValue). Recall that this is a pairing containing a reference to the type and the actual value (do not call .getValue on the types). This should return the real value (interpreted value) for this element based on it's children. Remember, this is a XML is a tree structure, so if you don't include some children, they are gone forever (so be careful when ignoring data).

If the element had #CData (Nested Child Text), this will appear in the first slot, with a null Element.

A SAXNotSupportedException should be thrown when the child's [inherited, default implementation of getValue(ElementValue[],Attributes)] method should be used.

Returns:
Object
Throws:
javax.naming.OperationNotSupportedException
org.xml.sax.SAXException
See Also:
ElementValue

getName

public java.lang.String getName()

This returns the XML Schema declaration name of this type (both complex and simple types have names ...)

Returns:

getNamespace

public java.net.URI getNamespace()

This is used for validation of an XML document, and represents the targetNamespace of that this type resides in.

Returns:

getInstanceType

public java.lang.Class getInstanceType()

This will return the intended Java Class for this element type. For generic complex types this will be an object array. SimpleTypes will match as they are parsed, and custom extensions will also return the appropriate class value.

Returns:

canEncode

public boolean canEncode(Element element,
                         java.lang.Object value,
                         java.util.Map hints)
Can I write this object out as element specified?

Parameters:
element - The element which may be used to represent the Object. This is included to allow for child definitions to include addition information where appropriate.
value - An Object which may or may not be encodeable by this type. The value may also be null.
Returns:
True when the encode method can interpret the given element/value pair into valid xml.
See Also:
Type#encode(Element, Object, Writer, Map)

encode

public void encode(Element element,
                   java.lang.Object value,
                   PrintHandler output,
                   java.util.Map hints)
            throws java.io.IOException,
                   javax.naming.OperationNotSupportedException
Encode value as element on the provided output.

This is encoding because the PrintHandler does not have to go back to a stream.

Parameters:
element - The original element declaration to which we should encode.
value - The Object to encode.
output - This is where the output should be written to.
hints - For providing additional context information to specific schemas.
Throws:
java.io.IOException - When there is an error with the Writer.
javax.naming.OperationNotSupportedException - When this type cannot be encoded ... and wasn't checked first.

findChildElement

public Element findChildElement(java.lang.String name)
Convinience method used to search this type's children for the requested element by localName.

Parameters:
name - the element's localName to search for.
Returns:


Copyright © GeoTools. All Rights Reserved.