feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
498
jdkSrc/jdk8/com/sun/xml/internal/stream/dtd/DTDGrammarUtil.java
Normal file
498
jdkSrc/jdk8/com/sun/xml/internal/stream/dtd/DTDGrammarUtil.java
Normal file
@@ -0,0 +1,498 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.dtd;
|
||||
import com.sun.xml.internal.stream.dtd.nonvalidating.DTDGrammar;
|
||||
import com.sun.xml.internal.stream.dtd.nonvalidating.XMLAttributeDecl;
|
||||
import com.sun.xml.internal.stream.dtd.nonvalidating.XMLElementDecl;
|
||||
import com.sun.xml.internal.stream.dtd.nonvalidating.XMLSimpleType;
|
||||
import com.sun.org.apache.xerces.internal.impl.Constants;
|
||||
import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
|
||||
import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
|
||||
import com.sun.org.apache.xerces.internal.util.SymbolTable;
|
||||
import com.sun.org.apache.xerces.internal.util.XMLChar;
|
||||
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
|
||||
import com.sun.org.apache.xerces.internal.xni.Augmentations;
|
||||
import com.sun.org.apache.xerces.internal.xni.QName;
|
||||
import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
|
||||
import com.sun.org.apache.xerces.internal.xni.XMLAttributes;
|
||||
import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
|
||||
import com.sun.org.apache.xerces.internal.xni.XMLLocator;
|
||||
import com.sun.org.apache.xerces.internal.xni.XMLString;
|
||||
import com.sun.org.apache.xerces.internal.xni.XNIException;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;
|
||||
import javax.xml.XMLConstants;
|
||||
|
||||
/*
|
||||
* @author Eric Ye, IBM
|
||||
* @author Andy Clark, IBM
|
||||
* @author Jeffrey Rodriguez IBM
|
||||
* @author Neil Graham, IBM
|
||||
* @author Sunitha Reddy, Sun Microsystems
|
||||
*/
|
||||
|
||||
public class DTDGrammarUtil {
|
||||
|
||||
|
||||
/** Property identifier: symbol table. */
|
||||
protected static final String SYMBOL_TABLE =
|
||||
Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
|
||||
|
||||
protected static final String NAMESPACES =
|
||||
Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;
|
||||
|
||||
|
||||
/** Compile to true to debug attributes. */
|
||||
private static final boolean DEBUG_ATTRIBUTES = false;
|
||||
|
||||
/** Compile to true to debug element children. */
|
||||
private static final boolean DEBUG_ELEMENT_CHILDREN = false;
|
||||
|
||||
protected DTDGrammar fDTDGrammar = null;
|
||||
/** Namespaces. */
|
||||
protected boolean fNamespaces;
|
||||
|
||||
/** Symbol table. */
|
||||
protected SymbolTable fSymbolTable = null;
|
||||
|
||||
/** Current element index. */
|
||||
private int fCurrentElementIndex = -1;
|
||||
|
||||
/** Current content spec type. */
|
||||
private int fCurrentContentSpecType = -1;
|
||||
|
||||
/** Content spec type stack. */
|
||||
private boolean[] fElementContentState = new boolean[8];
|
||||
|
||||
/** Element depth. */
|
||||
private int fElementDepth = -1;
|
||||
|
||||
/** True if inside of element content. */
|
||||
private boolean fInElementContent = false;
|
||||
|
||||
/** Temporary atribute declaration. */
|
||||
private XMLAttributeDecl fTempAttDecl = new XMLAttributeDecl();
|
||||
|
||||
/** Temporary qualified name. */
|
||||
private QName fTempQName = new QName();
|
||||
|
||||
/** Temporary string buffers. */
|
||||
private StringBuffer fBuffer = new StringBuffer();
|
||||
|
||||
private NamespaceContext fNamespaceContext = null;
|
||||
|
||||
/** Default constructor. */
|
||||
public DTDGrammarUtil(SymbolTable symbolTable) {
|
||||
fSymbolTable = symbolTable;
|
||||
}
|
||||
|
||||
public DTDGrammarUtil(DTDGrammar grammar, SymbolTable symbolTable) {
|
||||
fDTDGrammar = grammar;
|
||||
fSymbolTable = symbolTable;
|
||||
}
|
||||
|
||||
public DTDGrammarUtil(DTDGrammar grammar, SymbolTable symbolTable,
|
||||
NamespaceContext namespaceContext) {
|
||||
fDTDGrammar = grammar;
|
||||
fSymbolTable = symbolTable;
|
||||
fNamespaceContext = namespaceContext;
|
||||
}
|
||||
|
||||
/*
|
||||
* Resets the component. The component can query the component manager
|
||||
* about any features and properties that affect the operation of the
|
||||
* component.
|
||||
*
|
||||
* @param componentManager The component manager.
|
||||
*
|
||||
* @throws SAXException Thrown by component on finitialization error.
|
||||
* For example, if a feature or property is
|
||||
* required for the operation of the component, the
|
||||
* component manager may throw a
|
||||
* SAXNotRecognizedException or a
|
||||
* SAXNotSupportedException.
|
||||
*/
|
||||
public void reset(XMLComponentManager componentManager)
|
||||
throws XMLConfigurationException {
|
||||
|
||||
fDTDGrammar = null;
|
||||
fInElementContent = false;
|
||||
fCurrentElementIndex = -1;
|
||||
fCurrentContentSpecType = -1;
|
||||
fNamespaces = componentManager.getFeature(NAMESPACES, true);
|
||||
fSymbolTable = (SymbolTable) componentManager.getProperty(
|
||||
Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY);
|
||||
fElementDepth = -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The start of an element.
|
||||
*
|
||||
* @param element The name of the element.
|
||||
* @param attributes The element attributes.
|
||||
* @param augs Additional information that may include infoset augmentations
|
||||
*
|
||||
* @throws XNIException Thrown by handler to signal an error.
|
||||
*/
|
||||
public void startElement(QName element, XMLAttributes attributes) throws XNIException {
|
||||
handleStartElement(element, attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* The end of an element.
|
||||
*
|
||||
* @param element The name of the element.
|
||||
* @param augs Additional information that may include infoset augmentations
|
||||
*
|
||||
* @throws XNIException Thrown by handler to signal an error.
|
||||
*/
|
||||
public void endElement(QName element) throws XNIException {
|
||||
handleEndElement(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* The start of a CDATA section.
|
||||
* @param augs Additional information that may include infoset augmentations
|
||||
*
|
||||
* @throws XNIException Thrown by handler to signal an error.
|
||||
*/
|
||||
public void startCDATA(Augmentations augs) throws XNIException {
|
||||
}
|
||||
|
||||
/**
|
||||
* The end of a CDATA section.
|
||||
* @param augs Additional information that may include infoset augmentations
|
||||
*
|
||||
* @throws XNIException Thrown by handler to signal an error.
|
||||
*/
|
||||
public void endCDATA(Augmentations augs) throws XNIException {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Add default attributes and validate. */
|
||||
public void addDTDDefaultAttrs(QName elementName, XMLAttributes attributes)
|
||||
throws XNIException {
|
||||
|
||||
int elementIndex;
|
||||
elementIndex = fDTDGrammar.getElementDeclIndex(elementName);
|
||||
// is there anything to do?
|
||||
if (elementIndex == -1 || fDTDGrammar == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Check after all specified attrs are scanned
|
||||
// (1) report error for REQUIRED attrs that are missing (V_TAGc)
|
||||
// (2) add default attrs (FIXED and NOT_FIXED)
|
||||
//
|
||||
int attlistIndex = fDTDGrammar.getFirstAttributeDeclIndex(elementIndex);
|
||||
|
||||
while (attlistIndex != -1) {
|
||||
|
||||
fDTDGrammar.getAttributeDecl(attlistIndex, fTempAttDecl);
|
||||
|
||||
if (DEBUG_ATTRIBUTES) {
|
||||
if (fTempAttDecl != null) {
|
||||
XMLElementDecl elementDecl = new XMLElementDecl();
|
||||
fDTDGrammar.getElementDecl(elementIndex, elementDecl);
|
||||
System.out.println("element: " + (elementDecl.name.localpart));
|
||||
System.out.println("attlistIndex " + attlistIndex + "\n" +
|
||||
"attName : '" + (fTempAttDecl.name.localpart) + "'\n"
|
||||
+ "attType : " + fTempAttDecl.simpleType.type + "\n"
|
||||
+ "attDefaultType : " + fTempAttDecl.simpleType.defaultType + "\n"
|
||||
+ "attDefaultValue : '" + fTempAttDecl.simpleType.defaultValue + "'\n"
|
||||
+ attributes.getLength() + "\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
String attPrefix = fTempAttDecl.name.prefix;
|
||||
String attLocalpart = fTempAttDecl.name.localpart;
|
||||
String attRawName = fTempAttDecl.name.rawname;
|
||||
String attType = getAttributeTypeName(fTempAttDecl);
|
||||
int attDefaultType = fTempAttDecl.simpleType.defaultType;
|
||||
String attValue = null;
|
||||
|
||||
if (fTempAttDecl.simpleType.defaultValue != null) {
|
||||
attValue = fTempAttDecl.simpleType.defaultValue;
|
||||
}
|
||||
boolean specified = false;
|
||||
boolean required = attDefaultType == XMLSimpleType.DEFAULT_TYPE_REQUIRED;
|
||||
boolean cdata = attType == XMLSymbols.fCDATASymbol;
|
||||
|
||||
if (!cdata || required || attValue != null) {
|
||||
|
||||
//check whether attribute is a namespace declaration
|
||||
if (fNamespaceContext != null && attRawName.startsWith(XMLConstants.XMLNS_ATTRIBUTE)) {
|
||||
String prefix = "";
|
||||
int pos = attRawName.indexOf(':');
|
||||
if (pos != -1) {
|
||||
prefix = attRawName.substring(0, pos);
|
||||
} else {
|
||||
prefix = attRawName;
|
||||
}
|
||||
prefix = fSymbolTable.addSymbol(prefix);
|
||||
if (!((com.sun.org.apache.xerces.internal.util.
|
||||
NamespaceSupport) fNamespaceContext).
|
||||
containsPrefixInCurrentContext(prefix)) {
|
||||
fNamespaceContext.declarePrefix(prefix, attValue);
|
||||
}
|
||||
specified = true;
|
||||
} else {
|
||||
|
||||
int attrCount = attributes.getLength();
|
||||
for (int i = 0; i < attrCount; i++) {
|
||||
if (attributes.getQName(i) == attRawName) {
|
||||
specified = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!specified) {
|
||||
if (attValue != null) {
|
||||
if (fNamespaces) {
|
||||
int index = attRawName.indexOf(':');
|
||||
if (index != -1) {
|
||||
attPrefix = attRawName.substring(0, index);
|
||||
attPrefix = fSymbolTable.addSymbol(attPrefix);
|
||||
attLocalpart = attRawName.substring(index + 1);
|
||||
attLocalpart = fSymbolTable.addSymbol(attLocalpart);
|
||||
}
|
||||
}
|
||||
fTempQName.setValues(attPrefix, attLocalpart, attRawName,
|
||||
fTempAttDecl.name.uri);
|
||||
int newAttr = attributes.addAttribute(fTempQName, attType,
|
||||
attValue);
|
||||
}
|
||||
}
|
||||
attlistIndex = fDTDGrammar.getNextAttributeDeclIndex(attlistIndex);
|
||||
}
|
||||
|
||||
// now iterate through the expanded attributes for
|
||||
// 1. if every attribute seen is declared in the DTD
|
||||
// 2. check if the VC: default_fixed holds
|
||||
// 3. validate every attribute.
|
||||
int attrCount = attributes.getLength();
|
||||
for (int i = 0; i < attrCount; i++) {
|
||||
String attrRawName = attributes.getQName(i);
|
||||
boolean declared = false;
|
||||
int position =
|
||||
fDTDGrammar.getFirstAttributeDeclIndex(elementIndex);
|
||||
while (position != -1) {
|
||||
fDTDGrammar.getAttributeDecl(position, fTempAttDecl);
|
||||
if (fTempAttDecl.name.rawname == attrRawName) {
|
||||
// found the match att decl,
|
||||
declared = true;
|
||||
break;
|
||||
}
|
||||
position = fDTDGrammar.getNextAttributeDeclIndex(position);
|
||||
}
|
||||
if (!declared) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String type = getAttributeTypeName(fTempAttDecl);
|
||||
attributes.setType(i, type);
|
||||
|
||||
boolean changedByNormalization = false;
|
||||
if (attributes.isSpecified(i) && type != XMLSymbols.fCDATASymbol) {
|
||||
changedByNormalization = normalizeAttrValue(attributes, i);
|
||||
}
|
||||
} // for all attributes
|
||||
|
||||
} // addDTDDefaultAttrsAndValidate(int,XMLAttrList)
|
||||
|
||||
|
||||
/**
|
||||
* Normalize the attribute value of a non CDATA attributes collapsing
|
||||
* sequences of space characters (x20)
|
||||
*
|
||||
* @param attributes The list of attributes
|
||||
* @param index The index of the attribute to normalize
|
||||
*/
|
||||
private boolean normalizeAttrValue(XMLAttributes attributes, int index) {
|
||||
// vars
|
||||
boolean leadingSpace = true;
|
||||
boolean spaceStart = false;
|
||||
boolean readingNonSpace = false;
|
||||
int count = 0;
|
||||
int eaten = 0;
|
||||
String attrValue = attributes.getValue(index);
|
||||
char[] attValue = new char[attrValue.length()];
|
||||
|
||||
fBuffer.setLength(0);
|
||||
attrValue.getChars(0, attrValue.length(), attValue, 0);
|
||||
for (int i = 0; i < attValue.length; i++) {
|
||||
|
||||
if (attValue[i] == ' ') {
|
||||
|
||||
// now the tricky part
|
||||
if (readingNonSpace) {
|
||||
spaceStart = true;
|
||||
readingNonSpace = false;
|
||||
}
|
||||
|
||||
if (spaceStart && !leadingSpace) {
|
||||
spaceStart = false;
|
||||
fBuffer.append(attValue[i]);
|
||||
count++;
|
||||
} else {
|
||||
if (leadingSpace || !spaceStart) {
|
||||
eaten++;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
readingNonSpace = true;
|
||||
spaceStart = false;
|
||||
leadingSpace = false;
|
||||
fBuffer.append(attValue[i]);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
// check if the last appended character is a space.
|
||||
if (count > 0 && fBuffer.charAt(count - 1) == ' ') {
|
||||
fBuffer.setLength(count - 1);
|
||||
|
||||
}
|
||||
String newValue = fBuffer.toString();
|
||||
attributes.setValue(index, newValue);
|
||||
return !attrValue.equals(newValue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** convert attribute type from ints to strings */
|
||||
private String getAttributeTypeName(XMLAttributeDecl attrDecl) {
|
||||
|
||||
switch (attrDecl.simpleType.type) {
|
||||
case XMLSimpleType.TYPE_ENTITY: {
|
||||
return attrDecl.simpleType.list ? XMLSymbols.fENTITIESSymbol :
|
||||
XMLSymbols.fENTITYSymbol;
|
||||
}
|
||||
case XMLSimpleType.TYPE_ENUMERATION: {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append('(');
|
||||
for (int i = 0; i < attrDecl.simpleType.enumeration.length; i++) {
|
||||
if (i > 0) {
|
||||
buffer.append("|");
|
||||
}
|
||||
buffer.append(attrDecl.simpleType.enumeration[i]);
|
||||
}
|
||||
buffer.append(')');
|
||||
return fSymbolTable.addSymbol(buffer.toString());
|
||||
}
|
||||
case XMLSimpleType.TYPE_ID: {
|
||||
return XMLSymbols.fIDSymbol;
|
||||
}
|
||||
case XMLSimpleType.TYPE_IDREF: {
|
||||
return attrDecl.simpleType.list ? XMLSymbols.fIDREFSSymbol :
|
||||
XMLSymbols.fIDREFSymbol;
|
||||
}
|
||||
case XMLSimpleType.TYPE_NMTOKEN: {
|
||||
return attrDecl.simpleType.list ? XMLSymbols.fNMTOKENSSymbol :
|
||||
XMLSymbols.fNMTOKENSymbol;
|
||||
}
|
||||
case XMLSimpleType.TYPE_NOTATION: {
|
||||
return XMLSymbols.fNOTATIONSymbol;
|
||||
}
|
||||
}
|
||||
return XMLSymbols.fCDATASymbol;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** ensure element stack capacity */
|
||||
private void ensureStackCapacity(int newElementDepth) {
|
||||
if (newElementDepth == fElementContentState.length) {
|
||||
boolean[] newStack = new boolean[newElementDepth * 2];
|
||||
System.arraycopy(this.fElementContentState, 0, newStack, 0,
|
||||
newElementDepth);
|
||||
fElementContentState = newStack;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Handle element
|
||||
* @return true if validator is removed from the pipeline
|
||||
*/
|
||||
protected void handleStartElement(QName element, XMLAttributes attributes) throws XNIException {
|
||||
|
||||
if (fDTDGrammar == null) {
|
||||
fCurrentElementIndex = -1;
|
||||
fCurrentContentSpecType = -1;
|
||||
fInElementContent = false;
|
||||
return;
|
||||
} else {
|
||||
fCurrentElementIndex = fDTDGrammar.getElementDeclIndex(element);
|
||||
fCurrentContentSpecType = fDTDGrammar.getContentSpecType(
|
||||
fCurrentElementIndex);
|
||||
//handleDTDDefaultAttrs(element,attributes);
|
||||
addDTDDefaultAttrs(element, attributes);
|
||||
}
|
||||
|
||||
fInElementContent = fCurrentContentSpecType == XMLElementDecl.TYPE_CHILDREN;
|
||||
fElementDepth++;
|
||||
ensureStackCapacity(fElementDepth);
|
||||
fElementContentState[fElementDepth] = fInElementContent;
|
||||
}
|
||||
|
||||
|
||||
/** Handle end element. */
|
||||
protected void handleEndElement(QName element) throws XNIException {
|
||||
if (fDTDGrammar == null) return;
|
||||
fElementDepth--;
|
||||
if (fElementDepth < -1) {
|
||||
throw new RuntimeException("FWK008 Element stack underflow");
|
||||
}
|
||||
if (fElementDepth < 0) {
|
||||
fCurrentElementIndex = -1;
|
||||
fCurrentContentSpecType = -1;
|
||||
fInElementContent = false;
|
||||
return;
|
||||
}
|
||||
fInElementContent = fElementContentState[fElementDepth];
|
||||
}
|
||||
|
||||
public boolean isInElementContent() {
|
||||
return fInElementContent;
|
||||
}
|
||||
|
||||
public boolean isIgnorableWhiteSpace(XMLString text) {
|
||||
if (isInElementContent()) {
|
||||
for (int i = text.offset; i < text.offset + text.length; i++) {
|
||||
if (!XMLChar.isSpace(text.ch[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,878 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.dtd.nonvalidating;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.util.SymbolTable;
|
||||
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
|
||||
import com.sun.org.apache.xerces.internal.xni.Augmentations;
|
||||
import com.sun.org.apache.xerces.internal.xni.QName;
|
||||
import com.sun.org.apache.xerces.internal.xni.XMLLocator;
|
||||
import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
|
||||
import com.sun.org.apache.xerces.internal.xni.XMLString;
|
||||
import com.sun.org.apache.xerces.internal.xni.XNIException;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDContentModelSource;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A DTD grammar. This class implements the XNI handler interfaces
|
||||
* for DTD information so that it can build the approprate validation
|
||||
* structures automatically from the callbacks.
|
||||
*
|
||||
* @author Eric Ye, IBM
|
||||
* @author Jeffrey Rodriguez, IBM
|
||||
* @author Andy Clark, IBM
|
||||
* @author Neil Graham, IBM
|
||||
*
|
||||
*/
|
||||
public class DTDGrammar {
|
||||
|
||||
|
||||
/** Top level scope (-1). */
|
||||
public static final int TOP_LEVEL_SCOPE = -1;
|
||||
|
||||
// private
|
||||
|
||||
/** Chunk shift (8). */
|
||||
private static final int CHUNK_SHIFT = 8; // 2^8 = 256
|
||||
|
||||
/** Chunk size (1 << CHUNK_SHIFT). */
|
||||
private static final int CHUNK_SIZE = (1 << CHUNK_SHIFT);
|
||||
|
||||
/** Chunk mask (CHUNK_SIZE - 1). */
|
||||
private static final int CHUNK_MASK = CHUNK_SIZE - 1;
|
||||
|
||||
/** Initial chunk count (1 << (10 - CHUNK_SHIFT)). */
|
||||
private static final int INITIAL_CHUNK_COUNT = (1 << (10 - CHUNK_SHIFT)); // 2^10 = 1k
|
||||
|
||||
/** List flag (0x80). */
|
||||
private static final short LIST_FLAG = 0x80;
|
||||
|
||||
/** List mask (~LIST_FLAG). */
|
||||
private static final short LIST_MASK = ~LIST_FLAG;
|
||||
|
||||
// debugging
|
||||
|
||||
/** Debug DTDGrammar. */
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
//
|
||||
// Data
|
||||
//
|
||||
|
||||
protected XMLDTDSource fDTDSource = null;
|
||||
protected XMLDTDContentModelSource fDTDContentModelSource = null;
|
||||
|
||||
/** Current element index. */
|
||||
protected int fCurrentElementIndex;
|
||||
|
||||
/** Current attribute index. */
|
||||
protected int fCurrentAttributeIndex;
|
||||
|
||||
/** fReadingExternalDTD */
|
||||
protected boolean fReadingExternalDTD = false;
|
||||
|
||||
/** Symbol table. */
|
||||
private SymbolTable fSymbolTable;
|
||||
private ArrayList notationDecls = new ArrayList();
|
||||
|
||||
// element declarations
|
||||
|
||||
/** Number of element declarations. */
|
||||
private int fElementDeclCount = 0;
|
||||
|
||||
/** Element declaration name. */
|
||||
private QName fElementDeclName[][] = new QName[INITIAL_CHUNK_COUNT][];
|
||||
|
||||
/**
|
||||
* Element declaration type.
|
||||
* @see XMLElementDecl
|
||||
*/
|
||||
private short fElementDeclType[][] = new short[INITIAL_CHUNK_COUNT][];
|
||||
|
||||
|
||||
/** First attribute declaration of an element declaration. */
|
||||
private int fElementDeclFirstAttributeDeclIndex[][] = new int[INITIAL_CHUNK_COUNT][];
|
||||
|
||||
/** Last attribute declaration of an element declaration. */
|
||||
private int fElementDeclLastAttributeDeclIndex[][] = new int[INITIAL_CHUNK_COUNT][];
|
||||
|
||||
// attribute declarations
|
||||
|
||||
/** Number of attribute declarations. */
|
||||
private int fAttributeDeclCount = 0 ;
|
||||
|
||||
/** Attribute declaration name. */
|
||||
private QName fAttributeDeclName[][] = new QName[INITIAL_CHUNK_COUNT][];
|
||||
|
||||
/**
|
||||
* Attribute declaration type.
|
||||
* @see XMLAttributeDecl
|
||||
*/
|
||||
private short fAttributeDeclType[][] = new short[INITIAL_CHUNK_COUNT][];
|
||||
|
||||
/** Attribute declaration enumeration values. */
|
||||
private String[] fAttributeDeclEnumeration[][] = new String[INITIAL_CHUNK_COUNT][][];
|
||||
private short fAttributeDeclDefaultType[][] = new short[INITIAL_CHUNK_COUNT][];
|
||||
private String fAttributeDeclDefaultValue[][] = new String[INITIAL_CHUNK_COUNT][];
|
||||
private String fAttributeDeclNonNormalizedDefaultValue[][] = new String[INITIAL_CHUNK_COUNT][];
|
||||
private int fAttributeDeclNextAttributeDeclIndex[][] = new int[INITIAL_CHUNK_COUNT][];
|
||||
|
||||
/** Element index mapping table. */
|
||||
private final Map<String, Integer> fElementIndexMap = new HashMap<>();
|
||||
|
||||
/** Temporary qualified name. */
|
||||
private final QName fQName = new QName();
|
||||
|
||||
/** Temporary Attribute decl. */
|
||||
protected XMLAttributeDecl fAttributeDecl = new XMLAttributeDecl();
|
||||
|
||||
/** Element declaration. */
|
||||
private XMLElementDecl fElementDecl = new XMLElementDecl();
|
||||
|
||||
/** Simple type. */
|
||||
private XMLSimpleType fSimpleType = new XMLSimpleType();
|
||||
|
||||
|
||||
/** table of XMLElementDecl */
|
||||
Map<String, XMLElementDecl> fElementDeclTab = new HashMap<>();
|
||||
|
||||
/** Default constructor. */
|
||||
public DTDGrammar(SymbolTable symbolTable) {
|
||||
fSymbolTable = symbolTable;
|
||||
}
|
||||
|
||||
public int getAttributeDeclIndex(int elementDeclIndex, String attributeDeclName) {
|
||||
if (elementDeclIndex == -1) {
|
||||
return -1;
|
||||
}
|
||||
int attDefIndex = getFirstAttributeDeclIndex(elementDeclIndex);
|
||||
while (attDefIndex != -1) {
|
||||
getAttributeDecl(attDefIndex, fAttributeDecl);
|
||||
|
||||
if (fAttributeDecl.name.rawname == attributeDeclName
|
||||
|| attributeDeclName.equals(fAttributeDecl.name.rawname) ) {
|
||||
return attDefIndex;
|
||||
}
|
||||
attDefIndex = getNextAttributeDeclIndex(attDefIndex);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* The start of the DTD.
|
||||
*
|
||||
* @param locator The document locator, or null if the document
|
||||
* location cannot be reported during the parsing of
|
||||
* the document DTD. However, it is <em>strongly</em>
|
||||
* recommended that a locator be supplied that can
|
||||
* at least report the base system identifier of the
|
||||
* DTD.
|
||||
*
|
||||
* @param augs Additional information that may include infoset
|
||||
* augmentations.
|
||||
* @throws XNIException Thrown by handler to signal an error.
|
||||
*/
|
||||
public void startDTD(XMLLocator locator, Augmentations augs) throws XNIException {
|
||||
} // startDTD(XMLLocator)
|
||||
|
||||
// startExternalSubset(Augmentations)
|
||||
|
||||
// endExternalSubset(Augmentations)
|
||||
|
||||
/**
|
||||
* An element declaration.
|
||||
*
|
||||
* @param name The name of the element.
|
||||
* @param contentModel The element content model.
|
||||
* @param augs Additional information that may include infoset
|
||||
* augmentations.
|
||||
* @throws XNIException Thrown by handler to signal an error.
|
||||
*/
|
||||
public void elementDecl(String name, String contentModel, Augmentations augs)
|
||||
throws XNIException {
|
||||
|
||||
XMLElementDecl tmpElementDecl = fElementDeclTab.get(name) ;
|
||||
if ( tmpElementDecl != null ) {
|
||||
if (tmpElementDecl.type == -1) {
|
||||
fCurrentElementIndex = getElementDeclIndex(name);
|
||||
}
|
||||
else {
|
||||
// duplicate element, ignored.
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fCurrentElementIndex = createElementDecl();//create element decl
|
||||
}
|
||||
|
||||
XMLElementDecl elementDecl = new XMLElementDecl();
|
||||
QName elementName = new QName(null, name, name, null);
|
||||
|
||||
elementDecl.name.setValues(elementName);
|
||||
elementDecl.scope= -1;
|
||||
if (contentModel.equals("EMPTY")) {
|
||||
elementDecl.type = XMLElementDecl.TYPE_EMPTY;
|
||||
}
|
||||
else if (contentModel.equals("ANY")) {
|
||||
elementDecl.type = XMLElementDecl.TYPE_ANY;
|
||||
}
|
||||
else if (contentModel.startsWith("(") ) {
|
||||
if (contentModel.indexOf("#PCDATA") > 0 ) {
|
||||
elementDecl.type = XMLElementDecl.TYPE_MIXED;
|
||||
}
|
||||
else {
|
||||
elementDecl.type = XMLElementDecl.TYPE_CHILDREN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//add(or set) this elementDecl to the local cache
|
||||
this.fElementDeclTab.put(name, elementDecl );
|
||||
|
||||
fElementDecl = elementDecl;
|
||||
|
||||
|
||||
if ( DEBUG ) {
|
||||
System.out.println( "name = " + fElementDecl.name.localpart );
|
||||
System.out.println( "Type = " + fElementDecl.type );
|
||||
}
|
||||
|
||||
setElementDecl(fCurrentElementIndex, fElementDecl );//set internal structure
|
||||
|
||||
int chunk = fCurrentElementIndex >> CHUNK_SHIFT;
|
||||
ensureElementDeclCapacity(chunk);
|
||||
}
|
||||
|
||||
/**
|
||||
* An attribute declaration.
|
||||
*
|
||||
* @param elementName The name of the element that this attribute
|
||||
* is associated with.
|
||||
* @param attributeName The name of the attribute.
|
||||
* @param type The attribute type. This value will be one of
|
||||
* the following: "CDATA", "ENTITY", "ENTITIES",
|
||||
* "ENUMERATION", "ID", "IDREF", "IDREFS",
|
||||
* "NMTOKEN", "NMTOKENS", or "NOTATION".
|
||||
* @param enumeration If the type has the value "ENUMERATION", this
|
||||
* array holds the allowed attribute values;
|
||||
* otherwise, this array is null.
|
||||
* @param defaultType The attribute default type. This value will be
|
||||
* one of the following: "#FIXED", "#IMPLIED",
|
||||
* "#REQUIRED", or null.
|
||||
* @param defaultValue The attribute default value, or null if no
|
||||
* default value is specified.
|
||||
* @param nonNormalizedDefaultValue The attribute default value with no normalization
|
||||
* performed, or null if no default value is specified.
|
||||
*
|
||||
* @param augs Additional information that may include infoset
|
||||
* augmentations.
|
||||
* @throws XNIException Thrown by handler to signal an error.
|
||||
*/
|
||||
public void attributeDecl(String elementName, String attributeName,
|
||||
String type, String[] enumeration,
|
||||
String defaultType, XMLString defaultValue,
|
||||
XMLString nonNormalizedDefaultValue, Augmentations augs) throws XNIException {
|
||||
|
||||
if (type != XMLSymbols.fCDATASymbol && defaultValue != null) {
|
||||
normalizeDefaultAttrValue(defaultValue);
|
||||
}
|
||||
|
||||
if ( this.fElementDeclTab.containsKey(elementName)) {
|
||||
//if ElementDecl has already being created in the Grammar then remove from table,
|
||||
//this.fElementDeclTab.remove( (String) elementName );
|
||||
}
|
||||
// then it is forward reference to a element decl, create the elementDecl first.
|
||||
else {
|
||||
fCurrentElementIndex = createElementDecl();//create element decl
|
||||
|
||||
XMLElementDecl elementDecl = new XMLElementDecl();
|
||||
elementDecl.name.setValues(null, elementName, elementName, null);
|
||||
|
||||
elementDecl.scope= -1;
|
||||
|
||||
//add(or set) this elementDecl to the local cache
|
||||
this.fElementDeclTab.put(elementName, elementDecl );
|
||||
|
||||
//set internal structure
|
||||
setElementDecl(fCurrentElementIndex, elementDecl );
|
||||
}
|
||||
|
||||
//Get Grammar index to grammar array
|
||||
int elementIndex = getElementDeclIndex(elementName);
|
||||
|
||||
//return, when more than one definition is provided for the same attribute of given element type
|
||||
//only the first declaration is binding and later declarations are ignored
|
||||
if (getAttributeDeclIndex(elementIndex, attributeName) != -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
fCurrentAttributeIndex = createAttributeDecl();// Create current Attribute Decl
|
||||
|
||||
fSimpleType.clear();
|
||||
if ( defaultType != null ) {
|
||||
if ( defaultType.equals( "#FIXED") ) {
|
||||
fSimpleType.defaultType = fSimpleType.DEFAULT_TYPE_FIXED;
|
||||
} else if ( defaultType.equals( "#IMPLIED") ) {
|
||||
fSimpleType.defaultType = fSimpleType.DEFAULT_TYPE_IMPLIED;
|
||||
} else if ( defaultType.equals( "#REQUIRED") ) {
|
||||
fSimpleType.defaultType = fSimpleType.DEFAULT_TYPE_REQUIRED;
|
||||
}
|
||||
}
|
||||
if ( DEBUG ) {
|
||||
System.out.println("defaultvalue = " + defaultValue.toString() );
|
||||
}
|
||||
fSimpleType.defaultValue = defaultValue!=null ? defaultValue.toString() : null;
|
||||
fSimpleType.nonNormalizedDefaultValue = nonNormalizedDefaultValue!=null ? nonNormalizedDefaultValue.toString() : null;
|
||||
fSimpleType.enumeration = enumeration;
|
||||
|
||||
if (type.equals("CDATA")) {
|
||||
fSimpleType.type = XMLSimpleType.TYPE_CDATA;
|
||||
}
|
||||
else if ( type.equals("ID") ) {
|
||||
fSimpleType.type = XMLSimpleType.TYPE_ID;
|
||||
}
|
||||
else if ( type.startsWith("IDREF") ) {
|
||||
fSimpleType.type = XMLSimpleType.TYPE_IDREF;
|
||||
if (type.indexOf("S") > 0) {
|
||||
fSimpleType.list = true;
|
||||
}
|
||||
}
|
||||
else if (type.equals("ENTITIES")) {
|
||||
fSimpleType.type = XMLSimpleType.TYPE_ENTITY;
|
||||
fSimpleType.list = true;
|
||||
}
|
||||
else if (type.equals("ENTITY")) {
|
||||
fSimpleType.type = XMLSimpleType.TYPE_ENTITY;
|
||||
}
|
||||
else if (type.equals("NMTOKENS")) {
|
||||
fSimpleType.type = XMLSimpleType.TYPE_NMTOKEN;
|
||||
fSimpleType.list = true;
|
||||
}
|
||||
else if (type.equals("NMTOKEN")) {
|
||||
fSimpleType.type = XMLSimpleType.TYPE_NMTOKEN;
|
||||
}
|
||||
else if (type.startsWith("NOTATION") ) {
|
||||
fSimpleType.type = XMLSimpleType.TYPE_NOTATION;
|
||||
}
|
||||
else if (type.startsWith("ENUMERATION") ) {
|
||||
fSimpleType.type = XMLSimpleType.TYPE_ENUMERATION;
|
||||
}
|
||||
else {
|
||||
// REVISIT: Report error message. -Ac
|
||||
System.err.println("!!! unknown attribute type "+type);
|
||||
}
|
||||
// REVISIT: The datatype should be stored with the attribute value
|
||||
// and not special-cased in the XMLValidator. -Ac
|
||||
//fSimpleType.datatypeValidator = fDatatypeValidatorFactory.createDatatypeValidator(type, null, facets, fSimpleType.list);
|
||||
|
||||
fQName.setValues(null, attributeName, attributeName, null);
|
||||
fAttributeDecl.setValues( fQName, fSimpleType, false );
|
||||
|
||||
setAttributeDecl(elementIndex, fCurrentAttributeIndex, fAttributeDecl);
|
||||
|
||||
int chunk = fCurrentAttributeIndex >> CHUNK_SHIFT;
|
||||
ensureAttributeDeclCapacity(chunk);
|
||||
} // attributeDecl(String,String,String,String[],String,XMLString,XMLString, Augmentations)
|
||||
|
||||
/** 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) {
|
||||
Integer mapping = fElementIndexMap.get(elementDeclName);
|
||||
if (mapping == null) {
|
||||
mapping = -1;
|
||||
}
|
||||
//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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
elementDecl.simpleType.defaultType = -1;
|
||||
elementDecl.simpleType.defaultValue = null;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
// 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];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public boolean getAttributeDecl(int attributeDeclIndex, XMLAttributeDecl attributeDecl) {
|
||||
if (attributeDeclIndex < 0 || attributeDeclIndex >= fAttributeDeclCount) {
|
||||
return false;
|
||||
}
|
||||
int chunk = attributeDeclIndex >> CHUNK_SHIFT;
|
||||
int index = attributeDeclIndex & CHUNK_MASK;
|
||||
|
||||
attributeDecl.name.setValues(fAttributeDeclName[chunk][index]);
|
||||
|
||||
short attributeType;
|
||||
boolean isList;
|
||||
|
||||
if (fAttributeDeclType[chunk][index] == -1) {
|
||||
|
||||
attributeType = -1;
|
||||
isList = false;
|
||||
} else {
|
||||
attributeType = (short) (fAttributeDeclType[chunk][index] & LIST_MASK);
|
||||
isList = (fAttributeDeclType[chunk][index] & LIST_FLAG) != 0;
|
||||
}
|
||||
attributeDecl.simpleType.setValues(attributeType,fAttributeDeclName[chunk][index].localpart,
|
||||
fAttributeDeclEnumeration[chunk][index],
|
||||
isList, fAttributeDeclDefaultType[chunk][index],
|
||||
fAttributeDeclDefaultValue[chunk][index],
|
||||
fAttributeDeclNonNormalizedDefaultValue[chunk][index]);
|
||||
return true;
|
||||
|
||||
} // getAttributeDecl
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether the given attribute is of type CDATA or not
|
||||
*
|
||||
* @param elName The element name.
|
||||
* @param atName The attribute name.
|
||||
*
|
||||
* @return true if the attribute is of type CDATA
|
||||
*/
|
||||
public boolean isCDATAAttribute(QName elName, QName atName) {
|
||||
int elDeclIdx = getElementDeclIndex(elName);
|
||||
if (getAttributeDecl(elDeclIdx, fAttributeDecl)
|
||||
&& fAttributeDecl.simpleType.type != XMLSimpleType.TYPE_CDATA){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void printElements( ) {
|
||||
int elementDeclIndex = 0;
|
||||
XMLElementDecl elementDecl = new XMLElementDecl();
|
||||
while (getElementDecl(elementDeclIndex++, elementDecl)) {
|
||||
|
||||
System.out.println("element decl: "+elementDecl.name+
|
||||
", "+ elementDecl.name.rawname );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void printAttributes(int elementDeclIndex) {
|
||||
int attributeDeclIndex = getFirstAttributeDeclIndex(elementDeclIndex);
|
||||
System.out.print(elementDeclIndex);
|
||||
System.out.print(" [");
|
||||
while (attributeDeclIndex != -1) {
|
||||
System.out.print(' ');
|
||||
System.out.print(attributeDeclIndex);
|
||||
printAttribute(attributeDeclIndex);
|
||||
attributeDeclIndex = getNextAttributeDeclIndex(attributeDeclIndex);
|
||||
if (attributeDeclIndex != -1) {
|
||||
System.out.print(",");
|
||||
}
|
||||
}
|
||||
System.out.println(" ]");
|
||||
}
|
||||
|
||||
|
||||
protected int createElementDecl() {
|
||||
int chunk = fElementDeclCount >> CHUNK_SHIFT;
|
||||
int index = fElementDeclCount & CHUNK_MASK;
|
||||
ensureElementDeclCapacity(chunk);
|
||||
fElementDeclName[chunk][index] = new QName();
|
||||
fElementDeclType[chunk][index] = -1;
|
||||
fElementDeclFirstAttributeDeclIndex[chunk][index] = -1;
|
||||
fElementDeclLastAttributeDeclIndex[chunk][index] = -1;
|
||||
return fElementDeclCount++;
|
||||
}
|
||||
|
||||
protected void setElementDecl(int elementDeclIndex, XMLElementDecl elementDecl) {
|
||||
if (elementDeclIndex < 0 || elementDeclIndex >= fElementDeclCount) {
|
||||
return;
|
||||
}
|
||||
int chunk = elementDeclIndex >> CHUNK_SHIFT;
|
||||
int index = elementDeclIndex & CHUNK_MASK;
|
||||
|
||||
int scope = elementDecl.scope;
|
||||
|
||||
|
||||
fElementDeclName[chunk][index].setValues(elementDecl.name);
|
||||
fElementDeclType[chunk][index] = elementDecl.type;
|
||||
|
||||
|
||||
|
||||
if (elementDecl.simpleType.list == true ) {
|
||||
fElementDeclType[chunk][index] |= LIST_FLAG;
|
||||
}
|
||||
|
||||
fElementIndexMap.put(elementDecl.name.rawname, elementDeclIndex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected void setFirstAttributeDeclIndex(int elementDeclIndex, int newFirstAttrIndex){
|
||||
|
||||
if (elementDeclIndex < 0 || elementDeclIndex >= fElementDeclCount) {
|
||||
return;
|
||||
}
|
||||
|
||||
int chunk = elementDeclIndex >> CHUNK_SHIFT;
|
||||
int index = elementDeclIndex & CHUNK_MASK;
|
||||
|
||||
fElementDeclFirstAttributeDeclIndex[chunk][index] = newFirstAttrIndex;
|
||||
}
|
||||
|
||||
|
||||
protected int createAttributeDecl() {
|
||||
int chunk = fAttributeDeclCount >> CHUNK_SHIFT;
|
||||
int index = fAttributeDeclCount & CHUNK_MASK;
|
||||
|
||||
ensureAttributeDeclCapacity(chunk);
|
||||
fAttributeDeclName[chunk][index] = new QName();
|
||||
fAttributeDeclType[chunk][index] = -1;
|
||||
fAttributeDeclEnumeration[chunk][index] = null;
|
||||
fAttributeDeclDefaultType[chunk][index] = XMLSimpleType.DEFAULT_TYPE_IMPLIED;
|
||||
fAttributeDeclDefaultValue[chunk][index] = null;
|
||||
fAttributeDeclNonNormalizedDefaultValue[chunk][index] = null;
|
||||
fAttributeDeclNextAttributeDeclIndex[chunk][index] = -1;
|
||||
return fAttributeDeclCount++;
|
||||
}
|
||||
|
||||
|
||||
protected void setAttributeDecl(int elementDeclIndex, int attributeDeclIndex,
|
||||
XMLAttributeDecl attributeDecl) {
|
||||
int attrChunk = attributeDeclIndex >> CHUNK_SHIFT;
|
||||
int attrIndex = attributeDeclIndex & CHUNK_MASK;
|
||||
fAttributeDeclName[attrChunk][attrIndex].setValues(attributeDecl.name);
|
||||
fAttributeDeclType[attrChunk][attrIndex] = attributeDecl.simpleType.type;
|
||||
|
||||
if (attributeDecl.simpleType.list) {
|
||||
fAttributeDeclType[attrChunk][attrIndex] |= LIST_FLAG;
|
||||
}
|
||||
fAttributeDeclEnumeration[attrChunk][attrIndex] = attributeDecl.simpleType.enumeration;
|
||||
fAttributeDeclDefaultType[attrChunk][attrIndex] = attributeDecl.simpleType.defaultType;
|
||||
|
||||
fAttributeDeclDefaultValue[attrChunk][attrIndex] = attributeDecl.simpleType.defaultValue;
|
||||
fAttributeDeclNonNormalizedDefaultValue[attrChunk][attrIndex] = attributeDecl.simpleType.nonNormalizedDefaultValue;
|
||||
|
||||
int elemChunk = elementDeclIndex >> CHUNK_SHIFT;
|
||||
int elemIndex = elementDeclIndex & CHUNK_MASK;
|
||||
int index = fElementDeclFirstAttributeDeclIndex[elemChunk][elemIndex];
|
||||
while (index != -1) {
|
||||
if (index == attributeDeclIndex) {
|
||||
break;
|
||||
}
|
||||
attrChunk = index >> CHUNK_SHIFT;
|
||||
attrIndex = index & CHUNK_MASK;
|
||||
index = fAttributeDeclNextAttributeDeclIndex[attrChunk][attrIndex];
|
||||
}
|
||||
if (index == -1) {
|
||||
if (fElementDeclFirstAttributeDeclIndex[elemChunk][elemIndex] == -1) {
|
||||
fElementDeclFirstAttributeDeclIndex[elemChunk][elemIndex] = attributeDeclIndex;
|
||||
} else {
|
||||
index = fElementDeclLastAttributeDeclIndex[elemChunk][elemIndex];
|
||||
attrChunk = index >> CHUNK_SHIFT;
|
||||
attrIndex = index & CHUNK_MASK;
|
||||
fAttributeDeclNextAttributeDeclIndex[attrChunk][attrIndex] = attributeDeclIndex;
|
||||
}
|
||||
fElementDeclLastAttributeDeclIndex[elemChunk][elemIndex] = attributeDeclIndex;
|
||||
}
|
||||
}
|
||||
|
||||
public void notationDecl(String name, XMLResourceIdentifier identifier,
|
||||
Augmentations augs) throws XNIException {
|
||||
|
||||
|
||||
XMLNotationDecl notationDecl = new XMLNotationDecl();
|
||||
notationDecl.setValues(name,identifier.getPublicId(),identifier.getLiteralSystemId(),
|
||||
identifier.getBaseSystemId());
|
||||
notationDecls.add(notationDecl);
|
||||
}
|
||||
|
||||
public List getNotationDecls(){
|
||||
return notationDecls;
|
||||
}
|
||||
|
||||
//
|
||||
// Private methods
|
||||
//
|
||||
private void printAttribute(int attributeDeclIndex) {
|
||||
|
||||
XMLAttributeDecl attributeDecl = new XMLAttributeDecl();
|
||||
if (getAttributeDecl(attributeDeclIndex, attributeDecl)) {
|
||||
System.out.print(" { ");
|
||||
System.out.print(attributeDecl.name.localpart);
|
||||
System.out.print(" }");
|
||||
}
|
||||
|
||||
} // printAttribute(int)
|
||||
|
||||
|
||||
|
||||
private void ensureElementDeclCapacity(int chunk) {
|
||||
if (chunk >= fElementDeclName.length) {
|
||||
|
||||
fElementDeclName = resize(fElementDeclName, fElementDeclName.length * 2);
|
||||
fElementDeclType = resize(fElementDeclType, fElementDeclType.length * 2);
|
||||
fElementDeclFirstAttributeDeclIndex = resize(fElementDeclFirstAttributeDeclIndex, fElementDeclFirstAttributeDeclIndex.length * 2);
|
||||
fElementDeclLastAttributeDeclIndex = resize(fElementDeclLastAttributeDeclIndex, fElementDeclLastAttributeDeclIndex.length * 2);
|
||||
}
|
||||
else if (fElementDeclName[chunk] != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
fElementDeclName[chunk] = new QName[CHUNK_SIZE];
|
||||
fElementDeclType[chunk] = new short[CHUNK_SIZE];
|
||||
fElementDeclFirstAttributeDeclIndex[chunk] = new int[CHUNK_SIZE];
|
||||
fElementDeclLastAttributeDeclIndex[chunk] = new int[CHUNK_SIZE];
|
||||
return;
|
||||
}
|
||||
|
||||
private void ensureAttributeDeclCapacity(int chunk) {
|
||||
|
||||
if (chunk >= fAttributeDeclName.length) {
|
||||
fAttributeDeclName = resize(fAttributeDeclName, fAttributeDeclName.length * 2);
|
||||
fAttributeDeclType = resize(fAttributeDeclType, fAttributeDeclType.length * 2);
|
||||
fAttributeDeclEnumeration = resize(fAttributeDeclEnumeration, fAttributeDeclEnumeration.length * 2);
|
||||
fAttributeDeclDefaultType = resize(fAttributeDeclDefaultType, fAttributeDeclDefaultType.length * 2);
|
||||
fAttributeDeclDefaultValue = resize(fAttributeDeclDefaultValue, fAttributeDeclDefaultValue.length * 2);
|
||||
fAttributeDeclNonNormalizedDefaultValue = resize(fAttributeDeclNonNormalizedDefaultValue, fAttributeDeclNonNormalizedDefaultValue.length * 2);
|
||||
fAttributeDeclNextAttributeDeclIndex = resize(fAttributeDeclNextAttributeDeclIndex, fAttributeDeclNextAttributeDeclIndex.length * 2);
|
||||
}
|
||||
else if (fAttributeDeclName[chunk] != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
fAttributeDeclName[chunk] = new QName[CHUNK_SIZE];
|
||||
fAttributeDeclType[chunk] = new short[CHUNK_SIZE];
|
||||
fAttributeDeclEnumeration[chunk] = new String[CHUNK_SIZE][];
|
||||
fAttributeDeclDefaultType[chunk] = new short[CHUNK_SIZE];
|
||||
fAttributeDeclDefaultValue[chunk] = new String[CHUNK_SIZE];
|
||||
fAttributeDeclNonNormalizedDefaultValue[chunk] = new String[CHUNK_SIZE];
|
||||
fAttributeDeclNextAttributeDeclIndex[chunk] = new int[CHUNK_SIZE];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// resize chunks
|
||||
|
||||
private static short[][] resize(short array[][], int newsize) {
|
||||
short newarray[][] = new short[newsize][];
|
||||
System.arraycopy(array, 0, newarray, 0, array.length);
|
||||
return newarray;
|
||||
}
|
||||
|
||||
private static int[][] resize(int array[][], int newsize) {
|
||||
int newarray[][] = new int[newsize][];
|
||||
System.arraycopy(array, 0, newarray, 0, array.length);
|
||||
return newarray;
|
||||
}
|
||||
|
||||
private static QName[][] resize(QName array[][], int newsize) {
|
||||
QName newarray[][] = new QName[newsize][];
|
||||
System.arraycopy(array, 0, newarray, 0, array.length);
|
||||
return newarray;
|
||||
}
|
||||
|
||||
private static String[][] resize(String array[][], int newsize) {
|
||||
String newarray[][] = new String[newsize][];
|
||||
System.arraycopy(array, 0, newarray, 0, array.length);
|
||||
return newarray;
|
||||
}
|
||||
|
||||
private static String[][][] resize(String array[][][], int newsize) {
|
||||
String newarray[][][] = new String[newsize] [][];
|
||||
System.arraycopy(array, 0, newarray, 0, array.length);
|
||||
return newarray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize the attribute value of a non CDATA default attribute
|
||||
* collapsing sequences of space characters (x20)
|
||||
*
|
||||
* @param value The value to normalize
|
||||
* @return Whether the value was changed or not.
|
||||
*/
|
||||
private boolean normalizeDefaultAttrValue(XMLString value) {
|
||||
|
||||
int oldLength = value.length;
|
||||
|
||||
boolean skipSpace = true; // skip leading spaces
|
||||
int current = value.offset;
|
||||
int end = value.offset + value.length;
|
||||
for (int i = value.offset; i < end; i++) {
|
||||
if (value.ch[i] == ' ') {
|
||||
if (!skipSpace) {
|
||||
// take the first whitespace as a space and skip the others
|
||||
value.ch[current++] = ' ';
|
||||
skipSpace = true;
|
||||
}
|
||||
else {
|
||||
// just skip it.
|
||||
}
|
||||
}
|
||||
else {
|
||||
// simply shift non space chars if needed
|
||||
if (current != i) {
|
||||
value.ch[current] = value.ch[i];
|
||||
}
|
||||
current++;
|
||||
skipSpace = false;
|
||||
}
|
||||
}
|
||||
if (current != end) {
|
||||
if (skipSpace) {
|
||||
// if we finished on a space trim it
|
||||
current--;
|
||||
}
|
||||
// set the new value length
|
||||
value.length = current - value.offset;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void endDTD(Augmentations augs) throws XNIException {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.dtd.nonvalidating;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.xni.QName;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class XMLAttributeDecl {
|
||||
|
||||
|
||||
/** name */
|
||||
public final QName name = new QName();
|
||||
|
||||
/** simpleType */
|
||||
public final XMLSimpleType simpleType = new XMLSimpleType();
|
||||
|
||||
/** optional */
|
||||
public boolean optional;
|
||||
|
||||
|
||||
/**
|
||||
* setValues
|
||||
*
|
||||
* @param name
|
||||
* @param simpleType
|
||||
* @param optional
|
||||
*/
|
||||
public void setValues(QName name, XMLSimpleType simpleType, boolean optional) {
|
||||
this.name.setValues(name);
|
||||
this.simpleType.setValues(simpleType);
|
||||
this.optional = optional;
|
||||
}
|
||||
|
||||
/**
|
||||
* clear
|
||||
*/
|
||||
public void clear() {
|
||||
this.name.clear();
|
||||
this.simpleType.clear();
|
||||
this.optional = false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.dtd.nonvalidating;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.xni.QName;
|
||||
/**
|
||||
*/
|
||||
public class XMLElementDecl {
|
||||
|
||||
/** TYPE_ANY */
|
||||
public static final short TYPE_ANY = 0;
|
||||
|
||||
/** TYPE_EMPTY */
|
||||
public static final short TYPE_EMPTY = 1;
|
||||
|
||||
/** TYPE_MIXED */
|
||||
public static final short TYPE_MIXED = 2;
|
||||
|
||||
/** TYPE_CHILDREN */
|
||||
public static final short TYPE_CHILDREN = 3;
|
||||
|
||||
/** TYPE_SIMPLE */
|
||||
public static final short TYPE_SIMPLE = 4;
|
||||
|
||||
|
||||
/** name */
|
||||
public final QName name = new QName();
|
||||
|
||||
/** scope */
|
||||
public int scope = -1;
|
||||
|
||||
/** type */
|
||||
public short type = -1;
|
||||
|
||||
|
||||
/** simpleType */
|
||||
public final XMLSimpleType simpleType = new XMLSimpleType();
|
||||
|
||||
/**
|
||||
* setValues
|
||||
*
|
||||
* @param name
|
||||
* @param scope
|
||||
* @param type
|
||||
* @param contentModelValidator
|
||||
* @param simpleType
|
||||
*/
|
||||
public void setValues(QName name, int scope, short type, XMLSimpleType simpleType) {
|
||||
this.name.setValues(name);
|
||||
this.scope = scope;
|
||||
this.type = type;
|
||||
this.simpleType.setValues(simpleType);
|
||||
} // setValues
|
||||
|
||||
/**
|
||||
* clear
|
||||
*/
|
||||
public void clear() {
|
||||
this.name.clear();
|
||||
this.type = -1;
|
||||
this.scope = -1;
|
||||
this.simpleType.clear();
|
||||
} // clear
|
||||
|
||||
} // class XMLElementDecl
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.dtd.nonvalidating;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class XMLNotationDecl {
|
||||
|
||||
//
|
||||
// Data
|
||||
//
|
||||
|
||||
/** name */
|
||||
public String name;
|
||||
|
||||
/** publicId */
|
||||
public String publicId;
|
||||
|
||||
/** systemId */
|
||||
public String systemId;
|
||||
|
||||
/** base systemId */
|
||||
public String baseSystemId;
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
|
||||
/**
|
||||
* setValues
|
||||
*
|
||||
* @param name
|
||||
* @param publicId
|
||||
* @param systemId
|
||||
*/
|
||||
public void setValues(String name, String publicId, String systemId, String baseSystemId) {
|
||||
this.name = name;
|
||||
this.publicId = publicId;
|
||||
this.systemId = systemId;
|
||||
this.baseSystemId = baseSystemId;
|
||||
} // setValues
|
||||
|
||||
/**
|
||||
* clear
|
||||
*/
|
||||
public void clear() {
|
||||
this.name = null;
|
||||
this.publicId = null;
|
||||
this.systemId = null;
|
||||
this.baseSystemId = null;
|
||||
} // clear
|
||||
|
||||
} // class XMLNotationDecl
|
||||
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
* THIS FILE WAS MODIFIED BY SUN MICROSYSTEMS, INC.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2005 The Apache Software Foundation.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.dtd.nonvalidating;
|
||||
/**
|
||||
*/
|
||||
public class XMLSimpleType {
|
||||
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
|
||||
/** TYPE_CDATA */
|
||||
public static final short TYPE_CDATA = 0;
|
||||
|
||||
/** TYPE_ENTITY */
|
||||
public static final short TYPE_ENTITY = 1;
|
||||
|
||||
/** TYPE_ENUMERATION */
|
||||
public static final short TYPE_ENUMERATION = 2;
|
||||
|
||||
/** TYPE_ID */
|
||||
public static final short TYPE_ID = 3;
|
||||
|
||||
/** TYPE_IDREF */
|
||||
public static final short TYPE_IDREF = 4;
|
||||
|
||||
/** TYPE_NMTOKEN */
|
||||
public static final short TYPE_NMTOKEN = 5;
|
||||
|
||||
/** TYPE_NOTATION */
|
||||
public static final short TYPE_NOTATION = 6;
|
||||
|
||||
/** TYPE_NAMED */
|
||||
public static final short TYPE_NAMED = 7;
|
||||
|
||||
/** DEFAULT_TYPE_DEFAULT */
|
||||
public static final short DEFAULT_TYPE_DEFAULT = 3;
|
||||
|
||||
/** DEFAULT_TYPE_FIXED */
|
||||
public static final short DEFAULT_TYPE_FIXED = 1;
|
||||
|
||||
/** DEFAULT_TYPE_IMPLIED */
|
||||
public static final short DEFAULT_TYPE_IMPLIED = 0;
|
||||
|
||||
/** DEFAULT_TYPE_REQUIRED */
|
||||
public static final short DEFAULT_TYPE_REQUIRED = 2;
|
||||
|
||||
//
|
||||
// Data
|
||||
//
|
||||
|
||||
/** type */
|
||||
public short type;
|
||||
|
||||
/** name */
|
||||
public String name;
|
||||
|
||||
/** enumeration */
|
||||
public String[] enumeration;
|
||||
|
||||
/** list */
|
||||
public boolean list;
|
||||
|
||||
/** defaultType */
|
||||
public short defaultType;
|
||||
|
||||
/** defaultValue */
|
||||
public String defaultValue;
|
||||
|
||||
/** non-normalized defaultValue */
|
||||
public String nonNormalizedDefaultValue;
|
||||
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
|
||||
/**
|
||||
* setValues
|
||||
*
|
||||
* @param type
|
||||
* @param name
|
||||
* @param enumeration
|
||||
* @param list
|
||||
* @param defaultType
|
||||
* @param defaultValue
|
||||
* @param nonNormalizedDefaultValue
|
||||
* @param datatypeValidator
|
||||
*/
|
||||
public void setValues(short type, String name, String[] enumeration,
|
||||
boolean list, short defaultType,
|
||||
String defaultValue, String nonNormalizedDefaultValue){
|
||||
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
// REVISIT: Should this be a copy? -Ac
|
||||
if (enumeration != null && enumeration.length > 0) {
|
||||
this.enumeration = new String[enumeration.length];
|
||||
System.arraycopy(enumeration, 0, this.enumeration, 0, this.enumeration.length);
|
||||
}
|
||||
else {
|
||||
this.enumeration = null;
|
||||
}
|
||||
this.list = list;
|
||||
this.defaultType = defaultType;
|
||||
this.defaultValue = defaultValue;
|
||||
this.nonNormalizedDefaultValue = nonNormalizedDefaultValue;
|
||||
|
||||
} // setValues(short,String,String[],boolean,short,String,String,DatatypeValidator)
|
||||
|
||||
/** Set values. */
|
||||
public void setValues(XMLSimpleType simpleType) {
|
||||
|
||||
type = simpleType.type;
|
||||
name = simpleType.name;
|
||||
// REVISIT: Should this be a copy? -Ac
|
||||
if (simpleType.enumeration != null && simpleType.enumeration.length > 0) {
|
||||
enumeration = new String[simpleType.enumeration.length];
|
||||
System.arraycopy(simpleType.enumeration, 0, enumeration, 0, enumeration.length);
|
||||
}
|
||||
else {
|
||||
enumeration = null;
|
||||
}
|
||||
list = simpleType.list;
|
||||
defaultType = simpleType.defaultType;
|
||||
defaultValue = simpleType.defaultValue;
|
||||
nonNormalizedDefaultValue = simpleType.nonNormalizedDefaultValue;
|
||||
|
||||
} // setValues(XMLSimpleType)
|
||||
|
||||
/**
|
||||
* clear
|
||||
*/
|
||||
public void clear() {
|
||||
this.type = -1;
|
||||
this.name = null;
|
||||
this.enumeration = null;
|
||||
this.list = false;
|
||||
this.defaultType = -1;
|
||||
this.defaultValue = null;
|
||||
this.nonNormalizedDefaultValue = null;
|
||||
}
|
||||
|
||||
} // class XMLSimpleType
|
||||
Reference in New Issue
Block a user