com.ctc.wstx.dtd
Class DTDAttribute

java.lang.Object
  extended bycom.ctc.wstx.dtd.DTDAttribute
Direct Known Subclasses:
DTDEntitiesAttr, DTDEntityAttr, DTDEnumAttr, DTDIdAttr, DTDIdRefAttr, DTDIdRefsAttr, DTDNmTokenAttr, DTDNmTokensAttr, DTDNotationAttr, DTDTypedAttr

public class DTDAttribute
extends java.lang.Object

Base class for objects that contain attribute definitions from DTD. Sub-classes exists for specific typed attributes (enumeration-valued, non-CDATA ones); base class itself is used for attributes of type CDATA.


Field Summary
static int DEF_DEFAULT
           
static int DEF_FIXED
           
static int DEF_IMPLIED
           
static int DEF_REQUIRED
           
protected  java.lang.String mDefValue
           Note: Can not be made final since validation code may want to trim it down a bit...
protected  int mDefValueType
           
protected  NameKey mName
           
protected  int mSpecialIndex
          Index number amongst "special" attributes (required ones, attributes that have default values), if attribute is one: -1 if not.
static int TYPE_CDATA
           
static int TYPE_ENTITIES
           
static int TYPE_ENTITY
           
static int TYPE_ENUMERATED
           
static int TYPE_ID
           
static int TYPE_IDREF
           
static int TYPE_IDREFS
           
static int TYPE_NMTOKEN
           
static int TYPE_NMTOKENS
           
static int TYPE_NOTATION
           
 
Constructor Summary
DTDAttribute(NameKey name, int defValueType, java.lang.String defValue, int specIndex)
           
 
Method Summary
protected  void checkEntity(InputProblemReporter rep, java.lang.String id, EntityDecl ent)
           
 DTDAttribute cloneWith(int specIndex)
           
protected  EntityDecl findEntityDecl(ElementValidator v, char[] ch, int start, int len, int hash)
           
 int getDefaultType()
           
 java.lang.String getDefaultValue()
           
 NameKey getName()
           
 int getSpecialIndex()
           
 int getValueType()
          Returns the value type of this attribute as an enumerated int to match type (CDATA, ...)
 java.lang.String getValueTypeString()
           
 boolean isFixed()
           
 boolean isRequired()
           
 boolean isSpecial()
          Method used by the element to figure out if attribute needs "special" checking; basically if it's required, and/or has a default value.
static boolean isSpecial(int defValueType)
           
 boolean needsValidation()
           
protected  void reportInvalidChar(ElementValidator v, char c, java.lang.String msg)
           
protected  void reportParseError(ElementValidator v, java.lang.String msg)
           
protected  void reportParseError(InputProblemReporter rep, java.lang.String msg)
           
 java.lang.String toString()
           
 boolean typeIsId()
           
 boolean typeIsNotation()
           
 void validate(ElementValidator v, boolean normalize, AttributeCollector ac, int index)
          Method called by the ElementValidator to let the attribute do necessary normalization and/or validation for the value.
 void validateDefault(InputProblemReporter rep, boolean normalize)
          Method called by the ElementValidator to ask attribute to verify that the default it has (if any) is valid for such type.
protected  java.lang.String validateDefaultName(InputProblemReporter rep, boolean normalize)
           
protected  java.lang.String validateDefaultNames(InputProblemReporter rep, boolean normalize)
           
protected  java.lang.String validateDefaultNmToken(InputProblemReporter rep, boolean normalize)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_CDATA

public static final int TYPE_CDATA
See Also:
Constant Field Values

TYPE_ENUMERATED

public static final int TYPE_ENUMERATED
See Also:
Constant Field Values

TYPE_ID

public static final int TYPE_ID
See Also:
Constant Field Values

TYPE_IDREF

public static final int TYPE_IDREF
See Also:
Constant Field Values

TYPE_IDREFS

public static final int TYPE_IDREFS
See Also:
Constant Field Values

TYPE_ENTITY

public static final int TYPE_ENTITY
See Also:
Constant Field Values

TYPE_ENTITIES

public static final int TYPE_ENTITIES
See Also:
Constant Field Values

TYPE_NOTATION

public static final int TYPE_NOTATION
See Also:
Constant Field Values

TYPE_NMTOKEN

public static final int TYPE_NMTOKEN
See Also:
Constant Field Values

TYPE_NMTOKENS

public static final int TYPE_NMTOKENS
See Also:
Constant Field Values

DEF_DEFAULT

public static final int DEF_DEFAULT
See Also:
Constant Field Values

DEF_IMPLIED

public static final int DEF_IMPLIED
See Also:
Constant Field Values

DEF_REQUIRED

public static final int DEF_REQUIRED
See Also:
Constant Field Values

DEF_FIXED

public static final int DEF_FIXED
See Also:
Constant Field Values

mName

protected final NameKey mName

mSpecialIndex

protected final int mSpecialIndex
Index number amongst "special" attributes (required ones, attributes that have default values), if attribute is one: -1 if not.


mDefValueType

protected final int mDefValueType

mDefValue

protected java.lang.String mDefValue

Note: Can not be made final since validation code may want to trim it down a bit...

Constructor Detail

DTDAttribute

public DTDAttribute(NameKey name,
                    int defValueType,
                    java.lang.String defValue,
                    int specIndex)
Method Detail

cloneWith

public DTDAttribute cloneWith(int specIndex)

getName

public final NameKey getName()

toString

public final java.lang.String toString()

getDefaultType

public final int getDefaultType()

getDefaultValue

public final java.lang.String getDefaultValue()

isSpecial

public final boolean isSpecial()
Method used by the element to figure out if attribute needs "special" checking; basically if it's required, and/or has a default value. In both cases missing the attribute has specific consequences, either exception or addition of a default value.


isSpecial

public static boolean isSpecial(int defValueType)

isRequired

public final boolean isRequired()

isFixed

public final boolean isFixed()

getSpecialIndex

public final int getSpecialIndex()

needsValidation

public final boolean needsValidation()

getValueType

public int getValueType()
Returns the value type of this attribute as an enumerated int to match type (CDATA, ...)

Note:


getValueTypeString

public java.lang.String getValueTypeString()

typeIsId

public boolean typeIsId()

typeIsNotation

public boolean typeIsNotation()

validate

public void validate(ElementValidator v,
                     boolean normalize,
                     AttributeCollector ac,
                     int index)
              throws WstxException
Method called by the ElementValidator to let the attribute do necessary normalization and/or validation for the value.

Throws:
WstxException

validateDefault

public void validateDefault(InputProblemReporter rep,
                            boolean normalize)
                     throws WstxException
Method called by the ElementValidator to ask attribute to verify that the default it has (if any) is valid for such type.

Throws:
WstxException

validateDefaultName

protected java.lang.String validateDefaultName(InputProblemReporter rep,
                                               boolean normalize)
                                        throws WstxException
Throws:
WstxException

validateDefaultNames

protected java.lang.String validateDefaultNames(InputProblemReporter rep,
                                                boolean normalize)
                                         throws WstxException
Throws:
WstxException

validateDefaultNmToken

protected java.lang.String validateDefaultNmToken(InputProblemReporter rep,
                                                  boolean normalize)
                                           throws WstxException
Throws:
WstxException

findEntityDecl

protected EntityDecl findEntityDecl(ElementValidator v,
                                    char[] ch,
                                    int start,
                                    int len,
                                    int hash)
                             throws WstxException
Throws:
WstxException

checkEntity

protected void checkEntity(InputProblemReporter rep,
                           java.lang.String id,
                           EntityDecl ent)
                    throws WstxException
Throws:
WstxException

reportInvalidChar

protected void reportInvalidChar(ElementValidator v,
                                 char c,
                                 java.lang.String msg)
                          throws WstxException
Throws:
WstxException

reportParseError

protected void reportParseError(ElementValidator v,
                                java.lang.String msg)
                         throws WstxException
Throws:
WstxException

reportParseError

protected void reportParseError(InputProblemReporter rep,
                                java.lang.String msg)
                         throws WstxException
Throws:
WstxException