Top Description Fields Constructors Methods
com.sun.xml.internal.stream.dtd.nonvalidating

public Class DTDGrammar

extends Object
Class Inheritance
Imports
com.sun.org.apache.xerces.internal.util.SymbolTable, .XMLSymbols, com.sun.org.apache.xerces.internal.xni.Augmentations, .QName, .XMLLocator, .XMLResourceIdentifier, .XMLString, .XNIException, com.sun.org.apache.xerces.internal.xni.parser.XMLDTDContentModelSource, .XMLDTDSource, java.util.ArrayList, .HashMap, .List, .Map

A DTD grammar. This class implements the XNI handler interfaces for DTD information so that it can build the appropriate validation structures automatically from the callbacks.
Authors
Eric Ye, IBM, Jeffrey Rodriguez, IBM, Andy Clark, IBM, Neil Graham, IBM

Field Summary

Modifier and TypeField and Description
private static final int
CHUNK_MASK

Chunk mask (CHUNK_SIZE - 1).

private static final int
CHUNK_SHIFT

Chunk shift (8).

private static final int
CHUNK_SIZE

Chunk size (1 << CHUNK_SHIFT).

private static final boolean
DEBUG

Debug DTDGrammar.

protected XMLAttributeDecl
fAttributeDecl

Temporary Attribute decl.

private int
fAttributeDeclCount

Number of attribute declarations.

private short[][]
private String[][]
private String[][][]
fAttributeDeclEnumeration

Attribute declaration enumeration values.

private QName[][]
fAttributeDeclName

Attribute declaration name.

private int[][]
private String[][]
private short[][]
fAttributeDeclType

Attribute declaration type.

protected int
fCurrentAttributeIndex

Current attribute index.

protected int
fCurrentElementIndex

Current element index.

protected XMLDTDContentModelSource
protected XMLDTDSource
private XMLElementDecl
fElementDecl

Element declaration.

private int
fElementDeclCount

Number of element declarations.

private int[][]
fElementDeclFirstAttributeDeclIndex

First attribute declaration of an element declaration.

private int[][]
fElementDeclLastAttributeDeclIndex

Last attribute declaration of an element declaration.

private QName[][]
fElementDeclName

Element declaration name.

pack-priv Map<String, XMLElementDecl>
fElementDeclTab

table of XMLElementDecl

private short[][]
fElementDeclType

Element declaration type.

private final Map<String, Integer>
fElementIndexMap

Element index mapping table.

private final QName
fQName

Temporary qualified name.

protected boolean
fReadingExternalDTD

fReadingExternalDTD

private XMLSimpleType
fSimpleType

Simple type.

private final SymbolTable
fSymbolTable

Symbol table.

private static final int
INITIAL_CHUNK_COUNT

Initial chunk count (1 << (10 - CHUNK_SHIFT)).

private static final short
LIST_FLAG

List flag (0x80).

private static final short
LIST_MASK

List mask (~LIST_FLAG).

private final ArrayList<XMLNotationDecl>
public static final int
TOP_LEVEL_SCOPE

Top level scope (-1).

Constructor Summary

AccessConstructor and Description
public
DTDGrammar(SymbolTable symbolTable)

Default constructor.

Method Summary

Modifier and TypeMethod and Description
public void
attributeDecl(String
The name of the element that this attribute is associated with.
elementName
,
String
The name of the attribute.
attributeName
,
String
The attribute type. This value will be one of the following: "CDATA", "ENTITY", "ENTITIES", "ENUMERATION", "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", or "NOTATION".
type
,
String[]
If the type has the value "ENUMERATION", this array holds the allowed attribute values; otherwise, this array is null.
enumeration
,
String
The attribute default type. This value will be one of the following: "#FIXED", "#IMPLIED", "#REQUIRED", or null.
defaultType
,
XMLString
The attribute default value, or null if no default value is specified.
defaultValue
,
XMLString
The attribute default value with no normalization performed, or null if no default value is specified.
nonNormalizedDefaultValue
,
Augmentations
Additional information that may include infoset augmentations.
augs
)

An attribute declaration.

protected int
protected int
public void
elementDecl(String
The name of the element.
name
,
String
The element content model.
contentModel
,
Augmentations
Additional information that may include infoset augmentations.
augs
)

An element declaration.

public void
private void
private void
public boolean

Returns:

true if getAttributeDecl was able to fill in the value of attributeDecl
getAttributeDecl
(int attributeDeclIndex, XMLAttributeDecl
The values of this structure are set by this call.
attributeDecl
)

getAttributeDecl

public int
getAttributeDeclIndex(int elementDeclIndex, String attributeDeclName)

public short
getContentSpecType(int elementIndex)

make separate function for getting contentSpecType of element.

public boolean

Returns:

True if find the element, False otherwise.
getElementDecl
(int elementDeclIndex, XMLElementDecl
The values of this structure are set by this call.
elementDecl
)

getElementDecl

public int

Returns:

index of the elementDeclName in scope
getElementDeclIndex
(String elementDeclName)

getElementDeclIndex

public int
getElementDeclIndex(QName
qualilfied name of the element
elementDeclQName
)

Returns the element decl index.

public int

Returns:

index of the first attribute for element declaration elementDeclIndex
getFirstAttributeDeclIndex
(int elementDeclIndex)

getFirstAttributeDeclIndex

public int
getFirstElementDeclIndex()

Returns the index of the first element declaration.

public int

Returns:

index of the next attribute of the attribute at attributeDeclIndex
getNextAttributeDeclIndex
(int attributeDeclIndex)

getNextAttributeDeclIndex

public int
getNextElementDeclIndex(int
The element declaration index.
elementDeclIndex
)

Returns the next index of the element declaration following the specified element declaration.

public List<XMLNotationDecl>
public SymbolTable
getSymbolTable()

Returns the symbol table.

public boolean

Returns:

true if the attribute is of type CDATA
isCDATAAttribute
(QName
The element name.
elName
,
QName
The attribute name.
atName
)

Returns whether the given attribute is of type CDATA or not

private boolean

Returns:

Whether the value was changed or not.
normalizeDefaultAttrValue
(XMLString
The value to normalize
value
)

Normalize the attribute value of a non CDATA default attribute collapsing sequences of space characters (x20)

public void
private void
printAttribute(int attributeDeclIndex)

public void
printAttributes(int elementDeclIndex)

public void
private static short[][]
resize(short[][] array, int newsize)

private static int[][]
resize(int[][] array, int newsize)

private static QName[][]
resize(QName[][] array, int newsize)

private static String[][]
resize(String[][] array, int newsize)

private static String[][][]
resize(String[][][] array, int newsize)

protected void
setAttributeDecl(int elementDeclIndex, int attributeDeclIndex, XMLAttributeDecl attributeDecl)

protected void
setElementDecl(int elementDeclIndex, XMLElementDecl elementDecl)

protected void
setFirstAttributeDeclIndex(int elementDeclIndex, int newFirstAttrIndex)

public void
startDTD(XMLLocator
The document locator, or null if the document location cannot be reported during the parsing of the document DTD. However, it is strongly recommended that a locator be supplied that can at least report the base system identifier of the DTD.
locator
,
Augmentations
Additional information that may include infoset augmentations.
augs
)

The start of the DTD.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CHUNK_MASKback to summary
private static final int CHUNK_MASK

Chunk mask (CHUNK_SIZE - 1).

CHUNK_SHIFTback to summary
private static final int CHUNK_SHIFT

Chunk shift (8).

CHUNK_SIZEback to summary
private static final int CHUNK_SIZE

Chunk size (1 << CHUNK_SHIFT).

DEBUGback to summary
private static final boolean DEBUG

Debug DTDGrammar.

fAttributeDeclback to summary
protected XMLAttributeDecl fAttributeDecl

Temporary Attribute decl.

fAttributeDeclCountback to summary
private int fAttributeDeclCount

Number of attribute declarations.

fAttributeDeclDefaultTypeback to summary
private short[][] fAttributeDeclDefaultType
fAttributeDeclDefaultValueback to summary
private String[][] fAttributeDeclDefaultValue
fAttributeDeclEnumerationback to summary
private String[][][] fAttributeDeclEnumeration

Attribute declaration enumeration values.

fAttributeDeclNameback to summary
private QName[][] fAttributeDeclName

Attribute declaration name.

fAttributeDeclNextAttributeDeclIndexback to summary
private int[][] fAttributeDeclNextAttributeDeclIndex
fAttributeDeclNonNormalizedDefaultValueback to summary
private String[][] fAttributeDeclNonNormalizedDefaultValue
fAttributeDeclTypeback to summary
private short[][] fAttributeDeclType

Attribute declaration type.

See Also
XMLAttributeDecl
fCurrentAttributeIndexback to summary
protected int fCurrentAttributeIndex

Current attribute index.

fCurrentElementIndexback to summary
protected int fCurrentElementIndex

Current element index.

fDTDContentModelSourceback to summary
protected XMLDTDContentModelSource fDTDContentModelSource
fDTDSourceback to summary
protected XMLDTDSource fDTDSource
fElementDeclback to summary
private XMLElementDecl fElementDecl

Element declaration.

fElementDeclCountback to summary
private int fElementDeclCount

Number of element declarations.

fElementDeclFirstAttributeDeclIndexback to summary
private int[][] fElementDeclFirstAttributeDeclIndex

First attribute declaration of an element declaration.

fElementDeclLastAttributeDeclIndexback to summary
private int[][] fElementDeclLastAttributeDeclIndex

Last attribute declaration of an element declaration.

fElementDeclNameback to summary
private QName[][] fElementDeclName

Element declaration name.

fElementDeclTabback to summary
pack-priv Map<String, XMLElementDecl> fElementDeclTab

table of XMLElementDecl

fElementDeclTypeback to summary
private short[][] fElementDeclType

Element declaration type.

See Also
XMLElementDecl
fElementIndexMapback to summary
private final Map<String, Integer> fElementIndexMap

Element index mapping table.

fQNameback to summary
private final QName fQName

Temporary qualified name.

fReadingExternalDTDback to summary
protected boolean fReadingExternalDTD

fReadingExternalDTD

fSimpleTypeback to summary
private XMLSimpleType fSimpleType

Simple type.

fSymbolTableback to summary
private final SymbolTable fSymbolTable

Symbol table.

INITIAL_CHUNK_COUNTback to summary
private static final int INITIAL_CHUNK_COUNT

Initial chunk count (1 << (10 - CHUNK_SHIFT)).

LIST_FLAGback to summary
private static final short LIST_FLAG

List flag (0x80).

LIST_MASKback to summary
private static final short LIST_MASK

List mask (~LIST_FLAG).

notationDeclsback to summary
private final ArrayList<XMLNotationDecl> notationDecls
TOP_LEVEL_SCOPEback to summary
public static final int TOP_LEVEL_SCOPE

Top level scope (-1).

Constructor Detail

DTDGrammarback to summary
public DTDGrammar(SymbolTable symbolTable)

Default constructor.

Method Detail

attributeDeclback to summary
public void attributeDecl(String elementName, String attributeName, String type, String[] enumeration, String defaultType, XMLString defaultValue, XMLString nonNormalizedDefaultValue, Augmentations augs) throws XNIException

An attribute declaration.

Parameters
elementName:String

The name of the element that this attribute is associated with.

attributeName:String

The name of the attribute.

type:String

The attribute type. This value will be one of the following: "CDATA", "ENTITY", "ENTITIES", "ENUMERATION", "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", or "NOTATION".

enumeration:String[]

If the type has the value "ENUMERATION", this array holds the allowed attribute values; otherwise, this array is null.

defaultType:String

The attribute default type. This value will be one of the following: "#FIXED", "#IMPLIED", "#REQUIRED", or null.

defaultValue:XMLString

The attribute default value, or null if no default value is specified.

nonNormalizedDefaultValue:XMLString

The attribute default value with no normalization performed, or null if no default value is specified.

augs:Augmentations

Additional information that may include infoset augmentations.

Exceptions
XNIException:
Thrown by handler to signal an error.
createAttributeDeclback to summary
protected int createAttributeDecl()
createElementDeclback to summary
protected int createElementDecl()
elementDeclback to summary
public void elementDecl(String name, String contentModel, Augmentations augs) throws XNIException

An element declaration.

Parameters
name:String

The name of the element.

contentModel:String

The element content model.

augs:Augmentations

Additional information that may include infoset augmentations.

Exceptions
XNIException:
Thrown by handler to signal an error.
endDTDback to summary
public void endDTD(Augmentations augs) throws XNIException
ensureAttributeDeclCapacityback to summary
private void ensureAttributeDeclCapacity(int chunk)
ensureElementDeclCapacityback to summary
private void ensureElementDeclCapacity(int chunk)
getAttributeDeclback to summary
public boolean getAttributeDecl(int attributeDeclIndex, XMLAttributeDecl attributeDecl)

getAttributeDecl

Parameters
attributeDecl:XMLAttributeDecl

The values of this structure are set by this call.

Returns:boolean

true if getAttributeDecl was able to fill in the value of attributeDecl

getAttributeDeclIndexback to summary
public int getAttributeDeclIndex(int elementDeclIndex, String attributeDeclName)
getContentSpecTypeback to summary
public short getContentSpecType(int elementIndex)

make separate function for getting contentSpecType of element. we can avoid setting of the element values.

getElementDeclback to summary
public boolean getElementDecl(int elementDeclIndex, XMLElementDecl elementDecl)

getElementDecl

Parameters
elementDecl:XMLElementDecl

The values of this structure are set by this call.

Returns:boolean

True if find the element, False otherwise.

getElementDeclIndexback to summary
public int getElementDeclIndex(String elementDeclName)

getElementDeclIndex

Returns:int

index of the elementDeclName in scope

getElementDeclIndexback to summary
public int getElementDeclIndex(QName elementDeclQName)

Returns the element decl index.

Parameters
elementDeclQName:QName

qualilfied name of the element

getFirstAttributeDeclIndexback to summary
public int getFirstAttributeDeclIndex(int elementDeclIndex)

getFirstAttributeDeclIndex

Returns:int

index of the first attribute for element declaration elementDeclIndex

getFirstElementDeclIndexback to summary
public int getFirstElementDeclIndex()

Returns the index of the first element declaration. This index is then used to query more information about the element declaration.

See Also
getNextElementDeclIndex, getElementDecl
getNextAttributeDeclIndexback to summary
public int getNextAttributeDeclIndex(int attributeDeclIndex)

getNextAttributeDeclIndex

Returns:int

index of the next attribute of the attribute at attributeDeclIndex

getNextElementDeclIndexback to summary
public int getNextElementDeclIndex(int elementDeclIndex)

Returns the next index of the element declaration following the specified element declaration.

Parameters
elementDeclIndex:int

The element declaration index.

getNotationDeclsback to summary
public List<XMLNotationDecl> getNotationDecls()
getSymbolTableback to summary
public SymbolTable getSymbolTable()

Returns the symbol table.

isCDATAAttributeback to summary
public boolean isCDATAAttribute(QName elName, QName atName)

Returns whether the given attribute is of type CDATA or not

Parameters
elName:QName

The element name.

atName:QName

The attribute name.

Returns:boolean

true if the attribute is of type CDATA

normalizeDefaultAttrValueback to summary
private boolean normalizeDefaultAttrValue(XMLString value)

Normalize the attribute value of a non CDATA default attribute collapsing sequences of space characters (x20)

Parameters
value:XMLString

The value to normalize

Returns:boolean

Whether the value was changed or not.

notationDeclback to summary
public void notationDecl(String name, XMLResourceIdentifier identifier, Augmentations augs) throws XNIException
printAttributeback to summary
private void printAttribute(int attributeDeclIndex)
printAttributesback to summary
public void printAttributes(int elementDeclIndex)
printElementsback to summary
public void printElements()
resizeback to summary
private static short[][] resize(short[][] array, int newsize)
resizeback to summary
private static int[][] resize(int[][] array, int newsize)
resizeback to summary
private static QName[][] resize(QName[][] array, int newsize)
resizeback to summary
private static String[][] resize(String[][] array, int newsize)
resizeback to summary
private static String[][][] resize(String[][][] array, int newsize)
setAttributeDeclback to summary
protected void setAttributeDecl(int elementDeclIndex, int attributeDeclIndex, XMLAttributeDecl attributeDecl)
setElementDeclback to summary
protected void setElementDecl(int elementDeclIndex, XMLElementDecl elementDecl)
setFirstAttributeDeclIndexback to summary
protected void setFirstAttributeDeclIndex(int elementDeclIndex, int newFirstAttrIndex)
startDTDback to summary
public void startDTD(XMLLocator locator, Augmentations augs) throws XNIException

The start of the DTD.

Parameters
locator:XMLLocator

The document locator, or null if the document location cannot be reported during the parsing of the document DTD. However, it is strongly recommended that a locator be supplied that can at least report the base system identifier of the DTD.

augs:Augmentations

Additional information that may include infoset augmentations.

Exceptions
XNIException:
Thrown by handler to signal an error.