Package com.ibm.icu.impl

Examples of com.ibm.icu.impl.CharTrie$FriendAgent


                         checkRanges3.length);
    }
   
    public void TestCharValues()
    {
        CharTrie trie = null;
        try {
             trie = UCharacterProperty.getInstance().m_trie_;
        } catch (Exception e) {
            warnln("Error creating ucharacter trie");
            return;
        }
       
        for (int i = 0; i < 0xFFFF; i ++) {
            if (i < 0xFF
                && trie.getBMPValue((char)i)
                    != trie.getLatin1LinearValue((char)i)) {
                errln("For latin 1 codepoint, getBMPValue should be the same " +
                       "as getLatin1LinearValue");
            }
            if (trie.getBMPValue((char)i) != trie.getCodePointValue(i)) {
                errln("For BMP codepoint, getBMPValue should be the same " +
                       "as getCodepointValue");
            }
        }
        for (int i = 0x10000; i < 0x10ffff; i ++) {
            char lead = UTF16.getLeadSurrogate(i);
            char trail = UTF16.getTrailSurrogate(i);
            char value = trie.getCodePointValue(i);
            if (value != trie.getSurrogateValue(lead, trail) ||
                value != trie.getTrailValue(trie.getLeadValue(lead),
                                            trail)) {
                errln("For Non-BMP codepoints, getSurrogateValue should be "
                      + "the same s getCodepointValue and getTrailValue");
            }       
        }
View Full Code Here


            return -1; /* never get non-initialValue data for supplementary code points */
        }
    }

    public void TestDummyCharTrie() {
        CharTrie trie;
        final int initialValue=0x313, leadUnitValue=0xaffe;
        int value;
        int c;
        trie=new CharTrie(initialValue, leadUnitValue, new DummyGetFoldingOffset());

        /* test that all code points have initialValue */
        for(c=0; c<=0x10ffff; ++c) {
            value=trie.getCodePointValue(c);
            if(value!=initialValue) {
                errln("CharTrie/dummy.getCodePointValue(c)(U+"+hex(c)+")=0x"+hex(value)+" instead of 0x"+hex(initialValue));
            }
        }

        /* test that the lead surrogate code units have leadUnitValue */
        for(c=0xd800; c<=0xdbff; ++c) {
            value=trie.getLeadValue((char)c);
            if(value!=leadUnitValue) {
                errln("CharTrie/dummy.getLeadValue(c)(U+"+hex(c)+")=0x"+hex(value)+" instead of 0x"+hex(leadUnitValue));
            }
        }
    }
View Full Code Here

        //indexes[INDEX_MAPPING_DATA_SIZE] store the size of mappingData in bytes          
        mappingData = new char[indexes[INDEX_MAPPING_DATA_SIZE]/2];
        // load the rest of the data data and initialize the data members
        reader.read(sprepBytes,mappingData);
                                  
        sprepTrie = new CharTrie(new ByteArrayInputStream(sprepBytes), null);
             
        // get the data format version                          
        /*formatVersion = */reader.getDataFormatVersion();
        // get the options
View Full Code Here

        dis.mark(This.fHeader.fTrieLen+100);    // Mark position of start of TRIE in the input
                                                //  and tell Java to keep the mark valid so long
                                                //  as we don't go more than 100 bytes past the
                                                //  past the end of the TRIE.
   
        This.fTrie = new CharTrie(dis, fTrieFoldingFunc)// Deserialize the TRIE, leaving input
                                                //  stream at an unknown position, preceding the
                                                //  padding between TRIE and following section.
   
        dis.reset();                            // Move input stream back to marked position at
                                                //   the start of the serialized TRIE.  Now our
View Full Code Here

        fLastStatusIndexValid = true;
        fLastRuleStatusIndex  = 0;

        // caches for quicker access
        CharacterIterator text = fText;
        CharTrie trie = fRData.fTrie;

        // Set up the starting char
        int c               = text.current();
        if (c >= UTF16.LEAD_SURROGATE_MIN_VALUE) {
            c = nextTrail32(text, c);
            if (c == DONE32) {
                return BreakIterator.DONE;
            }
        }
        int initialPosition = text.getIndex();
        int result          = initialPosition;

        // Set the initial state for the state machine
        int state           = START_STATE;
        int row             = fRData.getRowIndex(state);
        short category      = 3;
        short flagsState    = stateTable[RBBIDataWrapper.FLAGS+1];
        int mode            = RBBI_RUN;
        if ((flagsState & RBBIDataWrapper.RBBI_BOF_REQUIRED) != 0) {
            category = 2;
            mode     = RBBI_START;
            if (TRACE) {
                System.out.print("            " +  RBBIDataWrapper.intToString(text.getIndex(), 5));
                System.out.print(RBBIDataWrapper.intToHexString(c, 10));
                System.out.println(RBBIDataWrapper.intToString(state,7) + RBBIDataWrapper.intToString(category,6));
            }
        }
        int lookaheadStatus = 0;
        int lookaheadTagIdx = 0;
        int lookaheadResult = 0;

        // loop until we reach the end of the text or transition to state 0
        while (state != STOP_STATE) {
            if (c == DONE32) {
                // Reached end of input string.
                if (mode == RBBI_END) {
                    // We have already run the loop one last time with the
                    // character set to the pseudo {eof} value. Now it is time
                    // to unconditionally bail out.

                    if (lookaheadResult > result) {
                        // We ran off the end of the string with a pending
                        // look-ahead match.
                        // Treat this as if the look-ahead condition had been
                        // met, and return
                        // the match at the / position from the look-ahead rule.
                        result = lookaheadResult;
                        fLastRuleStatusIndex = lookaheadTagIdx;
                    }
                    break;
                }
                // Run the loop one last time with the fake end-of-input character category
                mode = RBBI_END;
                category = 1;
            }
            else if (mode == RBBI_RUN) {
                // Get the char category.  An incoming category of 1 or 2 mens that
                //      we are preset for doing the beginning or end of input, and
                //      that we shouldn't get a category from an actual text input character.
                //

                // look up the current character's character category, which tells us
                // which column in the state table to look at.
                //
                category = (short) trie.getCodePointValue(c);
               
                // Check the dictionary bit in the character's category.
                //    Counter is only used by dictionary based iterators (subclasses).
                //    Chars that need to be handled by a dictionary have a flag bit set
                //    in their category values.
View Full Code Here

        //indexes[INDEX_MAPPING_DATA_SIZE] store the size of mappingData in bytes          
        mappingData = new char[indexes[INDEX_MAPPING_DATA_SIZE]/2];
        // load the rest of the data data and initialize the data members
        reader.read(sprepBytes,mappingData);
                                  
        sprepTrie = new CharTrie(new ByteArrayInputStream(sprepBytes), null);
             
        // get the data format version                          
        /*formatVersion = */reader.getDataFormatVersion();
        // get the options
View Full Code Here

        dis.mark(This.fHeader.fTrieLen+100);    // Mark position of start of TRIE in the input
                                                //  and tell Java to keep the mark valid so long
                                                //  as we don't go more than 100 bytes past the
                                                //  past the end of the TRIE.
   
        This.fTrie = new CharTrie(dis, fTrieFoldingFunc)// Deserialize the TRIE, leaving input
                                                //  stream at an unknown position, preceding the
                                                //  padding between TRIE and following section.
   
        dis.reset();                            // Move input stream back to marked position at
                                                //   the start of the serialized TRIE.  Now our
View Full Code Here

        //indexes[INDEX_MAPPING_DATA_SIZE] store the size of mappingData in bytes          
        mappingData = new char[indexes[INDEX_MAPPING_DATA_SIZE]/2];
        // load the rest of the data data and initialize the data members
        reader.read(sprepBytes,mappingData);
                                  
        sprepTrie = new CharTrie(new ByteArrayInputStream(sprepBytes), null);
             
        // get the data format version                          
        /*formatVersion = */reader.getDataFormatVersion();
        // get the options
View Full Code Here

        dis.mark(This.fHeader.fTrieLen+100);    // Mark position of start of TRIE in the input
                                                //  and tell Java to keep the mark valid so long
                                                //  as we don't go more than 100 bytes past the
                                                //  past the end of the TRIE.
   
        This.fTrie = new CharTrie(dis, fTrieFoldingFunc)// Deserialize the TRIE, leaving input
                                                //  stream at an unknown position, preceding the
                                                //  padding between TRIE and following section.
   
        dis.reset();                            // Move input stream back to marked position at
                                                //   the start of the serialized TRIE.  Now our
View Full Code Here

        //indexes[INDEX_MAPPING_DATA_SIZE] store the size of mappingData in bytes          
        mappingData = new char[indexes[INDEX_MAPPING_DATA_SIZE]/2];
        // load the rest of the data data and initialize the data members
        reader.read(sprepBytes,mappingData);
                                  
        sprepTrie = new CharTrie(new ByteArrayInputStream(sprepBytes), null);
             
        // get the data format version                          
        /*formatVersion = */reader.getDataFormatVersion();
        // get the options
View Full Code Here

TOP

Related Classes of com.ibm.icu.impl.CharTrie$FriendAgent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.