Java Code Examples for com.sun.xml.internal.fastinfoset.util.KeyIntMap#NOT_PRESENT

The following examples show how to use com.sun.xml.internal.fastinfoset.util.KeyIntMap#NOT_PRESENT . 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: SerializerVocabulary.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void addToNameTable(QName n, LocalNameQualifiedNamesMap m) {
    int namespaceURIIndex = -1;
    int prefixIndex = -1;
    if (n.getNamespaceURI().length() > 0) {
        namespaceURIIndex = namespaceName.obtainIndex(n.getNamespaceURI());
        if (namespaceURIIndex == KeyIntMap.NOT_PRESENT) {
            namespaceURIIndex = namespaceName.get(n.getNamespaceURI());
        }

        if (n.getPrefix().length() > 0) {
            prefixIndex = prefix.obtainIndex(n.getPrefix());
            if (prefixIndex == KeyIntMap.NOT_PRESENT) {
                prefixIndex = prefix.get(n.getPrefix());
            }
        }
    }

    int localNameIndex = localName.obtainIndex(n.getLocalPart());
    if (localNameIndex == KeyIntMap.NOT_PRESENT) {
        localNameIndex = localName.get(n.getLocalPart());
    }

    QualifiedName name = new QualifiedName(n.getPrefix(), n.getNamespaceURI(), n.getLocalPart(),
            m.getNextIndex(),
            prefixIndex, namespaceURIIndex, localNameIndex);

    LocalNameQualifiedNamesMap.Entry entry = null;
    if (_useLocalNameAsKey) {
        entry = m.obtainEntry(n.getLocalPart());
    } else {
        String qName = (prefixIndex == -1)
            ? n.getLocalPart()
            : n.getPrefix() + ":" + n.getLocalPart();
        entry = m.obtainEntry(qName);
    }

    entry.addQualifiedName(name);
}
 
Example 2
Source File: VocabularyGenerator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void addToCharArrayTable(CharArray c) {
    if (_serializerVocabulary.characterContentChunk.obtainIndex(c.ch, c.start, c.length, false) == KeyIntMap.NOT_PRESENT) {
        _parserVocabulary.characterContentChunk.add(c.ch, c.length);
    }

    _v.characterContentChunks.add(c.toString());
}
 
Example 3
Source File: Encoder.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Encode a non identifying string on the first bit of an octet.
 * Implementation of clause C.14 of ITU-T Rec. X.891 | ISO/IEC 24824-1.
 *
 * @param s the string to encode
 * @param map the vocabulary table of strings to indexes.
 * @param addToTable true if the string could be added to the vocabulary
 *                   table (if table has enough memory)
 * @param mustBeAddedToTable true if the string must be added to the vocabulary
 *                   table (if not already present in the table).
 */
protected final void encodeNonIdentifyingStringOnFirstBit(String s, StringIntMap map,
        boolean addToTable, boolean mustBeAddedToTable) throws IOException {
    if (s == null || s.length() == 0) {
        // C.26 an index (first bit '1') with seven '1' bits for an empty string
        write(0xFF);
    } else {
        if (addToTable || mustBeAddedToTable) {
            // if attribute value could be added to table
            boolean canAddAttributeToTable = mustBeAddedToTable ||
                    canAddAttributeToTable(s.length());

            // obtain/get index
            int index = canAddAttributeToTable ?
                map.obtainIndex(s) :
                map.get(s);

            if (index != KeyIntMap.NOT_PRESENT) {
                // if attribute value is in table
                encodeNonZeroIntegerOnSecondBitFirstBitOne(index);
            } else if (canAddAttributeToTable) {
                // if attribute value is not in table, but could be added
                _b = EncodingConstants.NISTRING_ADD_TO_TABLE_FLAG |
                        _nonIdentifyingStringOnFirstBitCES;
                encodeNonEmptyCharacterStringOnFifthBit(s);
            } else {
                // if attribute value is not in table and could not be added
                _b = _nonIdentifyingStringOnFirstBitCES;
                encodeNonEmptyCharacterStringOnFifthBit(s);
            }
        } else {
            _b = _nonIdentifyingStringOnFirstBitCES;
            encodeNonEmptyCharacterStringOnFifthBit(s);
        }
    }
}
 
Example 4
Source File: VocabularyGenerator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void addToTable(String s, Set v, StringIntMap m, PrefixArray a) {
    if (s.length() == 0) {
        return;
    }

    if (m.obtainIndex(s) == KeyIntMap.NOT_PRESENT) {
        a.add(s);
    }

    v.add(s);
}
 
Example 5
Source File: Encoder.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Encode a chunk of Character Information Items using a restricted
 * alphabet that results in the encoding of a character in 4 bits
 * (or two characters per octet).
 *
 * @param id the restricted alphabet identifier.
 * @param table the table mapping characters to 4 bit values.
 * @param ch the array of characters.
 * @param offset the offset into the array of characters.
 * @param length the length of characters.
 * @param addToTable if characters should be added to table.
 * @throws ArrayIndexOutOfBoundsException.
 */
protected final void encodeFourBitCharacters(int id, int[] table, char[] ch, int offset, int length,
        boolean addToTable) throws FastInfosetException, IOException {
    if (addToTable) {
        // if char array could be added to table
        boolean canAddCharacterContentToTable =
                canAddCharacterContentToTable(length, _v.characterContentChunk);

        // obtain/get index
        int index = canAddCharacterContentToTable ?
            _v.characterContentChunk.obtainIndex(ch, offset, length, true) :
            _v.characterContentChunk.get(ch, offset, length);

        if (index != KeyIntMap.NOT_PRESENT) {
            // if char array is in table
            _b = EncodingConstants.CHARACTER_CHUNK | 0x20;
            encodeNonZeroIntegerOnFourthBit(index);
            return;
        } else if (canAddCharacterContentToTable) {
            // if char array is not in table, but could be added
            _b = EncodingConstants.CHARACTER_CHUNK | EncodingConstants.CHARACTER_CHUNK_RESTRICTED_ALPHABET_FLAG | EncodingConstants.CHARACTER_CHUNK_ADD_TO_TABLE_FLAG;
        } else {
            // if char array is not in table and could not be added
            _b = EncodingConstants.CHARACTER_CHUNK | EncodingConstants.CHARACTER_CHUNK_RESTRICTED_ALPHABET_FLAG;
        }
    } else {
        _b = EncodingConstants.CHARACTER_CHUNK | EncodingConstants.CHARACTER_CHUNK_RESTRICTED_ALPHABET_FLAG;
    }

    write (_b);

    // Encode bottom 6 bits of enoding algorithm id
    _b = id << 2;

    encodeNonEmptyFourBitCharacterStringOnSeventhBit(table, ch, offset, length);
}
 
Example 6
Source File: VocabularyGenerator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void addToCharArrayTable(CharArray c) {
    if (_serializerVocabulary.characterContentChunk.obtainIndex(c.ch, c.start, c.length, false) == KeyIntMap.NOT_PRESENT) {
        _parserVocabulary.characterContentChunk.add(c.ch, c.length);
    }

    _v.characterContentChunks.add(c.toString());
}
 
Example 7
Source File: VocabularyGenerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void addToTable(String s, Set v, StringIntMap m, PrefixArray a) {
    if (s.length() == 0) {
        return;
    }

    if (m.obtainIndex(s) == KeyIntMap.NOT_PRESENT) {
        a.add(s);
    }

    v.add(s);
}
 
Example 8
Source File: Encoder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Encode a non identifying string on the first bit of an octet.
 * Implementation of clause C.14 of ITU-T Rec. X.891 | ISO/IEC 24824-1.
 *
 * @param ch the array of characters.
 * @param offset the offset into the array of characters.
 * @param length the length of characters.
 * @param map the vocabulary table of character arrays to indexes.
 * @param addToTable true if the string should be added to the vocabulary
 *                   table (if not already present in the table).
 * @param clone true if the array of characters should be cloned if added
 *              to the vocabulary table.
 */
protected final void encodeNonIdentifyingStringOnFirstBit(char[] ch, int offset, int length, CharArrayIntMap map,
        boolean addToTable, boolean clone) throws IOException {
    if (length == 0) {
        // C.26 an index (first bit '1') with seven '1' bits for an empty string
        write(0xFF);
    } else {
        if (addToTable) {
            // if char array could be added to table
            boolean canAddCharacterContentToTable =
                    canAddCharacterContentToTable(length, map);

            // obtain/get index
            int index = canAddCharacterContentToTable ?
                map.obtainIndex(ch, offset, length, clone) :
                map.get(ch, offset, length);

            if (index != KeyIntMap.NOT_PRESENT) {
                // if char array is in table
                encodeNonZeroIntegerOnSecondBitFirstBitOne(index);
            } else if (canAddCharacterContentToTable) {
                // if char array is not in table, but could be added
                _b = EncodingConstants.NISTRING_ADD_TO_TABLE_FLAG |
                        _nonIdentifyingStringOnFirstBitCES;
                encodeNonEmptyCharacterStringOnFifthBit(ch, offset, length);
            } else {
                // if char array is not in table and could not be added
                _b = _nonIdentifyingStringOnFirstBitCES;
                encodeNonEmptyCharacterStringOnFifthBit(ch, offset, length);
            }
        } else {
            _b = _nonIdentifyingStringOnFirstBitCES;
            encodeNonEmptyCharacterStringOnFifthBit(ch, offset, length);
        }
    }
}
 
Example 9
Source File: SerializerVocabulary.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void addToNameTable(QName n, LocalNameQualifiedNamesMap m) {
    int namespaceURIIndex = -1;
    int prefixIndex = -1;
    if (n.getNamespaceURI().length() > 0) {
        namespaceURIIndex = namespaceName.obtainIndex(n.getNamespaceURI());
        if (namespaceURIIndex == KeyIntMap.NOT_PRESENT) {
            namespaceURIIndex = namespaceName.get(n.getNamespaceURI());
        }

        if (n.getPrefix().length() > 0) {
            prefixIndex = prefix.obtainIndex(n.getPrefix());
            if (prefixIndex == KeyIntMap.NOT_PRESENT) {
                prefixIndex = prefix.get(n.getPrefix());
            }
        }
    }

    int localNameIndex = localName.obtainIndex(n.getLocalPart());
    if (localNameIndex == KeyIntMap.NOT_PRESENT) {
        localNameIndex = localName.get(n.getLocalPart());
    }

    QualifiedName name = new QualifiedName(n.getPrefix(), n.getNamespaceURI(), n.getLocalPart(),
            m.getNextIndex(),
            prefixIndex, namespaceURIIndex, localNameIndex);

    LocalNameQualifiedNamesMap.Entry entry = null;
    if (_useLocalNameAsKey) {
        entry = m.obtainEntry(n.getLocalPart());
    } else {
        String qName = (prefixIndex == -1)
            ? n.getLocalPart()
            : n.getPrefix() + ":" + n.getLocalPart();
        entry = m.obtainEntry(qName);
    }

    entry.addQualifiedName(name);
}
 
Example 10
Source File: Encoder.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Encode a non identifying string on the third bit of an octet.
 * Implementation of clause C.15 of ITU-T Rec. X.891 | ISO/IEC 24824-1.
 *
 * @param ch the array of characters.
 * @param offset the offset into the array of characters.
 * @param length the length of characters.
 * @param map the vocabulary table of character arrays to indexes.
 * @param addToTable true if the array of characters should be added to the vocabulary
 *                   table (if not already present in the table).
 * @param clone true if the array of characters should be cloned if added
 *              to the vocabulary table.
 */
protected final void encodeNonIdentifyingStringOnThirdBit(char[] ch, int offset, int length,
        CharArrayIntMap map, boolean addToTable, boolean clone) throws IOException {
    // length cannot be zero since sequence of CIIs has to be > 0

    if (addToTable) {
        // if char array could be added to table
        boolean canAddCharacterContentToTable =
                canAddCharacterContentToTable(length, map);

        // obtain/get index
        int index = canAddCharacterContentToTable ?
            map.obtainIndex(ch, offset, length, clone) :
            map.get(ch, offset, length);

        if (index != KeyIntMap.NOT_PRESENT) {
            // if char array is in table
            _b = EncodingConstants.CHARACTER_CHUNK | 0x20;
            encodeNonZeroIntegerOnFourthBit(index);
        } else if (canAddCharacterContentToTable) {
            // if char array is not in table, but could be added
            _b = EncodingConstants.CHARACTER_CHUNK_ADD_TO_TABLE_FLAG |
                    _nonIdentifyingStringOnThirdBitCES;
            encodeNonEmptyCharacterStringOnSeventhBit(ch, offset, length);
        } else {
            // if char array is not in table and could not be added
                _b = _nonIdentifyingStringOnThirdBitCES;
                encodeNonEmptyCharacterStringOnSeventhBit(ch, offset, length);
        }
    } else {
        // char array will not be added to map
        _b = _nonIdentifyingStringOnThirdBitCES;
        encodeNonEmptyCharacterStringOnSeventhBit(ch, offset, length);
    }
}
 
Example 11
Source File: VocabularyGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void addToNameTable(String namespaceURI, String qName, String localName,
        Set v, LocalNameQualifiedNamesMap m, QualifiedNameArray a,
        boolean isAttribute) throws SAXException {
    LocalNameQualifiedNamesMap.Entry entry = m.obtainEntry(qName);
    if (entry._valueIndex > 0) {
        QualifiedName[] names = entry._value;
        for (int i = 0; i < entry._valueIndex; i++) {
            if ((namespaceURI == names[i].namespaceName || namespaceURI.equals(names[i].namespaceName))) {
                return;
            }
        }
    }

    String prefix = getPrefixFromQualifiedName(qName);

    int namespaceURIIndex = -1;
    int prefixIndex = -1;
    int localNameIndex = -1;
    if (namespaceURI.length() > 0) {
        namespaceURIIndex = _serializerVocabulary.namespaceName.get(namespaceURI);
        if (namespaceURIIndex == KeyIntMap.NOT_PRESENT) {
            throw new SAXException(CommonResourceBundle.getInstance().
                    getString("message.namespaceURINotIndexed", new Object[]{Integer.valueOf(namespaceURIIndex)}));
        }

        if (prefix.length() > 0) {
            prefixIndex = _serializerVocabulary.prefix.get(prefix);
            if (prefixIndex == KeyIntMap.NOT_PRESENT) {
                throw new SAXException(CommonResourceBundle.getInstance().
                        getString("message.prefixNotIndexed", new Object[]{Integer.valueOf(prefixIndex)}));
            }
        }
    }

    localNameIndex = _serializerVocabulary.localName.obtainIndex(localName);
    if (localNameIndex == KeyIntMap.NOT_PRESENT) {
        _parserVocabulary.localName.add(localName);
        localNameIndex = _parserVocabulary.localName.getSize() - 1;
    }
    QualifiedName name = new QualifiedName(prefix, namespaceURI, localName, m.getNextIndex(),
            prefixIndex, namespaceURIIndex, localNameIndex);
    if (isAttribute) {
        name.createAttributeValues(DuplicateAttributeVerifier.MAP_SIZE);
    }
    entry.addQualifiedName(name);
    a.add(name);

    v.add(name.getQName());
}
 
Example 12
Source File: Encoder.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Encode a literal qualified name of an Attribute Informaiton Item on the
 * third bit of an octet.
 * Implementation of clause C.17 of ITU-T Rec. X.891 | ISO/IEC 24824-1.
 *
 * @param namespaceURI the namespace URI of the qualified name.
 * @param prefix the prefix of the qualified name.
 * @param localName the local name of the qualified name.
 */
protected final boolean encodeLiteralAttributeQualifiedNameOnSecondBit(String namespaceURI, String prefix, String localName,
            LocalNameQualifiedNamesMap.Entry entry) throws IOException {
    int namespaceURIIndex = KeyIntMap.NOT_PRESENT;
    int prefixIndex = KeyIntMap.NOT_PRESENT;
    if (namespaceURI.length() > 0) {
        namespaceURIIndex = _v.namespaceName.get(namespaceURI);
        if (namespaceURIIndex == KeyIntMap.NOT_PRESENT) {
            if (namespaceURI == EncodingConstants.XMLNS_NAMESPACE_NAME ||
                    namespaceURI.equals(EncodingConstants.XMLNS_NAMESPACE_NAME)) {
                return false;
            } else {
                throw new IOException(CommonResourceBundle.getInstance().getString("message.namespaceURINotIndexed", new Object[]{namespaceURI}));
            }
        }

        if (prefix.length() > 0) {
            prefixIndex = _v.prefix.get(prefix);
            if (prefixIndex == KeyIntMap.NOT_PRESENT) {
                throw new IOException(CommonResourceBundle.getInstance().getString("message.prefixNotIndexed", new Object[]{prefix}));
            }
        }
    }

    int localNameIndex = _v.localName.obtainIndex(localName);

    QualifiedName name = new QualifiedName(prefix, namespaceURI, localName, "", _v.attributeName.getNextIndex());
    entry.addQualifiedName(name);

    _b = EncodingConstants.ATTRIBUTE_LITERAL_QNAME_FLAG;
    if (namespaceURI.length() > 0) {
        _b |= EncodingConstants.LITERAL_QNAME_NAMESPACE_NAME_FLAG;
        if (prefix.length() > 0) {
            _b |= EncodingConstants.LITERAL_QNAME_PREFIX_FLAG;
        }
    }

    write(_b);

    if (namespaceURIIndex >= 0) {
        if (prefixIndex >= 0) {
            encodeNonZeroIntegerOnSecondBitFirstBitOne(prefixIndex);
        }
        encodeNonZeroIntegerOnSecondBitFirstBitOne(namespaceURIIndex);
    } else if (namespaceURI != "") {
        // XML prefix and namespace name
        encodeNonEmptyOctetStringOnSecondBit("xml");
        encodeNonEmptyOctetStringOnSecondBit("http://www.w3.org/XML/1998/namespace");
    }

    if (localNameIndex >= 0) {
        encodeNonZeroIntegerOnSecondBitFirstBitOne(localNameIndex);
    } else {
        encodeNonEmptyOctetStringOnSecondBit(localName);
    }

    return true;
}
 
Example 13
Source File: Encoder.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Encode a chunk of Character Information Items using a restricted
 * alphabet table.
 *
 * @param alphabet the alphabet defining the mapping between characters and
 *        integer values.
 * @param ch the array of characters.
 * @param offset the offset into the array of characters.
 * @param length the length of characters.
 * @param addToTable if characters should be added to table
 * @throws ArrayIndexOutOfBoundsException.
 * @throws FastInfosetException if the alphabet is not present in the
 *         vocabulary.
 */
protected final void encodeAlphabetCharacters(String alphabet, char[] ch, int offset, int length,
        boolean addToTable) throws FastInfosetException, IOException {
    if (addToTable) {
        // if char array could be added to table
        boolean canAddCharacterContentToTable =
                canAddCharacterContentToTable(length, _v.characterContentChunk);

        // obtain/get index
        int index = canAddCharacterContentToTable ?
            _v.characterContentChunk.obtainIndex(ch, offset, length, true) :
            _v.characterContentChunk.get(ch, offset, length);

        if (index != KeyIntMap.NOT_PRESENT) {
            // if char array is in table
            _b = EncodingConstants.CHARACTER_CHUNK | 0x20;
            encodeNonZeroIntegerOnFourthBit(index);
            return;
        } else if (canAddCharacterContentToTable) {
            // if char array is not in table, but could be added
            _b = EncodingConstants.CHARACTER_CHUNK | EncodingConstants.CHARACTER_CHUNK_RESTRICTED_ALPHABET_FLAG | EncodingConstants.CHARACTER_CHUNK_ADD_TO_TABLE_FLAG;
        } else {
            // if char array is not in table and could not be added
            _b = EncodingConstants.CHARACTER_CHUNK | EncodingConstants.CHARACTER_CHUNK_RESTRICTED_ALPHABET_FLAG;
        }
    } else {
        _b = EncodingConstants.CHARACTER_CHUNK | EncodingConstants.CHARACTER_CHUNK_RESTRICTED_ALPHABET_FLAG;
    }

    int id = _v.restrictedAlphabet.get(alphabet);
    if (id == KeyIntMap.NOT_PRESENT) {
        throw new FastInfosetException(CommonResourceBundle.getInstance().getString("message.restrictedAlphabetNotPresent"));
    }
    id += EncodingConstants.RESTRICTED_ALPHABET_APPLICATION_START;

    _b |= (id & 0xC0) >> 6;
    write(_b);

    // Encode bottom 6 bits of enoding algorithm id
    _b = (id & 0x3F) << 2;

    encodeNonEmptyNBitCharacterStringOnSeventhBit(alphabet, ch, offset, length);
}
 
Example 14
Source File: Encoder.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Encode a chunk of Character Information Items using a restricted
 * alphabet table.
 *
 * @param alphabet the alphabet defining the mapping between characters and
 *        integer values.
 * @param ch the array of characters.
 * @param offset the offset into the array of characters.
 * @param length the length of characters.
 * @param addToTable if characters should be added to table
 * @throws ArrayIndexOutOfBoundsException.
 * @throws FastInfosetException if the alphabet is not present in the
 *         vocabulary.
 */
protected final void encodeAlphabetCharacters(String alphabet, char[] ch, int offset, int length,
        boolean addToTable) throws FastInfosetException, IOException {
    if (addToTable) {
        // if char array could be added to table
        boolean canAddCharacterContentToTable =
                canAddCharacterContentToTable(length, _v.characterContentChunk);

        // obtain/get index
        int index = canAddCharacterContentToTable ?
            _v.characterContentChunk.obtainIndex(ch, offset, length, true) :
            _v.characterContentChunk.get(ch, offset, length);

        if (index != KeyIntMap.NOT_PRESENT) {
            // if char array is in table
            _b = EncodingConstants.CHARACTER_CHUNK | 0x20;
            encodeNonZeroIntegerOnFourthBit(index);
            return;
        } else if (canAddCharacterContentToTable) {
            // if char array is not in table, but could be added
            _b = EncodingConstants.CHARACTER_CHUNK | EncodingConstants.CHARACTER_CHUNK_RESTRICTED_ALPHABET_FLAG | EncodingConstants.CHARACTER_CHUNK_ADD_TO_TABLE_FLAG;
        } else {
            // if char array is not in table and could not be added
            _b = EncodingConstants.CHARACTER_CHUNK | EncodingConstants.CHARACTER_CHUNK_RESTRICTED_ALPHABET_FLAG;
        }
    } else {
        _b = EncodingConstants.CHARACTER_CHUNK | EncodingConstants.CHARACTER_CHUNK_RESTRICTED_ALPHABET_FLAG;
    }

    int id = _v.restrictedAlphabet.get(alphabet);
    if (id == KeyIntMap.NOT_PRESENT) {
        throw new FastInfosetException(CommonResourceBundle.getInstance().getString("message.restrictedAlphabetNotPresent"));
    }
    id += EncodingConstants.RESTRICTED_ALPHABET_APPLICATION_START;

    _b |= (id & 0xC0) >> 6;
    write(_b);

    // Encode bottom 6 bits of enoding algorithm id
    _b = (id & 0x3F) << 2;

    encodeNonEmptyNBitCharacterStringOnSeventhBit(alphabet, ch, offset, length);
}
 
Example 15
Source File: Encoder.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Encode a non identifying string on the third bit of an octet as binary
 * data using an encoding algorithm.
 * Implementation of clause C.15 of ITU-T Rec. X.891 | ISO/IEC 24824-1.
 *
 * @param URI the encoding algorithm URI. If the URI == null then the
 *            encoding algorithm identifier takes precendence.
 * @param id the encoding algorithm identifier.
 * @param d the data, as an array of bytes, to be encoded.
 * @param offset the offset into the array of bytes.
 * @param length the length of bytes.
 * @throws EncodingAlgorithmException if the encoding algorithm URI is not
 *         present in the vocabulary.
 */
protected final void encodeNonIdentifyingStringOnThirdBit(String URI, int id, byte[] d, int offset, int length) throws FastInfosetException, IOException {
    if (URI != null) {
        id = _v.encodingAlgorithm.get(URI);
        if (id == KeyIntMap.NOT_PRESENT) {
            throw new EncodingAlgorithmException(CommonResourceBundle.getInstance().getString("message.EncodingAlgorithmURI", new Object[]{URI}));
        }
        id += EncodingConstants.ENCODING_ALGORITHM_APPLICATION_START;
    }

    encodeCIIOctetAlgorithmData(id, d, offset, length);
}
 
Example 16
Source File: Encoder.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Encode a non identifying string on the third bit of an octet as binary
 * data using an encoding algorithm.
 * Implementation of clause C.15 of ITU-T Rec. X.891 | ISO/IEC 24824-1.
 *
 * @param URI the encoding algorithm URI. If the URI == null then the
 *            encoding algorithm identifier takes precendence.
 * @param id the encoding algorithm identifier.
 * @param d the data, as an array of bytes, to be encoded.
 * @param offset the offset into the array of bytes.
 * @param length the length of bytes.
 * @throws EncodingAlgorithmException if the encoding algorithm URI is not
 *         present in the vocabulary.
 */
protected final void encodeNonIdentifyingStringOnThirdBit(String URI, int id, byte[] d, int offset, int length) throws FastInfosetException, IOException {
    if (URI != null) {
        id = _v.encodingAlgorithm.get(URI);
        if (id == KeyIntMap.NOT_PRESENT) {
            throw new EncodingAlgorithmException(CommonResourceBundle.getInstance().getString("message.EncodingAlgorithmURI", new Object[]{URI}));
        }
        id += EncodingConstants.ENCODING_ALGORITHM_APPLICATION_START;
    }

    encodeCIIOctetAlgorithmData(id, d, offset, length);
}
 
Example 17
Source File: Encoder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Encode a non identifying string on the third bit of an octet as binary
 * data using an encoding algorithm.
 * Implementation of clause C.15 of ITU-T Rec. X.891 | ISO/IEC 24824-1.
 *
 * @param URI the encoding algorithm URI. If the URI == null then the
 *            encoding algorithm identifier takes precendence.
 * @param id the encoding algorithm identifier.
 * @param d the data, as an array of bytes, to be encoded.
 * @param offset the offset into the array of bytes.
 * @param length the length of bytes.
 * @throws EncodingAlgorithmException if the encoding algorithm URI is not
 *         present in the vocabulary.
 */
protected final void encodeNonIdentifyingStringOnThirdBit(String URI, int id, byte[] d, int offset, int length) throws FastInfosetException, IOException {
    if (URI != null) {
        id = _v.encodingAlgorithm.get(URI);
        if (id == KeyIntMap.NOT_PRESENT) {
            throw new EncodingAlgorithmException(CommonResourceBundle.getInstance().getString("message.EncodingAlgorithmURI", new Object[]{URI}));
        }
        id += EncodingConstants.ENCODING_ALGORITHM_APPLICATION_START;
    }

    encodeCIIOctetAlgorithmData(id, d, offset, length);
}
 
Example 18
Source File: Encoder.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Encode a non identifying string on the third bit of an octet as binary
 * data using an encoding algorithm.
 * Implementation of clause C.15 of ITU-T Rec. X.891 | ISO/IEC 24824-1.
 *
 * @param URI the encoding algorithm URI. If the URI == null then the
 *            encoding algorithm identifier takes precendence.
 * @param id the encoding algorithm identifier.
 * @param d the data, as an array of bytes, to be encoded.
 * @param offset the offset into the array of bytes.
 * @param length the length of bytes.
 * @throws EncodingAlgorithmException if the encoding algorithm URI is not
 *         present in the vocabulary.
 */
protected final void encodeNonIdentifyingStringOnThirdBit(String URI, int id, byte[] d, int offset, int length) throws FastInfosetException, IOException {
    if (URI != null) {
        id = _v.encodingAlgorithm.get(URI);
        if (id == KeyIntMap.NOT_PRESENT) {
            throw new EncodingAlgorithmException(CommonResourceBundle.getInstance().getString("message.EncodingAlgorithmURI", new Object[]{URI}));
        }
        id += EncodingConstants.ENCODING_ALGORITHM_APPLICATION_START;
    }

    encodeCIIOctetAlgorithmData(id, d, offset, length);
}
 
Example 19
Source File: Encoder.java    From jdk8u60 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Encode a non identifying string on the third bit of an octet as binary
 * data using an encoding algorithm.
 * Implementation of clause C.15 of ITU-T Rec. X.891 | ISO/IEC 24824-1.
 *
 * @param URI the encoding algorithm URI. If the URI == null then the
 *            encoding algorithm identifier takes precendence.
 * @param id the encoding algorithm identifier.
 * @param d the data, as an array of bytes, to be encoded.
 * @param offset the offset into the array of bytes.
 * @param length the length of bytes.
 * @throws EncodingAlgorithmException if the encoding algorithm URI is not
 *         present in the vocabulary.
 */
protected final void encodeNonIdentifyingStringOnThirdBit(String URI, int id, byte[] d, int offset, int length) throws FastInfosetException, IOException {
    if (URI != null) {
        id = _v.encodingAlgorithm.get(URI);
        if (id == KeyIntMap.NOT_PRESENT) {
            throw new EncodingAlgorithmException(CommonResourceBundle.getInstance().getString("message.EncodingAlgorithmURI", new Object[]{URI}));
        }
        id += EncodingConstants.ENCODING_ALGORITHM_APPLICATION_START;
    }

    encodeCIIOctetAlgorithmData(id, d, offset, length);
}
 
Example 20
Source File: Encoder.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Encode a non identifying string on the third bit of an octet as binary
 * data using an encoding algorithm.
 * Implementation of clause C.15 of ITU-T Rec. X.891 | ISO/IEC 24824-1.
 *
 * @param URI the encoding algorithm URI. If the URI == null then the
 *            encoding algorithm identifier takes precendence.
 * @param id the encoding algorithm identifier.
 * @param d the data, as an array of bytes, to be encoded.
 * @param offset the offset into the array of bytes.
 * @param length the length of bytes.
 * @throws EncodingAlgorithmException if the encoding algorithm URI is not
 *         present in the vocabulary.
 */
protected final void encodeNonIdentifyingStringOnThirdBit(String URI, int id, byte[] d, int offset, int length) throws FastInfosetException, IOException {
    if (URI != null) {
        id = _v.encodingAlgorithm.get(URI);
        if (id == KeyIntMap.NOT_PRESENT) {
            throw new EncodingAlgorithmException(CommonResourceBundle.getInstance().getString("message.EncodingAlgorithmURI", new Object[]{URI}));
        }
        id += EncodingConstants.ENCODING_ALGORITHM_APPLICATION_START;
    }

    encodeCIIOctetAlgorithmData(id, d, offset, length);
}