下面列出了org.xml.sax.ext.DeclHandler#com.sun.xml.internal.fastinfoset.CommonResourceBundle 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
protected final void resize() {
if (_size == _maximumCapacity) {
throw new ValueArrayResourceException(CommonResourceBundle.getInstance().getString("message.arrayMaxCapacity"));
}
int newSize = _size * 3 / 2 + 1;
if (newSize > _maximumCapacity) {
newSize = _maximumCapacity;
}
final int[] offset = new int[newSize];
System.arraycopy(_offset, 0, offset, 0, _size);
_offset = offset;
final int[] length = new int[newSize];
System.arraycopy(_length, 0, length, 0, _size);
_length = length;
}
/** if the current tag has already read, such as in the case EventReader's
* peek() has been called, the current cursor should not move before the loop
*/
public final int nextTag(boolean currentTagRead) throws XMLStreamException {
int eventType = getEventType();
if (!currentTagRead) {
eventType = next();
}
while((eventType == CHARACTERS && isWhiteSpace()) // skip whitespace
|| (eventType == CDATA && isWhiteSpace())
|| eventType == SPACE
|| eventType == PROCESSING_INSTRUCTION
|| eventType == COMMENT) {
eventType = next();
}
if (eventType != START_ELEMENT && eventType != END_ELEMENT) {
throw new XMLStreamException(CommonResourceBundle.getInstance().getString("message.expectedStartOrEnd"), getLocation());
}
return eventType;
}
protected final void processProcessingII() throws FastInfosetException, IOException {
_eventType = PROCESSING_INSTRUCTION;
_piTarget = decodeIdentifyingNonEmptyStringOnFirstBit(_v.otherNCName);
switch(decodeNonIdentifyingStringOnFirstBit()) {
case NISTRING_STRING:
_piData = new String(_charBuffer, 0, _charBufferLength);
if (_addToTable) {
_v.otherString.add(new CharArrayString(_piData));
}
break;
case NISTRING_ENCODING_ALGORITHM:
throw new FastInfosetException(CommonResourceBundle.getInstance().getString("message.processingIIWithEncodingAlgorithm"));
case NISTRING_INDEX:
_piData = _v.otherString.get(_integer).toString();
break;
case NISTRING_EMPTY_STRING:
_piData = "";
break;
}
}
public void writeNamespace(String prefix, String namespaceURI)
throws XMLStreamException
{
if (prefix == null || prefix.length() == 0 || prefix.equals(EncodingConstants.XMLNS_NAMESPACE_PREFIX)) {
writeDefaultNamespace(namespaceURI);
}
else {
if (!_inStartElement) {
throw new IllegalStateException(CommonResourceBundle.getInstance().getString("message.attributeWritingNotAllowed"));
}
if (_namespacesArrayIndex == _namespacesArray.length) {
final String[] namespacesArray = new String[_namespacesArrayIndex * 2];
System.arraycopy(_namespacesArray, 0, namespacesArray, 0, _namespacesArrayIndex);
_namespacesArray = namespacesArray;
}
_namespacesArray[_namespacesArrayIndex++] = prefix;
_namespacesArray[_namespacesArrayIndex++] = namespaceURI;
setPrefix(prefix, namespaceURI);
}
}
protected final void resize() {
if (_size == _maximumCapacity) {
throw new ValueArrayResourceException(CommonResourceBundle.getInstance().getString("message.arrayMaxCapacity"));
}
int newSize = _size * 3 / 2 + 1;
if (newSize > _maximumCapacity) {
newSize = _maximumCapacity;
}
final String[] newArray = new String[newSize];
System.arraycopy(_array, 0, newArray, 0, _size);
_array = newArray;
newSize += 2;
final NamespaceEntry[] newInScopeNamespaces = new NamespaceEntry[newSize];
System.arraycopy(_inScopeNamespaces, 0, newInScopeNamespaces, 0, _inScopeNamespaces.length);
_inScopeNamespaces = newInScopeNamespaces;
final int[] newCurrentInScope = new int[newSize];
System.arraycopy(_currentInScope, 0, newCurrentInScope, 0, _currentInScope.length);
_currentInScope = newCurrentInScope;
}
protected String convertEncodingAlgorithmDataToCharacters(boolean isAttributeValue) throws FastInfosetException, IOException {
StringBuffer buffer = new StringBuffer();
if (_identifier < EncodingConstants.ENCODING_ALGORITHM_BUILTIN_END) {
Object array = BuiltInEncodingAlgorithmFactory.getAlgorithm(_identifier).
decodeFromBytes(_octetBuffer, _octetBufferStart, _octetBufferLength);
BuiltInEncodingAlgorithmFactory.getAlgorithm(_identifier).convertToCharacters(array, buffer);
} else if (_identifier == EncodingAlgorithmIndexes.CDATA) {
if (!isAttributeValue) {
// Set back buffer position to start of encoded string
_octetBufferOffset -= _octetBufferLength;
return decodeUtf8StringAsString();
}
throw new EncodingAlgorithmException(CommonResourceBundle.getInstance().getString("message.CDATAAlgorithmNotSupported"));
} else if (_identifier >= EncodingConstants.ENCODING_ALGORITHM_APPLICATION_START) {
final String URI = _v.encodingAlgorithm.get(_identifier - EncodingConstants.ENCODING_ALGORITHM_APPLICATION_START);
final EncodingAlgorithm ea = (EncodingAlgorithm)_registeredEncodingAlgorithms.get(URI);
if (ea != null) {
final Object data = ea.decodeFromBytes(_octetBuffer, _octetBufferStart, _octetBufferLength);
ea.convertToCharacters(data, buffer);
} else {
throw new EncodingAlgorithmException(
CommonResourceBundle.getInstance().getString("message.algorithmDataCannotBeReported"));
}
}
return buffer.toString();
}
final void fromUUIDString(String name) {
String[] components = name.split("-");
if (components.length != 5)
throw new IllegalArgumentException(CommonResourceBundle.getInstance().
getString("message.invalidUUID", new Object[]{name}));
for (int i=0; i<5; i++)
components[i] = "0x"+components[i];
_msb = Long.parseLong(components[0], 16);
_msb <<= 16;
_msb |= Long.parseLong(components[1], 16);
_msb <<= 16;
_msb |= Long.parseLong(components[2], 16);
_lsb = Long.parseLong(components[3], 16);
_lsb <<= 48;
_lsb |= Long.parseLong(components[4], 16);
}
/** Get the value of a feature/property from the underlying implementation
* @param name The name of the property (may not be null)
* @return The value of the property
* @throws IllegalArgumentException if the property is not supported
*/
public Object getProperty(String name) throws IllegalArgumentException {
if(name == null){
throw new IllegalArgumentException(CommonResourceBundle.getInstance().getString("message.nullPropertyName"));
}
if(_manager.containsProperty(name))
return _manager.getProperty(name);
throw new IllegalArgumentException(CommonResourceBundle.getInstance().getString("message.propertyNotSupported", new Object[]{name}));
}
public void setProperty(String name, Object value){
checkProperty(name);
if (name.equals(XMLInputFactory.IS_VALIDATING) &&
Boolean.TRUE.equals(value)){
throw new IllegalArgumentException(CommonResourceBundle.getInstance().getString("message.validationNotSupported") +
CommonResourceBundle.getInstance().getString("support_validation"));
} else if (name.equals(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES) &&
Boolean.TRUE.equals(value)) {
throw new IllegalArgumentException(CommonResourceBundle.getInstance().getString("message.externalEntities") +
CommonResourceBundle.getInstance().getString("resolve_external_entities_"));
}
features.put(name,value);
}
public boolean getFeature(String name)
throws SAXNotRecognizedException, SAXNotSupportedException {
if (name.equals(Features.NAMESPACES_FEATURE)) {
return true;
} else if (name.equals(Features.NAMESPACE_PREFIXES_FEATURE)) {
return _namespacePrefixesFeature;
} else if (name.equals(Features.STRING_INTERNING_FEATURE) ||
name.equals(FastInfosetReader.STRING_INTERNING_PROPERTY)) {
return getStringInterning();
} else {
throw new SAXNotRecognizedException(
CommonResourceBundle.getInstance().getString("message.featureNotSupported") + name);
}
}
public int compareTo(Object o) {
try {
return qName.compareTo(((AttributeValueHolder) o).qName);
} catch (Exception e) {
throw new RuntimeException(CommonResourceBundle.getInstance().getString("message.AttributeValueHolderExpected"));
}
}
public XMLEvent nextTag() throws XMLStreamException {
while(hasNext()) {
XMLEvent e = nextEvent();
if (e.isStartElement() || e.isEndElement())
return e;
}
throw new XMLStreamException(CommonResourceBundle.getInstance().getString("message.startOrEndNotFound"));
}
/**
*
* @param eventReader
* @throws XMLStreamException
*/
public void add(XMLEventReader eventReader) throws XMLStreamException {
if(eventReader == null) throw new XMLStreamException(CommonResourceBundle.getInstance().getString("message.nullEventReader"));
while(eventReader.hasNext()){
add(eventReader.nextEvent());
}
}
protected final void resize() {
if (_size == _maximumCapacity) {
throw new ValueArrayResourceException(CommonResourceBundle.getInstance().getString("message.arrayMaxCapacity"));
}
int newSize = _size * 3 / 2 + 1;
if (newSize > _maximumCapacity) {
newSize = _maximumCapacity;
}
final String[] newArray = new String[newSize];
System.arraycopy(_array, 0, newArray, 0, _size);
_array = newArray;
}
public final void setReadOnlyMap(KeyIntMap readOnlyMap, boolean clear) {
if (!(readOnlyMap instanceof FixedEntryStringIntMap)) {
throw new IllegalArgumentException(CommonResourceBundle.getInstance().
getString("message.illegalClass", new Object[]{readOnlyMap}));
}
setReadOnlyMap((FixedEntryStringIntMap)readOnlyMap, clear);
}
/**
* Returns this event as a start element event, may result in
* a class cast exception if this event is not a start element.
*/
public StartElement asStartElement() {
if (isStartElement()) {
return (StartElement)this;
} else
throw new ClassCastException(CommonResourceBundle.getInstance().getString("message.startElementCase", new Object[]{getEventTypeString()}));
}
/** Test if the current event is of the given type and if the namespace and name match the current namespace and name of the current event.
* If the namespaceURI is null it is not checked for equality, if the localName is null it is not checked for equality.
* @param type the event type
* @param namespaceURI the uri of the event, may be null
* @param localName the localName of the event, may be null
* @throws XMLStreamException if the required values are not matched.
*/
public final void require(int type, String namespaceURI, String localName)
throws XMLStreamException {
if( type != _eventType)
throw new XMLStreamException(CommonResourceBundle.getInstance().getString("message.eventTypeNotMatch", new Object[]{getEventTypeString(type)}));
if( namespaceURI != null && !namespaceURI.equals(getNamespaceURI()) )
throw new XMLStreamException(CommonResourceBundle.getInstance().getString("message.namespaceURINotMatch", new Object[]{namespaceURI}));
if(localName != null && !localName.equals(getLocalName()))
throw new XMLStreamException(CommonResourceBundle.getInstance().getString("message.localNameNotMatch", new Object[]{localName}));
}
public final void processingInstruction(String target, String data) throws SAXException {
try {
if (getIgnoreProcesingInstructions()) return;
if (target.length() == 0) {
throw new SAXException(CommonResourceBundle.getInstance().
getString("message.processingInstructionTargetIsEmpty"));
}
encodeTermination();
encodeProcessingInstruction(target, data);
} catch (IOException e) {
throw new SAXException("processingInstruction", e);
}
}
public final String getNamespaceURI(String prefix) {
String namespace = getNamespaceDecl(prefix);
if (namespace == null) {
if (prefix == null) {
throw new IllegalArgumentException(CommonResourceBundle.getInstance().getString("message.nullPrefix"));
}
return null; // unbound
}
return namespace;
}
public void setReadOnlyMap(KeyIntMap readOnlyMap, boolean clear) {
if (!(readOnlyMap instanceof StringIntMap)) {
throw new IllegalArgumentException(CommonResourceBundle.getInstance().
getString("message.illegalClass", new Object[]{readOnlyMap}));
}
setReadOnlyMap((StringIntMap)readOnlyMap, clear);
}
public final int getAttributeCount() {
if (_eventType != START_ELEMENT) {
throw new IllegalStateException(CommonResourceBundle.getInstance().getString("message.invalidCallingGetAttributeValue"));
}
return _attributes.getLength();
}
public final String getAttributeNamespace(int index) {
if (_eventType != START_ELEMENT) {
throw new IllegalStateException(CommonResourceBundle.getInstance().getString("message.invalidCallingGetAttributeValue"));
}
return _attributes.getURI(index);
}
public final int getNamespaceCount() {
if (_eventType == START_ELEMENT || _eventType == END_ELEMENT) {
return (_currentNamespaceAIIsEnd > 0) ? (_currentNamespaceAIIsEnd - _currentNamespaceAIIsStart) : 0;
} else {
throw new IllegalStateException(CommonResourceBundle.getInstance().getString("message.invalidCallingGetNamespaceCount"));
}
}
public final String getNamespacePrefix(int index) {
if (_eventType == START_ELEMENT || _eventType == END_ELEMENT) {
return _namespaceAIIsPrefix[_currentNamespaceAIIsStart + index];
} else {
throw new IllegalStateException(CommonResourceBundle.getInstance().getString("message.invalidCallingGetNamespacePrefix"));
}
}
public final String getNamespaceURI(int index) {
if (_eventType == START_ELEMENT || _eventType == END_ELEMENT) {
return _namespaceAIIsNamespaceName[_currentNamespaceAIIsStart + index];
} else {
throw new IllegalStateException(CommonResourceBundle.getInstance().getString("message.invalidCallingGetNamespacePrefix"));
}
}
protected final void checkTextState() {
if (_algorithmData == null) {
throw new IllegalStateException(CommonResourceBundle.getInstance().getString("message.InvalidStateForText"));
}
try {
convertEncodingAlgorithmDataToCharacters();
} catch (Exception e) {
throw new IllegalStateException(CommonResourceBundle.getInstance().getString("message.InvalidStateForText"));
}
}
public final QName getName() {
if (_eventType == START_ELEMENT || _eventType == END_ELEMENT) {
return _qualifiedName.getQName();
} else {
throw new IllegalStateException(CommonResourceBundle.getInstance().getString("message.invalidCallingGetName"));
}
}
public final void setReadOnlyMap(KeyIntMap readOnlyMap, boolean clear) {
if (!(readOnlyMap instanceof LocalNameQualifiedNamesMap)) {
throw new IllegalArgumentException(CommonResourceBundle.getInstance().
getString("message.illegalClass", new Object[]{readOnlyMap}));
}
setReadOnlyMap((LocalNameQualifiedNamesMap)readOnlyMap, clear);
}
public final String getNamespaceURI() {
if (_eventType == START_ELEMENT || _eventType == END_ELEMENT) {
return _qualifiedName.namespaceName;
} else {
throw new IllegalStateException(CommonResourceBundle.getInstance().getString("message.invalidCallingGetNamespaceURI"));
}
}
protected final void resizeArray(int requestedSize) {
if (_arrayIndex == _maximumCharacterSize) {
throw new ValueArrayResourceException(CommonResourceBundle.getInstance().getString("message.maxNumberOfCharacters"));
}
int newSize = requestedSize * 3 / 2 + 1;
if (newSize > _maximumCharacterSize) {
newSize = _maximumCharacterSize;
}
final char[] array = new char[newSize];
System.arraycopy(_array, 0, array, 0, _arrayIndex);
_array = array;
}