org.idoox.xml.schema
Class Facet

java.lang.Object
  extended byorg.idoox.xml.schema.Facet
Direct Known Subclasses:
Facet.Enumeration, Facet.FixableFacet, Facet.Pattern

public abstract class Facet
extends java.lang.Object

This class represents common base for all facets from XML Schema.

Since:
4.7
Component:
Core

Nested Class Summary
static class Facet.Enumeration
          This class represents the enumeration XML Schema facet.
static class Facet.FacetEnum
          Enumeration of all facets defined in XML Schema.
static class Facet.FixableFacet
          A fixable facet is such a facet which supports the fixed attribute.
static class Facet.FractionDigits
          This class represents the fractionDigits XML Schema facet.
static class Facet.Length
          This class represents the length XML Schema facet.
static class Facet.MaxExclusive
          This class represents the maxExclusive XML Schema facet.
static class Facet.MaxInclusive
          This class represents the maxInclusive XML Schema facet.
static class Facet.MaxLength
          This class represents the maxLength XML Schema facet.
static class Facet.MinExclusive
          This class represents the minExclusive XML Schema facet.
static class Facet.MinInclusive
          This class represents the minExclusive XML Schema facet.
static class Facet.MinLength
          This class represents the minLength XML Schema facet.
static class Facet.Pattern
          This class represents the pattern XML Schema facet.
static class Facet.TotalDigits
          This class represents the totalDigits XML Schema facet.
static class Facet.WhiteSpace
          This class represents the whiteSpace XML Schema facet.
 
Field Summary
protected  java.lang.String name
          local name of the facet, e.g.
protected  java.lang.String value
          lexical value of the facet, i.e.
 
Constructor Summary
protected Facet(java.lang.String name, java.lang.String value)
          Creates new instance of Facet.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Returns whether the two facets have the same name and contain the same value.
 java.lang.String getName()
          Returns name of the element that represents this facet (e.g.
 java.lang.String getValue()
          Returns value of the facet (content of attribute value)
 int hashCode()
          Returns hashCode of this instance.
 java.lang.String toString()
          Returns stringified representation of the facet.
 void writeAsXML(TokenWriter writer)
          Writes representation of this facet into XML stream.
protected  void writeInnerXMLContent(TokenWriter writer)
          Customizes the content of the enclosing xml tag representing the recent restriction facet.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected final java.lang.String name
local name of the facet, e.g. minExclusive, maxInclusive,...


value

protected final java.lang.String value
lexical value of the facet, i.e. any valid string with respect to current facet type and holding data type (optional - e.g. length will always hold a number, in opposite to maxInclusive, which may hold either number, date,...)

Constructor Detail

Facet

protected Facet(java.lang.String name,
                java.lang.String value)
         throws SchemaException
Creates new instance of Facet. This is protected intentionally not to be able to create direct instances of this class, but to create derived classes.

Parameters:
name - name of the facet (identified its type)
value - value of the facet (constrains the value or lexical space of a type)
Throws:
SchemaException - if the validation of the given parameters fails (some attributes missing or have incorrect value)
Method Detail

getName

public java.lang.String getName()
Returns name of the element that represents this facet (e.g. minExclusive). The name is given at construction time.

Returns:
name of the facet

getValue

public java.lang.String getValue()
Returns value of the facet (content of attribute value)


toString

public java.lang.String toString()
Returns stringified representation of the facet.


hashCode

public int hashCode()
Returns hashCode of this instance. It is not unique as the name says :)


equals

public boolean equals(java.lang.Object obj)
Returns whether the two facets have the same name and contain the same value. Warning: the value of the fixed attribute is not considered intentionally.

Parameters:
obj - facet to compare to

writeAsXML

public final void writeAsXML(TokenWriter writer)
                      throws java.io.IOException
Writes representation of this facet into XML stream. The basic skeleton is written by this method (starting tag along with the 'value' attribute and closing tag), the inner content may be adjusted in writeInnerXMLContent(org.idoox.xml.TokenWriter).

Parameters:
writer - writer to be used
Throws:
java.io.IOException - no comment

writeInnerXMLContent

protected void writeInnerXMLContent(TokenWriter writer)
                             throws java.io.IOException
Customizes the content of the enclosing xml tag representing the recent restriction facet. You can write attributes as well as some real content of the enclosing tag. The name of the enclosing tag is determined by the facet name - given at construction time.

This implementation is empty.

Parameters:
writer - writer to be used to write into the XML stream
Throws:
java.io.IOException - no comment