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

The following examples show how to use com.sun.xml.internal.fastinfoset.util.KeyIntMap. 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-jdk8u 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 TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void addToTable(String s, Set v, StringIntMap m, StringArray a) {
    if (s.length() == 0) {
        return;
    }

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

    v.add(s);
}
 
Example #3
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 #4
Source File: ParserVocabulary.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void addToNameTable(QName n, QualifiedNameArray a,
        boolean isAttribute,
        StringIntMap prefixMap, StringIntMap namespaceNameMap,
        StringIntMap localNameMap) {
    int namespaceURIIndex = -1;
    int prefixIndex = -1;
    if (n.getNamespaceURI().length() > 0) {
        namespaceURIIndex = namespaceNameMap.obtainIndex(n.getNamespaceURI());
        if (namespaceURIIndex == KeyIntMap.NOT_PRESENT) {
            namespaceURIIndex = namespaceName.getSize();
            namespaceName.add(n.getNamespaceURI());
        }

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

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

    QualifiedName name = new QualifiedName(n.getPrefix(), n.getNamespaceURI(), n.getLocalPart(),
            a.getSize(),
            prefixIndex, namespaceURIIndex, localNameIndex);
    if (isAttribute) {
        name.createAttributeValues(DuplicateAttributeVerifier.MAP_SIZE);
    }
    a.add(name);
}
 
Example #5
Source File: VocabularyGenerator.java    From jdk8u60 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 #6
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 #7
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 #8
Source File: SerializerVocabulary.java    From openjdk-jdk9 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 #9
Source File: ParserVocabulary.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void addToNameTable(QName n, QualifiedNameArray a,
        boolean isAttribute,
        StringIntMap prefixMap, StringIntMap namespaceNameMap,
        StringIntMap localNameMap) {
    int namespaceURIIndex = -1;
    int prefixIndex = -1;
    if (n.getNamespaceURI().length() > 0) {
        namespaceURIIndex = namespaceNameMap.obtainIndex(n.getNamespaceURI());
        if (namespaceURIIndex == KeyIntMap.NOT_PRESENT) {
            namespaceURIIndex = namespaceName.getSize();
            namespaceName.add(n.getNamespaceURI());
        }

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

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

    QualifiedName name = new QualifiedName(n.getPrefix(), n.getNamespaceURI(), n.getLocalPart(),
            a.getSize(),
            prefixIndex, namespaceURIIndex, localNameIndex);
    if (isAttribute) {
        name.createAttributeValues(DuplicateAttributeVerifier.MAP_SIZE);
    }
    a.add(name);
}
 
Example #10
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 #11
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 #12
Source File: VocabularyGenerator.java    From openjdk-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 #13
Source File: Encoder.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Encode a non empty identifying string on the first bit of an octet.
 * Implementation of clause C.13 of ITU-T Rec. X.891 | ISO/IEC 24824-1.
 *
 * @param s the identifying string.
 * @param map the vocabulary table to use to determin the index of the
 *        identifying string
 */
protected final void encodeIdentifyingNonEmptyStringOnFirstBit(String s, StringIntMap map) throws IOException {
    int index = map.obtainIndex(s);
    if (index == KeyIntMap.NOT_PRESENT) {
        // _b = 0;
        encodeNonEmptyOctetStringOnSecondBit(s);
    } else {
        // _b = 0x80;
        encodeNonZeroIntegerOnSecondBitFirstBitOne(index);
    }
}
 
Example #14
Source File: Encoder.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Encode a non empty identifying string on the first bit of an octet.
 * Implementation of clause C.13 of ITU-T Rec. X.891 | ISO/IEC 24824-1.
 *
 * @param s the identifying string.
 * @param map the vocabulary table to use to determin the index of the
 *        identifying string
 */
protected final void encodeIdentifyingNonEmptyStringOnFirstBit(String s, StringIntMap map) throws IOException {
    int index = map.obtainIndex(s);
    if (index == KeyIntMap.NOT_PRESENT) {
        // _b = 0;
        encodeNonEmptyOctetStringOnSecondBit(s);
    } else {
        // _b = 0x80;
        encodeNonZeroIntegerOnSecondBitFirstBitOne(index);
    }
}
 
Example #15
Source File: ParserVocabulary.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void addToNameTable(QName n, QualifiedNameArray a,
        boolean isAttribute,
        StringIntMap prefixMap, StringIntMap namespaceNameMap,
        StringIntMap localNameMap) {
    int namespaceURIIndex = -1;
    int prefixIndex = -1;
    if (n.getNamespaceURI().length() > 0) {
        namespaceURIIndex = namespaceNameMap.obtainIndex(n.getNamespaceURI());
        if (namespaceURIIndex == KeyIntMap.NOT_PRESENT) {
            namespaceURIIndex = namespaceName.getSize();
            namespaceName.add(n.getNamespaceURI());
        }

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

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

    QualifiedName name = new QualifiedName(n.getPrefix(), n.getNamespaceURI(), n.getLocalPart(),
            a.getSize(),
            prefixIndex, namespaceURIIndex, localNameIndex);
    if (isAttribute) {
        name.createAttributeValues(DuplicateAttributeVerifier.MAP_SIZE);
    }
    a.add(name);
}
 
Example #16
Source File: VocabularyGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void addToTable(String s, Set v, StringIntMap m, StringArray a) {
    if (s.length() == 0) {
        return;
    }

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

    v.add(s);
}
 
Example #17
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 #18
Source File: VocabularyGenerator.java    From openjdk-jdk8u 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 #19
Source File: VocabularyGenerator.java    From openjdk-jdk8u 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 #20
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 #21
Source File: ParserVocabulary.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void addToNameTable(QName n, QualifiedNameArray a,
        boolean isAttribute,
        StringIntMap prefixMap, StringIntMap namespaceNameMap,
        StringIntMap localNameMap) {
    int namespaceURIIndex = -1;
    int prefixIndex = -1;
    if (n.getNamespaceURI().length() > 0) {
        namespaceURIIndex = namespaceNameMap.obtainIndex(n.getNamespaceURI());
        if (namespaceURIIndex == KeyIntMap.NOT_PRESENT) {
            namespaceURIIndex = namespaceName.getSize();
            namespaceName.add(n.getNamespaceURI());
        }

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

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

    QualifiedName name = new QualifiedName(n.getPrefix(), n.getNamespaceURI(), n.getLocalPart(),
            a.getSize(),
            prefixIndex, namespaceURIIndex, localNameIndex);
    if (isAttribute) {
        name.createAttributeValues(DuplicateAttributeVerifier.MAP_SIZE);
    }
    a.add(name);
}
 
Example #22
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 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 #23
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 #24
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 #25
Source File: Encoder.java    From openjdk-jdk9 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 #26
Source File: ParserVocabulary.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void addToNameTable(QName n, QualifiedNameArray a,
        boolean isAttribute,
        StringIntMap prefixMap, StringIntMap namespaceNameMap,
        StringIntMap localNameMap) {
    int namespaceURIIndex = -1;
    int prefixIndex = -1;
    if (n.getNamespaceURI().length() > 0) {
        namespaceURIIndex = namespaceNameMap.obtainIndex(n.getNamespaceURI());
        if (namespaceURIIndex == KeyIntMap.NOT_PRESENT) {
            namespaceURIIndex = namespaceName.getSize();
            namespaceName.add(n.getNamespaceURI());
        }

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

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

    QualifiedName name = new QualifiedName(n.getPrefix(), n.getNamespaceURI(), n.getLocalPart(),
            a.getSize(),
            prefixIndex, namespaceURIIndex, localNameIndex);
    if (isAttribute) {
        name.createAttributeValues(DuplicateAttributeVerifier.MAP_SIZE);
    }
    a.add(name);
}
 
Example #27
Source File: ParserVocabulary.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private void addToNameTable(QName n, QualifiedNameArray a,
        boolean isAttribute,
        StringIntMap prefixMap, StringIntMap namespaceNameMap,
        StringIntMap localNameMap) {
    int namespaceURIIndex = -1;
    int prefixIndex = -1;
    if (n.getNamespaceURI().length() > 0) {
        namespaceURIIndex = namespaceNameMap.obtainIndex(n.getNamespaceURI());
        if (namespaceURIIndex == KeyIntMap.NOT_PRESENT) {
            namespaceURIIndex = namespaceName.getSize();
            namespaceName.add(n.getNamespaceURI());
        }

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

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

    QualifiedName name = new QualifiedName(n.getPrefix(), n.getNamespaceURI(), n.getLocalPart(),
            a.getSize(),
            prefixIndex, namespaceURIIndex, localNameIndex);
    if (isAttribute) {
        name.createAttributeValues(DuplicateAttributeVerifier.MAP_SIZE);
    }
    a.add(name);
}
 
Example #28
Source File: SerializerVocabulary.java    From openjdk-jdk8u-backup 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 #29
Source File: VocabularyGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void addToTable(String s, Set v, StringIntMap m, StringArray a) {
    if (s.length() == 0) {
        return;
    }

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

    v.add(s);
}
 
Example #30
Source File: VocabularyGenerator.java    From openjdk-jdk8u-backup 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());
}