📄 dtdgrammar.java
字号:
fDepth = 0; initializeContentModelStack(); } // startContentModel(String) /** * A start of either a mixed or children content model. A mixed * content model will immediately be followed by a call to the * <code>pcdata()</code> method. A children content model will * contain additional groups and/or elements. * * @param augs Additional information that may include infoset * augmentations. * @throws XNIException Thrown by handler to signal an error. * * @see #any * @see #empty */ public void startGroup(Augmentations augs) throws XNIException { fDepth++; initializeContentModelStack(); fMixed = false; } // startGroup() /** * The appearance of "#PCDATA" within a group signifying a * mixed content model. This method will be the first called * following the content model's <code>startGroup()</code>. * *@param augs Additional information that may include infoset * augmentations. * * @throws XNIException Thrown by handler to signal an error. * * @see #startGroup */ public void pcdata(Augmentations augs) throws XNIException { fMixed = true; } // pcdata() /** * A referenced element in a mixed or children content model. * * @param elementName The name of the referenced element. * @param augs Additional information that may include infoset * augmentations. * * @throws XNIException Thrown by handler to signal an error. */ public void element(String elementName, Augmentations augs) throws XNIException { if (fMixed) { if (fNodeIndexStack[fDepth] == -1 ) { fNodeIndexStack[fDepth] = addUniqueLeafNode(elementName); } else { fNodeIndexStack[fDepth] = addContentSpecNode(XMLContentSpec.CONTENTSPECNODE_CHOICE, fNodeIndexStack[fDepth], addUniqueLeafNode(elementName)); } } else { fNodeIndexStack[fDepth] = addContentSpecNode(XMLContentSpec.CONTENTSPECNODE_LEAF, elementName); } } // element(String) /** * The separator between choices or sequences of a mixed or children * content model. * * @param separator The type of children separator. * @param augs Additional information that may include infoset * augmentations. * @throws XNIException Thrown by handler to signal an error. * * @see com.sun.org.apache.xerces.internal.xni.XMLDTDContentModelHandler#SEPARATOR_CHOICE * @see com.sun.org.apache.xerces.internal.xni.XMLDTDContentModelHandler#SEPARATOR_SEQUENCE */ public void separator(short separator, Augmentations augs) throws XNIException { if (!fMixed) { if (fOpStack[fDepth] != XMLContentSpec.CONTENTSPECNODE_SEQ && separator == XMLDTDContentModelHandler.SEPARATOR_CHOICE ) { if (fPrevNodeIndexStack[fDepth] != -1) { fNodeIndexStack[fDepth] = addContentSpecNode(fOpStack[fDepth], fPrevNodeIndexStack[fDepth], fNodeIndexStack[fDepth]); } fPrevNodeIndexStack[fDepth] = fNodeIndexStack[fDepth]; fOpStack[fDepth] = XMLContentSpec.CONTENTSPECNODE_CHOICE; } else if (fOpStack[fDepth] != XMLContentSpec.CONTENTSPECNODE_CHOICE && separator == XMLDTDContentModelHandler.SEPARATOR_SEQUENCE) { if (fPrevNodeIndexStack[fDepth] != -1) { fNodeIndexStack[fDepth] = addContentSpecNode(fOpStack[fDepth], fPrevNodeIndexStack[fDepth], fNodeIndexStack[fDepth]); } fPrevNodeIndexStack[fDepth] = fNodeIndexStack[fDepth]; fOpStack[fDepth] = XMLContentSpec.CONTENTSPECNODE_SEQ; } } } // separator(short) /** * The occurrence count for a child in a children content model or * for the mixed content model group. * * @param occurrence The occurrence count for the last element * or group. * @param augs Additional information that may include infoset * augmentations. * @throws XNIException Thrown by handler to signal an error. * * @see com.sun.org.apache.xerces.internal.xni.XMLDTDContentModelHandler#OCCURS_ZERO_OR_ONE * @see com.sun.org.apache.xerces.internal.xni.XMLDTDContentModelHandler#OCCURS_ZERO_OR_MORE * @see com.sun.org.apache.xerces.internal.xni.XMLDTDContentModelHandler#OCCURS_ONE_OR_MORE */ public void occurrence(short occurrence, Augmentations augs) throws XNIException { if (!fMixed) { if (occurrence == XMLDTDContentModelHandler.OCCURS_ZERO_OR_ONE ) { fNodeIndexStack[fDepth] = addContentSpecNode(XMLContentSpec.CONTENTSPECNODE_ZERO_OR_ONE, fNodeIndexStack[fDepth], -1); } else if ( occurrence == XMLDTDContentModelHandler.OCCURS_ZERO_OR_MORE ) { fNodeIndexStack[fDepth] = addContentSpecNode(XMLContentSpec.CONTENTSPECNODE_ZERO_OR_MORE, fNodeIndexStack[fDepth], -1 ); } else if ( occurrence == XMLDTDContentModelHandler.OCCURS_ONE_OR_MORE) { fNodeIndexStack[fDepth] = addContentSpecNode(XMLContentSpec.CONTENTSPECNODE_ONE_OR_MORE, fNodeIndexStack[fDepth], -1 ); } } } // occurrence(short) /** * The end of a group for mixed or children content models. * * @param augs Additional information that may include infoset * augmentations. * @throws XNIException Thrown by handler to signal an error. */ public void endGroup(Augmentations augs) throws XNIException { if (!fMixed) { if (fPrevNodeIndexStack[fDepth] != -1) { fNodeIndexStack[fDepth] = addContentSpecNode(fOpStack[fDepth], fPrevNodeIndexStack[fDepth], fNodeIndexStack[fDepth]); } int nodeIndex = fNodeIndexStack[fDepth--]; fNodeIndexStack[fDepth] = nodeIndex; } } // endGroup() // no-op methods /** * A content model of ANY. * * @param augs Additional information that may include infoset * augmentations. * @throws XNIException Thrown by handler to signal an error. * * @see #empty * @see #startGroup */ public void any(Augmentations augs) throws XNIException {} /** * A content model of EMPTY. * * @param augs Additional information that may include infoset * augmentations. * @throws XNIException Thrown by handler to signal an error. * * @see #any * @see #startGroup */ public void empty(Augmentations augs) throws XNIException {} /** * The end of a content model. * @param augs Additional information that may include infoset * augmentations. * * @throws XNIException Thrown by handler to signal an error. */ public void endContentModel(Augmentations augs) throws XNIException {} // // Grammar methods // /** Returns true if this grammar is namespace aware. */ public boolean isNamespaceAware() { return false; } // isNamespaceAware():boolean /** Returns the symbol table. */ public SymbolTable getSymbolTable() { return fSymbolTable; } // getSymbolTable():SymbolTable /** * Returns the index of the first element declaration. This index * is then used to query more information about the element declaration. * * @see #getNextElementDeclIndex * @see #getElementDecl */ public int getFirstElementDeclIndex() { return fElementDeclCount >= 0 ? 0 : -1; } // getFirstElementDeclIndex():int /** * Returns the next index of the element declaration following the * specified element declaration. * * @param elementDeclIndex The element declaration index. */ public int getNextElementDeclIndex(int elementDeclIndex) { return elementDeclIndex < fElementDeclCount - 1 ? elementDeclIndex + 1 : -1; } // getNextElementDeclIndex(int):int /** * getElementDeclIndex * * @param elementDeclName * * @return index of the elementDeclName in scope */ public int getElementDeclIndex(String elementDeclName) { int mapping = fElementIndexMap.get(elementDeclName); //System.out.println("getElementDeclIndex("+elementDeclName+") -> "+mapping); return mapping; } // getElementDeclIndex(String):int /** Returns the element decl index. * @param elementDeclQName qualilfied name of the element */ public int getElementDeclIndex(QName elementDeclQName) { return getElementDeclIndex(elementDeclQName.rawname); } // getElementDeclIndex(QName):int /** make separate function for getting contentSpecType of element. * we can avoid setting of the element values. */ public short getContentSpecType(int elementIndex){ if (elementIndex < 0 || elementIndex >= fElementDeclCount) { return -1 ; } int chunk = elementIndex >> CHUNK_SHIFT; int index = elementIndex & CHUNK_MASK; if(fElementDeclType[chunk][index] == -1){ return -1 ; } else{ return (short) (fElementDeclType[chunk][index] & LIST_MASK); } }//getContentSpecType /** * getElementDecl * * @param elementDeclIndex * @param elementDecl The values of this structure are set by this call. * * @return True if find the element, False otherwise. */ public boolean getElementDecl(int elementDeclIndex, XMLElementDecl elementDecl) { if (elementDeclIndex < 0 || elementDeclIndex >= fElementDeclCount) { return false; } int chunk = elementDeclIndex >> CHUNK_SHIFT; int index = elementDeclIndex & CHUNK_MASK; elementDecl.name.setValues(fElementDeclName[chunk][index]); if (fElementDeclType[chunk][index] == -1) { elementDecl.type = -1; elementDecl.simpleType.list = false; } else { elementDecl.type = (short) (fElementDeclType[chunk][index] & LIST_MASK); elementDecl.simpleType.list = (fElementDeclType[chunk][index] & LIST_FLAG) != 0; } /* Validators are null until we add that code */ if (elementDecl.type == XMLElementDecl.TYPE_CHILDREN || elementDecl.type == XMLElementDecl.TYPE_MIXED) { elementDecl.contentModelValidator = getElementContentModelValidator(elementDeclIndex); } elementDecl.simpleType.datatypeValidator = null; elementDecl.simpleType.defaultType = -1; elementDecl.simpleType.defaultValue = null; return true; } // getElementDecl(int,XMLElementDecl):boolean // REVISIT: Make this getAttributeDeclCount/getAttributeDeclAt. -Ac /** * getFirstAttributeDeclIndex * * @param elementDeclIndex * * @return index of the first attribute for element declaration elementDeclIndex */ public int getFirstAttributeDeclIndex(int elementDeclIndex) { int chunk = elementDeclIndex >> CHUNK_SHIFT; int index = elementDeclIndex & CHUNK_MASK; return fElementDeclFirstAttributeDeclIndex[chunk][index]; } // getFirstAttributeDeclIndex /** * getNextAttributeDeclIndex * * @param attributeDeclIndex * * @return index of the next attribute of the attribute at attributeDeclIndex */ public int getNextAttributeDeclIndex(int attributeDeclIndex) { int chunk = attributeDeclIndex >> CHUNK_SHIFT; int index = attributeDeclIndex & CHUNK_MASK; return fAttributeDeclNextAttributeDeclIndex[chunk][index]; } // getNextAttributeDeclIndex /** * getAttributeDecl * * @param attributeDeclIndex * @param attributeDecl The values of this structure are set by this call. * * @return true if getAttributeDecl was able to fill in the value of attributeDecl */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -