Package java.text

Examples of java.text.CollationElementIterator


     * @param s2 the contained string
     * @return true iff s1 contains s2
     */

    public boolean contains(String s1, String s2) {
        CollationElementIterator iter1 = collator.getCollationElementIterator(s1);
        CollationElementIterator iter2 = collator.getCollationElementIterator(s2);
        return collationContains(iter1, iter2, null, false);
    }
View Full Code Here


     * @param s2 the contained string
     * @return true iff s1 ends with s2
     */

    public boolean endsWith(String s1, String s2) {
        CollationElementIterator iter1 = collator.getCollationElementIterator(s1);
        CollationElementIterator iter2 = collator.getCollationElementIterator(s2);
        return collationContains(iter1, iter2, null, true);
    }
View Full Code Here

     * @param s2 the contained string
     * @return true iff s1 starts with s2
     */

    public boolean startsWith(String s1, String s2) {
        CollationElementIterator iter1 = collator.getCollationElementIterator(s1);
        CollationElementIterator iter2 = collator.getCollationElementIterator(s2);
        return collationStartsWith(iter1, iter2);
    }
View Full Code Here

     * @param s2 the contained string
     * @return the part of s1 that follows the first occurrence of s2
     */

    public String substringAfter(String s1, String s2) {
        CollationElementIterator iter1 = collator.getCollationElementIterator(s1);
        CollationElementIterator iter2 = collator.getCollationElementIterator(s2);
        int[] ia = new int[2];
        boolean ba = collationContains(iter1, iter2, ia, false);
        if (ba) {
            return s1.substring(ia[1]);
        } else {
View Full Code Here

     * @param s2 the contained string
     * @return the part of s1 that precedes the first occurrence of s2
     */

    public String substringBefore(String s1, String s2) {
        CollationElementIterator iter1 = collator.getCollationElementIterator(s1);
        CollationElementIterator iter2 = collator.getCollationElementIterator(s2);
        int[] ib = new int[2];
        boolean bb = collationContains(iter1, iter2, ib, false);
        if (bb) {
            return s1.substring(0, ib[0]);
        } else {
View Full Code Here

    public static void main(String[] args) {
        Configuration config = new Configuration();
        StringCollator collator = StandardCollationURIResolver.getInstance().resolve(args[0], args[0], config);
        FastStringBuffer sb = new FastStringBuffer(100);
        if (collator instanceof RuleBasedCollator) {
            CollationElementIterator iter = ((RuleBasedCollator)collator).getCollationElementIterator(args[1]);
            while (true) {
                int e = iter.next();
                if (e==-1) {
                    break;
                }
                sb.append(e+" ");
            }
View Full Code Here

    public final static boolean startsWith(Collator collator, String s1, String s2) {
        if (collator == null)
            {return s1.startsWith(s2);}
        else {
            final RuleBasedCollator rbc = (RuleBasedCollator) collator;
            final CollationElementIterator i1 = rbc.getCollationElementIterator(s1);
            final CollationElementIterator i2 = rbc.getCollationElementIterator(s2);
            return collationStartsWith(i1, i2);
        }
    }
View Full Code Here

    public final static boolean endsWith(Collator collator, String s1, String s2) {
        if (collator == null)
            {return s1.endsWith(s2);}
        else {
            final RuleBasedCollator rbc = (RuleBasedCollator) collator;
            final CollationElementIterator i1 = rbc.getCollationElementIterator(s1);
            final CollationElementIterator i2 = rbc.getCollationElementIterator(s2);
            return collationContains(i1, i2, null, true);
        }
    }
View Full Code Here

    public final static boolean contains(Collator collator, String s1, String s2) {
        if (collator == null)
            {return s1.indexOf(s2) != Constants.STRING_NOT_FOUND;}
        else {
            final RuleBasedCollator rbc = (RuleBasedCollator) collator;
            final CollationElementIterator i1 = rbc.getCollationElementIterator(s1);
            final CollationElementIterator i2 = rbc.getCollationElementIterator(s2);
            return collationContains(i1, i2, null, false);
        }
    }
View Full Code Here

        if (collator == null)
            {return s1.indexOf(s2);}
        else {
            final int offsets[] = new int[2];
            final RuleBasedCollator rbc = (RuleBasedCollator) collator;
            final CollationElementIterator i1 = rbc.getCollationElementIterator(s1);
            final CollationElementIterator i2 = rbc.getCollationElementIterator(s2);          
            if (collationContains(i1, i2, offsets, false))
                {return offsets[0];}
            else
                {return Constants.STRING_NOT_FOUND;}
        }
View Full Code Here

TOP

Related Classes of java.text.CollationElementIterator

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.