com.sun.xml.internal.fastinfoset.CommonResourceBundle Java Examples
The following examples show how to use
com.sun.xml.internal.fastinfoset.CommonResourceBundle.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DOMDocumentParser.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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(); }
Example #2
Source File: PrefixArray.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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; }
Example #3
Source File: StAXDocumentParser.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** 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; }
Example #4
Source File: StAXDocumentParser.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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; } }
Example #5
Source File: UUIDEncodingAlgorithm.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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); }
Example #6
Source File: ContiguousCharArrayArray.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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; }
Example #7
Source File: StAXDocumentSerializer.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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); } }
Example #8
Source File: BooleanEncodingAlgorithm.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void encodeToOutputStream(Object data, OutputStream s) throws IOException { if (!(data instanceof boolean[])) { throw new IllegalArgumentException(CommonResourceBundle.getInstance().getString("message.dataNotBoolean")); } boolean array[] = (boolean[])data; final int alength = array.length; final int mod = (alength + 4) % 8; final int unusedBits = (mod == 0) ? 0 : 8 - mod; int bitPosition = 4; int value = unusedBits << 4; int astart = 0; while (astart < alength) { if (array[astart++]) { value |= BIT_TABLE[bitPosition]; } if (++bitPosition == 8) { s.write(value); bitPosition = value = 0; } } if (bitPosition != 8) { s.write(value); } }
Example #9
Source File: LongEncodingAlgorithm.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void convertToCharacters(Object data, StringBuffer s) { if (!(data instanceof long[])) { throw new IllegalArgumentException(CommonResourceBundle.getInstance().getString("message.dataNotLongArray")); } final long[] ldata = (long[])data; convertToCharactersFromLongArray(ldata, s); }
Example #10
Source File: QualifiedNameArray.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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 QualifiedName[] newArray = new QualifiedName[newSize]; System.arraycopy(_array, 0, newArray, 0, _size); _array = newArray; }
Example #11
Source File: DoubleEncodingAlgorithm.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public final void convertToCharacters(Object data, StringBuffer s) { if (!(data instanceof double[])) { throw new IllegalArgumentException(CommonResourceBundle.getInstance().getString("message.dataNotDouble")); } final double[] fdata = (double[])data; convertToCharactersFromDoubleArray(fdata, s); }
Example #12
Source File: ShortEncodingAlgorithm.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void encodeToOutputStream(Object data, OutputStream s) throws IOException { if (!(data instanceof short[])) { throw new IllegalArgumentException(CommonResourceBundle.getInstance().getString("message.dataNotShortArray")); } final short[] idata = (short[])data; encodeToOutputStreamFromShortArray(idata, s); }
Example #13
Source File: BooleanEncodingAlgorithm.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public int getPrimtiveLengthFromOctetLength(int octetLength, int firstOctet) throws EncodingAlgorithmException { final int unusedBits = (firstOctet >> 4) & 0xFF; if (octetLength == 1) { if (unusedBits > 3) { throw new EncodingAlgorithmException(CommonResourceBundle.getInstance().getString("message.unusedBits4")); } return 4 - unusedBits; } else { if (unusedBits > 7) { throw new EncodingAlgorithmException(CommonResourceBundle.getInstance().getString("message.unusedBits8")); } return octetLength * 8 - 4 - unusedBits; } }
Example #14
Source File: BooleanEncodingAlgorithm.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void encodeToBytes(Object array, int astart, int alength, byte[] b, int start) { if (!(array instanceof boolean[])) { throw new IllegalArgumentException(CommonResourceBundle.getInstance().getString("message.dataNotBoolean")); } encodeToBytesFromBooleanArray((boolean[])array, astart, alength, b, start); }
Example #15
Source File: ShortEncodingAlgorithm.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public final void convertToCharacters(Object data, StringBuffer s) { if (!(data instanceof short[])) { throw new IllegalArgumentException(CommonResourceBundle.getInstance().getString("message.dataNotShortArray")); } final short[] idata = (short[])data; convertToCharactersFromShortArray(idata, s); }
Example #16
Source File: DOMDocumentParser.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
protected final QualifiedName processLiteralQualifiedName(int state) throws FastInfosetException, IOException { switch (state) { // no prefix, no namespace case 0: return new QualifiedName( null, null, decodeIdentifyingNonEmptyStringOnFirstBit(_v.localName), -1, -1, _identifier, null); // no prefix, namespace case 1: return new QualifiedName( null, decodeIdentifyingNonEmptyStringIndexOnFirstBitAsNamespaceName(false), decodeIdentifyingNonEmptyStringOnFirstBit(_v.localName), -1, _namespaceNameIndex, _identifier, null); // prefix, no namespace case 2: throw new FastInfosetException(CommonResourceBundle.getInstance().getString("message.qNameMissingNamespaceName")); // prefix, namespace case 3: return new QualifiedName( decodeIdentifyingNonEmptyStringIndexOnFirstBitAsPrefix(true), decodeIdentifyingNonEmptyStringIndexOnFirstBitAsNamespaceName(true), decodeIdentifyingNonEmptyStringOnFirstBit(_v.localName), _prefixIndex, _namespaceNameIndex, _identifier, _charBuffer); default: throw new FastInfosetException(CommonResourceBundle.getInstance().getString("message.decodingEII")); } }
Example #17
Source File: DoubleEncodingAlgorithm.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void encodeToOutputStream(Object data, OutputStream s) throws IOException { if (!(data instanceof double[])) { throw new IllegalArgumentException(CommonResourceBundle.getInstance().getString("message.dataNotDouble")); } final double[] fdata = (double[])data; encodeToOutputStreamFromDoubleArray(fdata, s); }
Example #18
Source File: BASE64EncodingAlgorithm.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void encodeToOutputStream(Object data, OutputStream s) throws IOException { if (!(data instanceof byte[])) { throw new IllegalArgumentException(CommonResourceBundle.getInstance().getString("message.dataNotByteArray")); } s.write((byte[])data); }
Example #19
Source File: LongEncodingAlgorithm.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void encodeToOutputStream(Object data, OutputStream s) throws IOException { if (!(data instanceof long[])) { throw new IllegalArgumentException(CommonResourceBundle.getInstance().getString("message.dataNotLongArray")); } final long[] ldata = (long[])data; encodeToOutputStreamFromLongArray(ldata, s); }
Example #20
Source File: LongEncodingAlgorithm.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public int getPrimtiveLengthFromOctetLength(int octetLength) throws EncodingAlgorithmException { if (octetLength % LONG_SIZE != 0) { throw new EncodingAlgorithmException(CommonResourceBundle.getInstance(). getString("message.lengthNotMultipleOfLong", new Object[]{Integer.valueOf(LONG_SIZE)})); } return octetLength / LONG_SIZE; }
Example #21
Source File: FloatEncodingAlgorithm.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void encodeToOutputStream(Object data, OutputStream s) throws IOException { if (!(data instanceof float[])) { throw new IllegalArgumentException(CommonResourceBundle.getInstance().getString("message.dataNotFloat")); } final float[] fdata = (float[])data; encodeToOutputStreamFromFloatArray(fdata, s); }
Example #22
Source File: StringArray.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public final void setReadOnlyArray(ValueArray readOnlyArray, boolean clear) { if (!(readOnlyArray instanceof StringArray)) { throw new IllegalArgumentException(CommonResourceBundle.getInstance(). getString("message.illegalClass", new Object[]{readOnlyArray})); } setReadOnlyArray((StringArray)readOnlyArray, clear); }
Example #23
Source File: StAXDocumentSerializer.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void writeAttribute(String prefix, String namespaceURI, String localName, String value) throws XMLStreamException { if (!_inStartElement) { throw new IllegalStateException(CommonResourceBundle.getInstance().getString("message.attributeWritingNotAllowed")); } // TODO // Need to check carefully the rule for the writing of // namespaces in StAX. Is it safe to ignore such // attributes, as declarations will be made using the // writeNamespace method if (namespaceURI == EncodingConstants.XMLNS_NAMESPACE_NAME || namespaceURI.equals(EncodingConstants.XMLNS_NAMESPACE_NAME)) { return; } if (_attributesArrayIndex == _attributesArray.length) { final String[] attributesArray = new String[_attributesArrayIndex * 2]; System.arraycopy(_attributesArray, 0, attributesArray, 0, _attributesArrayIndex); _attributesArray = attributesArray; } _attributesArray[_attributesArrayIndex++] = namespaceURI; _attributesArray[_attributesArrayIndex++] = prefix; _attributesArray[_attributesArrayIndex++] = localName; _attributesArray[_attributesArrayIndex++] = value; }
Example #24
Source File: StAXDocumentSerializer.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void writeAttribute(String namespaceURI, String localName, String value) throws XMLStreamException { String prefix = ""; // Find prefix for attribute, ignoring default namespace if (namespaceURI.length() > 0) { prefix = _nsContext.getNonDefaultPrefix(namespaceURI); // Undeclared prefix or ignorable default ns? if (prefix == null || prefix.length() == 0) { // Workaround for BUG in SAX NamespaceSupport helper // which incorrectly defines namespace declaration URI if (namespaceURI == EncodingConstants.XMLNS_NAMESPACE_NAME || namespaceURI.equals(EncodingConstants.XMLNS_NAMESPACE_NAME)) { // TODO // Need to check carefully the rule for the writing of // namespaces in StAX. Is it safe to ignore such // attributes, as declarations will be made using the // writeNamespace method return; } throw new XMLStreamException(CommonResourceBundle.getInstance().getString("message.URIUnbound", new Object[]{namespaceURI})); } } writeAttribute(prefix, namespaceURI, localName, value); }
Example #25
Source File: StAXDocumentParser.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
protected final void convertEncodingAlgorithmDataToCharacters() throws FastInfosetException, IOException { StringBuffer buffer = new StringBuffer(); if (_algorithmId == EncodingAlgorithmIndexes.BASE64) { convertBase64AlorithmDataToCharacters(buffer); } else if (_algorithmId < EncodingConstants.ENCODING_ALGORITHM_BUILTIN_END) { Object array = BuiltInEncodingAlgorithmFactory.getAlgorithm(_algorithmId). decodeFromBytes(_algorithmData, _algorithmDataOffset, _algorithmDataLength); BuiltInEncodingAlgorithmFactory.getAlgorithm(_algorithmId).convertToCharacters(array, buffer); } else if (_algorithmId == EncodingAlgorithmIndexes.CDATA) { _octetBufferOffset -= _octetBufferLength; decodeUtf8StringIntoCharBuffer(); _characters = _charBuffer; _charactersOffset = 0; return; } else if (_algorithmId >= EncodingConstants.ENCODING_ALGORITHM_APPLICATION_START) { final EncodingAlgorithm ea = (EncodingAlgorithm)_registeredEncodingAlgorithms.get(_algorithmURI); if (ea != null) { final Object data = ea.decodeFromBytes(_octetBuffer, _octetBufferStart, _octetBufferLength); ea.convertToCharacters(data, buffer); } else { throw new EncodingAlgorithmException( CommonResourceBundle.getInstance().getString("message.algorithmDataCannotBeReported")); } } _characters = new char[buffer.length()]; buffer.getChars(0, buffer.length(), _characters, 0); _charactersOffset = 0; _charBufferLength = _characters.length; }
Example #26
Source File: PrefixArray.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public final void setReadOnlyArray(ValueArray readOnlyArray, boolean clear) { if (!(readOnlyArray instanceof PrefixArray)) { throw new IllegalArgumentException(CommonResourceBundle.getInstance(). getString("message.illegalClass", new Object[]{readOnlyArray})); } setReadOnlyArray((PrefixArray)readOnlyArray, clear); }
Example #27
Source File: ContiguousCharArrayArray.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public final void setReadOnlyArray(ValueArray readOnlyArray, boolean clear) { if (!(readOnlyArray instanceof ContiguousCharArrayArray)) { throw new IllegalArgumentException(CommonResourceBundle.getInstance().getString("message.illegalClass", new Object[]{readOnlyArray})); } setReadOnlyArray((ContiguousCharArrayArray)readOnlyArray, clear); }
Example #28
Source File: StAXDocumentParser.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
protected final void processEII(QualifiedName name, boolean hasAttributes) throws FastInfosetException, IOException { if (_prefixTable._currentInScope[name.prefixIndex] != name.namespaceNameIndex) { throw new FastInfosetException(CommonResourceBundle.getInstance().getString("message.qnameOfEIINotInScope")); } _eventType = START_ELEMENT; _qualifiedName = name; if (_clearAttributes) { _attributes.clear(); _clearAttributes = false; } if (hasAttributes) { processAIIs(); } // Push element holder onto the stack _stackCount++; if (_stackCount == _qNameStack.length) { QualifiedName[] qNameStack = new QualifiedName[_qNameStack.length * 2]; System.arraycopy(_qNameStack, 0, qNameStack, 0, _qNameStack.length); _qNameStack = qNameStack; int[] namespaceAIIsStartStack = new int[_namespaceAIIsStartStack.length * 2]; System.arraycopy(_namespaceAIIsStartStack, 0, namespaceAIIsStartStack, 0, _namespaceAIIsStartStack.length); _namespaceAIIsStartStack = namespaceAIIsStartStack; int[] namespaceAIIsEndStack = new int[_namespaceAIIsEndStack.length * 2]; System.arraycopy(_namespaceAIIsEndStack, 0, namespaceAIIsEndStack, 0, _namespaceAIIsEndStack.length); _namespaceAIIsEndStack = namespaceAIIsEndStack; } _qNameStack[_stackCount] = _qualifiedName; _namespaceAIIsStartStack[_stackCount] = _currentNamespaceAIIsStart; _namespaceAIIsEndStack[_stackCount] = _currentNamespaceAIIsEnd; }
Example #29
Source File: SAXEventSerializer.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public boolean equals(Object o) { try { return (o instanceof AttributeValueHolder) && qName.equals(((AttributeValueHolder) o).qName); } catch (Exception e) { throw new RuntimeException(CommonResourceBundle.getInstance().getString("message.AttributeValueHolderExpected")); } }
Example #30
Source File: StAXDocumentParser.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public final String getPIData() { if (_eventType != PROCESSING_INSTRUCTION) { throw new IllegalStateException(CommonResourceBundle.getInstance().getString("message.invalidCallingGetPIData")); } return _piData; }