Package com.volantis.mcs.dissection.string

Examples of com.volantis.mcs.dissection.string.DissectableString


    }

    protected DissectableString createDissectableString(String string)
            throws Exception {
        WBSAXString wbsaxString = strings.create(string);
        DissectableString dstring = new DissectableWBSAXString(wbsaxString);
        return dstring;
    }
View Full Code Here


        }
    }
   
    protected void checkGetRangeCost(String string, int start,
            int[] expectedCosts) throws Exception {
        DissectableString dstring = checkCharacters(string);

        // check the cost for each character index
        int [] actualCosts = new int[expectedCosts.length];
        for (int i = 0; i < expectedCosts.length; i++) {
            actualCosts[i] = dstring.getRangeCost(start, start + i);
        }
        assertEquals(expectedCosts, actualCosts);
        // ensure the total matches if this is the entire string.
        if (start == 0) {
            assertEquals(expectedCosts[expectedCosts.length-1],
                    dstring.getCost());
        }
    }
View Full Code Here

        }
    }

    protected void checkGetCharacterIndex(String string, int start,
            int[] expectedIndexes) throws Exception {
        DissectableString dstring = checkCharacters(string);

        // check the character indexes for each cost
        int [] actualIndexes = new int[expectedIndexes.length];
        for (int i = 0; i < expectedIndexes.length; i++) {
            actualIndexes[i] = dstring.getCharacterIndex(start, i);
        }
        assertEquals(expectedIndexes, actualIndexes);
    }
View Full Code Here

        assertEquals(expectedIndexes, actualIndexes);
    }

    private DissectableString checkCharacters(String string)
            throws Exception {
        DissectableString dstring = createDissectableString(string);
        char[] chars = string.toCharArray();
       
        assertEquals(string.length(), dstring.getLength());
       
        // Check the chars
        int[] expectedChars = new int[chars.length];
        int[] actualChars = new int[chars.length];
        for (int i=0; i < string.length(); i++) {
            expectedChars[i] = chars[i];
            actualChars[i] = dstring.charAt(i);
        }
        assertEquals(expectedChars, actualChars);
        return dstring;
    }
View Full Code Here

    protected DissectableString createDissectableString(String string)
            throws Exception {
        WBSAXString wbsaxString = strings.create(string);
        DissectableWBSAXValueBuffer buffer = new DissectableWBSAXValueBuffer();
        buffer.append(wbsaxString);
        DissectableString dstring = new DissectableWBDOMCompositeString(buffer);
        return dstring;
    }
View Full Code Here

            throws DissectionException {

        // Lazily initialise the segmenter from the text / string when the
        // client code tries to dissect the text into the first shard.
        if (segmenter == null) {
            DissectableString string = document.getDissectableString(text);
            segmenter = new StringSegmenter(stringDissector, string);
        }

        // Handle the fact that when we first get called we haven't been
        // placed in a shard at all. Seems ugly that we have to do this...
View Full Code Here

TOP

Related Classes of com.volantis.mcs.dissection.string.DissectableString

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.