com.sun.xml.internal.fastinfoset.util.CharArrayIntMap Java Examples

The following examples show how to use com.sun.xml.internal.fastinfoset.util.CharArrayIntMap. 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 hottub with GNU General Public License v2.0 5 votes vote down vote up
public SerializerVocabulary() {
    tables[RESTRICTED_ALPHABET] = restrictedAlphabet = new StringIntMap(4);
    tables[ENCODING_ALGORITHM] = encodingAlgorithm = new StringIntMap(4);
    tables[PREFIX] = prefix = new FixedEntryStringIntMap(EncodingConstants.XML_NAMESPACE_PREFIX, 8);
    tables[NAMESPACE_NAME] = namespaceName = new FixedEntryStringIntMap(EncodingConstants.XML_NAMESPACE_NAME, 8);
    tables[LOCAL_NAME] = localName = new StringIntMap();
    tables[OTHER_NCNAME] = otherNCName = new StringIntMap(4);
    tables[OTHER_URI] = otherURI = new StringIntMap(4);
    tables[ATTRIBUTE_VALUE] = attributeValue = new StringIntMap();
    tables[OTHER_STRING] = otherString = new CharArrayIntMap(4);
    tables[CHARACTER_CONTENT_CHUNK] = characterContentChunk = new CharArrayIntMap();
    tables[ELEMENT_NAME] = elementName = new LocalNameQualifiedNamesMap();
    tables[ATTRIBUTE_NAME] = attributeName = new LocalNameQualifiedNamesMap();
}
 
Example #2
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 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 #3
Source File: SerializerVocabulary.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public SerializerVocabulary() {
    tables[RESTRICTED_ALPHABET] = restrictedAlphabet = new StringIntMap(4);
    tables[ENCODING_ALGORITHM] = encodingAlgorithm = new StringIntMap(4);
    tables[PREFIX] = prefix = new FixedEntryStringIntMap(EncodingConstants.XML_NAMESPACE_PREFIX, 8);
    tables[NAMESPACE_NAME] = namespaceName = new FixedEntryStringIntMap(EncodingConstants.XML_NAMESPACE_NAME, 8);
    tables[LOCAL_NAME] = localName = new StringIntMap();
    tables[OTHER_NCNAME] = otherNCName = new StringIntMap(4);
    tables[OTHER_URI] = otherURI = new StringIntMap(4);
    tables[ATTRIBUTE_VALUE] = attributeValue = new StringIntMap();
    tables[OTHER_STRING] = otherString = new CharArrayIntMap(4);
    tables[CHARACTER_CONTENT_CHUNK] = characterContentChunk = new CharArrayIntMap();
    tables[ELEMENT_NAME] = elementName = new LocalNameQualifiedNamesMap();
    tables[ATTRIBUTE_NAME] = attributeName = new LocalNameQualifiedNamesMap();
}
 
Example #4
Source File: SerializerVocabulary.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private void addToTable(String s, CharArrayIntMap m) {
    if (s.length() == 0) {
        return;
    }

    char[] c = s.toCharArray();
    m.obtainIndex(c, 0, c.length, false);
}
 
Example #5
Source File: Encoder.java    From openjdk-jdk9 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 #6
Source File: Encoder.java    From openjdk-jdk9 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 #7
Source File: SerializerVocabulary.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public SerializerVocabulary() {
    tables[RESTRICTED_ALPHABET] = restrictedAlphabet = new StringIntMap(4);
    tables[ENCODING_ALGORITHM] = encodingAlgorithm = new StringIntMap(4);
    tables[PREFIX] = prefix = new FixedEntryStringIntMap(EncodingConstants.XML_NAMESPACE_PREFIX, 8);
    tables[NAMESPACE_NAME] = namespaceName = new FixedEntryStringIntMap(EncodingConstants.XML_NAMESPACE_NAME, 8);
    tables[LOCAL_NAME] = localName = new StringIntMap();
    tables[OTHER_NCNAME] = otherNCName = new StringIntMap(4);
    tables[OTHER_URI] = otherURI = new StringIntMap(4);
    tables[ATTRIBUTE_VALUE] = attributeValue = new StringIntMap();
    tables[OTHER_STRING] = otherString = new CharArrayIntMap(4);
    tables[CHARACTER_CONTENT_CHUNK] = characterContentChunk = new CharArrayIntMap();
    tables[ELEMENT_NAME] = elementName = new LocalNameQualifiedNamesMap();
    tables[ATTRIBUTE_NAME] = attributeName = new LocalNameQualifiedNamesMap();
}
 
Example #8
Source File: SerializerVocabulary.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void addToTable(String s, CharArrayIntMap m) {
    if (s.length() == 0) {
        return;
    }

    char[] c = s.toCharArray();
    m.obtainIndex(c, 0, c.length, false);
}
 
Example #9
Source File: Encoder.java    From hottub 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 #10
Source File: Encoder.java    From hottub 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: 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 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 #12
Source File: SerializerVocabulary.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void addToTable(String s, CharArrayIntMap m) {
    if (s.length() == 0) {
        return;
    }

    char[] c = s.toCharArray();
    m.obtainIndex(c, 0, c.length, false);
}
 
Example #13
Source File: Encoder.java    From openjdk-8-source 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 #14
Source File: Encoder.java    From openjdk-8-source 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 #15
Source File: SerializerVocabulary.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public SerializerVocabulary() {
    tables[RESTRICTED_ALPHABET] = restrictedAlphabet = new StringIntMap(4);
    tables[ENCODING_ALGORITHM] = encodingAlgorithm = new StringIntMap(4);
    tables[PREFIX] = prefix = new FixedEntryStringIntMap(EncodingConstants.XML_NAMESPACE_PREFIX, 8);
    tables[NAMESPACE_NAME] = namespaceName = new FixedEntryStringIntMap(EncodingConstants.XML_NAMESPACE_NAME, 8);
    tables[LOCAL_NAME] = localName = new StringIntMap();
    tables[OTHER_NCNAME] = otherNCName = new StringIntMap(4);
    tables[OTHER_URI] = otherURI = new StringIntMap(4);
    tables[ATTRIBUTE_VALUE] = attributeValue = new StringIntMap();
    tables[OTHER_STRING] = otherString = new CharArrayIntMap(4);
    tables[CHARACTER_CONTENT_CHUNK] = characterContentChunk = new CharArrayIntMap();
    tables[ELEMENT_NAME] = elementName = new LocalNameQualifiedNamesMap();
    tables[ATTRIBUTE_NAME] = attributeName = new LocalNameQualifiedNamesMap();
}
 
Example #16
Source File: SerializerVocabulary.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void addToTable(String s, CharArrayIntMap m) {
    if (s.length() == 0) {
        return;
    }

    char[] c = s.toCharArray();
    m.obtainIndex(c, 0, c.length, false);
}
 
Example #17
Source File: Encoder.java    From openjdk-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 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 #18
Source File: Encoder.java    From openjdk-8 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 #19
Source File: SerializerVocabulary.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public SerializerVocabulary() {
    tables[RESTRICTED_ALPHABET] = restrictedAlphabet = new StringIntMap(4);
    tables[ENCODING_ALGORITHM] = encodingAlgorithm = new StringIntMap(4);
    tables[PREFIX] = prefix = new FixedEntryStringIntMap(EncodingConstants.XML_NAMESPACE_PREFIX, 8);
    tables[NAMESPACE_NAME] = namespaceName = new FixedEntryStringIntMap(EncodingConstants.XML_NAMESPACE_NAME, 8);
    tables[LOCAL_NAME] = localName = new StringIntMap();
    tables[OTHER_NCNAME] = otherNCName = new StringIntMap(4);
    tables[OTHER_URI] = otherURI = new StringIntMap(4);
    tables[ATTRIBUTE_VALUE] = attributeValue = new StringIntMap();
    tables[OTHER_STRING] = otherString = new CharArrayIntMap(4);
    tables[CHARACTER_CONTENT_CHUNK] = characterContentChunk = new CharArrayIntMap();
    tables[ELEMENT_NAME] = elementName = new LocalNameQualifiedNamesMap();
    tables[ATTRIBUTE_NAME] = attributeName = new LocalNameQualifiedNamesMap();
}
 
Example #20
Source File: SerializerVocabulary.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void addToTable(String s, CharArrayIntMap m) {
    if (s.length() == 0) {
        return;
    }

    char[] c = s.toCharArray();
    m.obtainIndex(c, 0, c.length, false);
}
 
Example #21
Source File: SerializerVocabulary.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public SerializerVocabulary() {
    tables[RESTRICTED_ALPHABET] = restrictedAlphabet = new StringIntMap(4);
    tables[ENCODING_ALGORITHM] = encodingAlgorithm = new StringIntMap(4);
    tables[PREFIX] = prefix = new FixedEntryStringIntMap(EncodingConstants.XML_NAMESPACE_PREFIX, 8);
    tables[NAMESPACE_NAME] = namespaceName = new FixedEntryStringIntMap(EncodingConstants.XML_NAMESPACE_NAME, 8);
    tables[LOCAL_NAME] = localName = new StringIntMap();
    tables[OTHER_NCNAME] = otherNCName = new StringIntMap(4);
    tables[OTHER_URI] = otherURI = new StringIntMap(4);
    tables[ATTRIBUTE_VALUE] = attributeValue = new StringIntMap();
    tables[OTHER_STRING] = otherString = new CharArrayIntMap(4);
    tables[CHARACTER_CONTENT_CHUNK] = characterContentChunk = new CharArrayIntMap();
    tables[ELEMENT_NAME] = elementName = new LocalNameQualifiedNamesMap();
    tables[ATTRIBUTE_NAME] = attributeName = new LocalNameQualifiedNamesMap();
}
 
Example #22
Source File: SerializerVocabulary.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void addToTable(String s, CharArrayIntMap m) {
    if (s.length() == 0) {
        return;
    }

    char[] c = s.toCharArray();
    m.obtainIndex(c, 0, c.length, false);
}
 
Example #23
Source File: Encoder.java    From jdk8u60 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 #24
Source File: Encoder.java    From jdk8u60 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 #25
Source File: SerializerVocabulary.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public SerializerVocabulary() {
    tables[RESTRICTED_ALPHABET] = restrictedAlphabet = new StringIntMap(4);
    tables[ENCODING_ALGORITHM] = encodingAlgorithm = new StringIntMap(4);
    tables[PREFIX] = prefix = new FixedEntryStringIntMap(EncodingConstants.XML_NAMESPACE_PREFIX, 8);
    tables[NAMESPACE_NAME] = namespaceName = new FixedEntryStringIntMap(EncodingConstants.XML_NAMESPACE_NAME, 8);
    tables[LOCAL_NAME] = localName = new StringIntMap();
    tables[OTHER_NCNAME] = otherNCName = new StringIntMap(4);
    tables[OTHER_URI] = otherURI = new StringIntMap(4);
    tables[ATTRIBUTE_VALUE] = attributeValue = new StringIntMap();
    tables[OTHER_STRING] = otherString = new CharArrayIntMap(4);
    tables[CHARACTER_CONTENT_CHUNK] = characterContentChunk = new CharArrayIntMap();
    tables[ELEMENT_NAME] = elementName = new LocalNameQualifiedNamesMap();
    tables[ATTRIBUTE_NAME] = attributeName = new LocalNameQualifiedNamesMap();
}
 
Example #26
Source File: SerializerVocabulary.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private void addToTable(String s, CharArrayIntMap m) {
    if (s.length() == 0) {
        return;
    }

    char[] c = s.toCharArray();
    m.obtainIndex(c, 0, c.length, false);
}
 
Example #27
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 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 #28
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 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 #29
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 #30
Source File: SerializerVocabulary.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public SerializerVocabulary() {
    tables[RESTRICTED_ALPHABET] = restrictedAlphabet = new StringIntMap(4);
    tables[ENCODING_ALGORITHM] = encodingAlgorithm = new StringIntMap(4);
    tables[PREFIX] = prefix = new FixedEntryStringIntMap(EncodingConstants.XML_NAMESPACE_PREFIX, 8);
    tables[NAMESPACE_NAME] = namespaceName = new FixedEntryStringIntMap(EncodingConstants.XML_NAMESPACE_NAME, 8);
    tables[LOCAL_NAME] = localName = new StringIntMap();
    tables[OTHER_NCNAME] = otherNCName = new StringIntMap(4);
    tables[OTHER_URI] = otherURI = new StringIntMap(4);
    tables[ATTRIBUTE_VALUE] = attributeValue = new StringIntMap();
    tables[OTHER_STRING] = otherString = new CharArrayIntMap(4);
    tables[CHARACTER_CONTENT_CHUNK] = characterContentChunk = new CharArrayIntMap();
    tables[ELEMENT_NAME] = elementName = new LocalNameQualifiedNamesMap();
    tables[ATTRIBUTE_NAME] = attributeName = new LocalNameQualifiedNamesMap();
}