Java Code Examples for java.text.CollationElementIterator

The following examples show how to use java.text.CollationElementIterator. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: jdk1.8-source-analysis   Source File: StringComparable.java    License: Apache License 2.0 4 votes vote down vote up
private final int[] getFirstCaseDiff(final String text, final String pattern, final Locale locale){

        final CollationElementIterator targIter = m_collator.getCollationElementIterator(text);
        final CollationElementIterator patIter = m_collator.getCollationElementIterator(pattern);
        int startTarg = -1;
        int endTarg = -1;
        int startPatt = -1;
        int endPatt = -1;
        final int done = getElement(CollationElementIterator.NULLORDER);
        int patternElement = 0, targetElement = 0;
        boolean getPattern = true, getTarget = true;

        while (true) {
            if (getPattern){
                 startPatt = patIter.getOffset();
                 patternElement = getElement(patIter.next());
                 endPatt = patIter.getOffset();
            }
            if ((getTarget)){
                 startTarg  = targIter.getOffset();
                 targetElement   = getElement(targIter.next());
                 endTarg  = targIter.getOffset();
            }
            getTarget = getPattern = true;
            if ((patternElement == done) ||( targetElement == done)) {
                return null;
            } else if (targetElement == 0) {
              getPattern = false;
            } else if (patternElement == 0) {
              getTarget = false;
            } else if (targetElement != patternElement) {// mismatch
                if((startPatt < endPatt) && (startTarg < endTarg)){
                    final String  subText = text.substring(startTarg, endTarg);
                    final String  subPatt = pattern.substring(startPatt, endPatt);
                    final String  subTextUp = subText.toUpperCase(locale);
                    final String  subPattUp = subPatt.toUpperCase(locale);
                    if(m_collator.compare(subTextUp, subPattUp) != 0){ // not case diffference
                        continue;
                    }

                    int diff[] = {UNKNOWN_CASE, UNKNOWN_CASE};
                    if(m_collator.compare(subText, subTextUp) == 0){
                        diff[0] = UPPER_CASE;
                    }else if(m_collator.compare(subText, subText.toLowerCase(locale)) == 0){
                       diff[0] = LOWER_CASE;
                    }
                    if(m_collator.compare(subPatt, subPattUp) == 0){
                        diff[1] = UPPER_CASE;
                    }else if(m_collator.compare(subPatt, subPatt.toLowerCase(locale)) == 0){
                       diff[1] = LOWER_CASE;
                    }

                    if(((diff[0] == UPPER_CASE) && ( diff[1] == LOWER_CASE)) ||
                       ((diff[0] == LOWER_CASE) && ( diff[1] == UPPER_CASE))){
                        return diff;
                    }else{// not case diff
                      continue;
                    }
                }else{
                    continue;
                }

           }
        }

  }
 
Example 2
private final int[] getFirstCaseDiff(final String text, final String pattern, final Locale locale){

        final CollationElementIterator targIter = m_collator.getCollationElementIterator(text);
        final CollationElementIterator patIter = m_collator.getCollationElementIterator(pattern);
        int startTarg = -1;
        int endTarg = -1;
        int startPatt = -1;
        int endPatt = -1;
        final int done = getElement(CollationElementIterator.NULLORDER);
        int patternElement = 0, targetElement = 0;
        boolean getPattern = true, getTarget = true;

        while (true) {
            if (getPattern){
                 startPatt = patIter.getOffset();
                 patternElement = getElement(patIter.next());
                 endPatt = patIter.getOffset();
            }
            if ((getTarget)){
                 startTarg  = targIter.getOffset();
                 targetElement   = getElement(targIter.next());
                 endTarg  = targIter.getOffset();
            }
            getTarget = getPattern = true;
            if ((patternElement == done) ||( targetElement == done)) {
                return null;
            } else if (targetElement == 0) {
              getPattern = false;
            } else if (patternElement == 0) {
              getTarget = false;
            } else if (targetElement != patternElement) {// mismatch
                if((startPatt < endPatt) && (startTarg < endTarg)){
                    final String  subText = text.substring(startTarg, endTarg);
                    final String  subPatt = pattern.substring(startPatt, endPatt);
                    final String  subTextUp = subText.toUpperCase(locale);
                    final String  subPattUp = subPatt.toUpperCase(locale);
                    if(m_collator.compare(subTextUp, subPattUp) != 0){ // not case diffference
                        continue;
                    }

                    int diff[] = {UNKNOWN_CASE, UNKNOWN_CASE};
                    if(m_collator.compare(subText, subTextUp) == 0){
                        diff[0] = UPPER_CASE;
                    }else if(m_collator.compare(subText, subText.toLowerCase(locale)) == 0){
                       diff[0] = LOWER_CASE;
                    }
                    if(m_collator.compare(subPatt, subPattUp) == 0){
                        diff[1] = UPPER_CASE;
                    }else if(m_collator.compare(subPatt, subPatt.toLowerCase(locale)) == 0){
                       diff[1] = LOWER_CASE;
                    }

                    if(((diff[0] == UPPER_CASE) && ( diff[1] == LOWER_CASE)) ||
                       ((diff[0] == LOWER_CASE) && ( diff[1] == UPPER_CASE))){
                        return diff;
                    }else{// not case diff
                      continue;
                    }
                }else{
                    continue;
                }

           }
        }

  }
 
Example 3
Source Project: jdk8u60   Source File: StringComparable.java    License: GNU General Public License v2.0 4 votes vote down vote up
private final int[] getFirstCaseDiff(final String text, final String pattern, final Locale locale){

        final CollationElementIterator targIter = m_collator.getCollationElementIterator(text);
        final CollationElementIterator patIter = m_collator.getCollationElementIterator(pattern);
        int startTarg = -1;
        int endTarg = -1;
        int startPatt = -1;
        int endPatt = -1;
        final int done = getElement(CollationElementIterator.NULLORDER);
        int patternElement = 0, targetElement = 0;
        boolean getPattern = true, getTarget = true;

        while (true) {
            if (getPattern){
                 startPatt = patIter.getOffset();
                 patternElement = getElement(patIter.next());
                 endPatt = patIter.getOffset();
            }
            if ((getTarget)){
                 startTarg  = targIter.getOffset();
                 targetElement   = getElement(targIter.next());
                 endTarg  = targIter.getOffset();
            }
            getTarget = getPattern = true;
            if ((patternElement == done) ||( targetElement == done)) {
                return null;
            } else if (targetElement == 0) {
              getPattern = false;
            } else if (patternElement == 0) {
              getTarget = false;
            } else if (targetElement != patternElement) {// mismatch
                if((startPatt < endPatt) && (startTarg < endTarg)){
                    final String  subText = text.substring(startTarg, endTarg);
                    final String  subPatt = pattern.substring(startPatt, endPatt);
                    final String  subTextUp = subText.toUpperCase(locale);
                    final String  subPattUp = subPatt.toUpperCase(locale);
                    if(m_collator.compare(subTextUp, subPattUp) != 0){ // not case diffference
                        continue;
                    }

                    int diff[] = {UNKNOWN_CASE, UNKNOWN_CASE};
                    if(m_collator.compare(subText, subTextUp) == 0){
                        diff[0] = UPPER_CASE;
                    }else if(m_collator.compare(subText, subText.toLowerCase(locale)) == 0){
                       diff[0] = LOWER_CASE;
                    }
                    if(m_collator.compare(subPatt, subPattUp) == 0){
                        diff[1] = UPPER_CASE;
                    }else if(m_collator.compare(subPatt, subPatt.toLowerCase(locale)) == 0){
                       diff[1] = LOWER_CASE;
                    }

                    if(((diff[0] == UPPER_CASE) && ( diff[1] == LOWER_CASE)) ||
                       ((diff[0] == LOWER_CASE) && ( diff[1] == UPPER_CASE))){
                        return diff;
                    }else{// not case diff
                      continue;
                    }
                }else{
                    continue;
                }

           }
        }

  }
 
Example 4
Source Project: JDKSourceCode1.8   Source File: StringComparable.java    License: MIT License 4 votes vote down vote up
private final int[] getFirstCaseDiff(final String text, final String pattern, final Locale locale){

        final CollationElementIterator targIter = m_collator.getCollationElementIterator(text);
        final CollationElementIterator patIter = m_collator.getCollationElementIterator(pattern);
        int startTarg = -1;
        int endTarg = -1;
        int startPatt = -1;
        int endPatt = -1;
        final int done = getElement(CollationElementIterator.NULLORDER);
        int patternElement = 0, targetElement = 0;
        boolean getPattern = true, getTarget = true;

        while (true) {
            if (getPattern){
                 startPatt = patIter.getOffset();
                 patternElement = getElement(patIter.next());
                 endPatt = patIter.getOffset();
            }
            if ((getTarget)){
                 startTarg  = targIter.getOffset();
                 targetElement   = getElement(targIter.next());
                 endTarg  = targIter.getOffset();
            }
            getTarget = getPattern = true;
            if ((patternElement == done) ||( targetElement == done)) {
                return null;
            } else if (targetElement == 0) {
              getPattern = false;
            } else if (patternElement == 0) {
              getTarget = false;
            } else if (targetElement != patternElement) {// mismatch
                if((startPatt < endPatt) && (startTarg < endTarg)){
                    final String  subText = text.substring(startTarg, endTarg);
                    final String  subPatt = pattern.substring(startPatt, endPatt);
                    final String  subTextUp = subText.toUpperCase(locale);
                    final String  subPattUp = subPatt.toUpperCase(locale);
                    if(m_collator.compare(subTextUp, subPattUp) != 0){ // not case diffference
                        continue;
                    }

                    int diff[] = {UNKNOWN_CASE, UNKNOWN_CASE};
                    if(m_collator.compare(subText, subTextUp) == 0){
                        diff[0] = UPPER_CASE;
                    }else if(m_collator.compare(subText, subText.toLowerCase(locale)) == 0){
                       diff[0] = LOWER_CASE;
                    }
                    if(m_collator.compare(subPatt, subPattUp) == 0){
                        diff[1] = UPPER_CASE;
                    }else if(m_collator.compare(subPatt, subPatt.toLowerCase(locale)) == 0){
                       diff[1] = LOWER_CASE;
                    }

                    if(((diff[0] == UPPER_CASE) && ( diff[1] == LOWER_CASE)) ||
                       ((diff[0] == LOWER_CASE) && ( diff[1] == UPPER_CASE))){
                        return diff;
                    }else{// not case diff
                      continue;
                    }
                }else{
                    continue;
                }

           }
        }

  }
 
Example 5
private final int[] getFirstCaseDiff(final String text, final String pattern, final Locale locale){

        final CollationElementIterator targIter = m_collator.getCollationElementIterator(text);
        final CollationElementIterator patIter = m_collator.getCollationElementIterator(pattern);
        int startTarg = -1;
        int endTarg = -1;
        int startPatt = -1;
        int endPatt = -1;
        final int done = getElement(CollationElementIterator.NULLORDER);
        int patternElement = 0, targetElement = 0;
        boolean getPattern = true, getTarget = true;

        while (true) {
            if (getPattern){
                 startPatt = patIter.getOffset();
                 patternElement = getElement(patIter.next());
                 endPatt = patIter.getOffset();
            }
            if ((getTarget)){
                 startTarg  = targIter.getOffset();
                 targetElement   = getElement(targIter.next());
                 endTarg  = targIter.getOffset();
            }
            getTarget = getPattern = true;
            if ((patternElement == done) ||( targetElement == done)) {
                return null;
            } else if (targetElement == 0) {
              getPattern = false;
            } else if (patternElement == 0) {
              getTarget = false;
            } else if (targetElement != patternElement) {// mismatch
                if((startPatt < endPatt) && (startTarg < endTarg)){
                    final String  subText = text.substring(startTarg, endTarg);
                    final String  subPatt = pattern.substring(startPatt, endPatt);
                    final String  subTextUp = subText.toUpperCase(locale);
                    final String  subPattUp = subPatt.toUpperCase(locale);
                    if(m_collator.compare(subTextUp, subPattUp) != 0){ // not case diffference
                        continue;
                    }

                    int diff[] = {UNKNOWN_CASE, UNKNOWN_CASE};
                    if(m_collator.compare(subText, subTextUp) == 0){
                        diff[0] = UPPER_CASE;
                    }else if(m_collator.compare(subText, subText.toLowerCase(locale)) == 0){
                       diff[0] = LOWER_CASE;
                    }
                    if(m_collator.compare(subPatt, subPattUp) == 0){
                        diff[1] = UPPER_CASE;
                    }else if(m_collator.compare(subPatt, subPatt.toLowerCase(locale)) == 0){
                       diff[1] = LOWER_CASE;
                    }

                    if(((diff[0] == UPPER_CASE) && ( diff[1] == LOWER_CASE)) ||
                       ((diff[0] == LOWER_CASE) && ( diff[1] == UPPER_CASE))){
                        return diff;
                    }else{// not case diff
                      continue;
                    }
                }else{
                    continue;
                }

           }
        }

  }
 
Example 6
private final int[] getFirstCaseDiff(final String text, final String pattern, final Locale locale){

        final CollationElementIterator targIter = m_collator.getCollationElementIterator(text);
        final CollationElementIterator patIter = m_collator.getCollationElementIterator(pattern);
        int startTarg = -1;
        int endTarg = -1;
        int startPatt = -1;
        int endPatt = -1;
        final int done = getElement(CollationElementIterator.NULLORDER);
        int patternElement = 0, targetElement = 0;
        boolean getPattern = true, getTarget = true;

        while (true) {
            if (getPattern){
                 startPatt = patIter.getOffset();
                 patternElement = getElement(patIter.next());
                 endPatt = patIter.getOffset();
            }
            if ((getTarget)){
                 startTarg  = targIter.getOffset();
                 targetElement   = getElement(targIter.next());
                 endTarg  = targIter.getOffset();
            }
            getTarget = getPattern = true;
            if ((patternElement == done) ||( targetElement == done)) {
                return null;
            } else if (targetElement == 0) {
              getPattern = false;
            } else if (patternElement == 0) {
              getTarget = false;
            } else if (targetElement != patternElement) {// mismatch
                if((startPatt < endPatt) && (startTarg < endTarg)){
                    final String  subText = text.substring(startTarg, endTarg);
                    final String  subPatt = pattern.substring(startPatt, endPatt);
                    final String  subTextUp = subText.toUpperCase(locale);
                    final String  subPattUp = subPatt.toUpperCase(locale);
                    if(m_collator.compare(subTextUp, subPattUp) != 0){ // not case diffference
                        continue;
                    }

                    int diff[] = {UNKNOWN_CASE, UNKNOWN_CASE};
                    if(m_collator.compare(subText, subTextUp) == 0){
                        diff[0] = UPPER_CASE;
                    }else if(m_collator.compare(subText, subText.toLowerCase(locale)) == 0){
                       diff[0] = LOWER_CASE;
                    }
                    if(m_collator.compare(subPatt, subPattUp) == 0){
                        diff[1] = UPPER_CASE;
                    }else if(m_collator.compare(subPatt, subPatt.toLowerCase(locale)) == 0){
                       diff[1] = LOWER_CASE;
                    }

                    if(((diff[0] == UPPER_CASE) && ( diff[1] == LOWER_CASE)) ||
                       ((diff[0] == LOWER_CASE) && ( diff[1] == UPPER_CASE))){
                        return diff;
                    }else{// not case diff
                      continue;
                    }
                }else{
                    continue;
                }

           }
        }

  }
 
Example 7
Source Project: Bytecoder   Source File: StringComparable.java    License: Apache License 2.0 4 votes vote down vote up
private final int[] getFirstCaseDiff(final String text, final String pattern, final Locale locale){

        final CollationElementIterator targIter = m_collator.getCollationElementIterator(text);
        final CollationElementIterator patIter = m_collator.getCollationElementIterator(pattern);
        int startTarg = -1;
        int endTarg = -1;
        int startPatt = -1;
        int endPatt = -1;
        final int done = getElement(CollationElementIterator.NULLORDER);
        int patternElement = 0, targetElement = 0;
        boolean getPattern = true, getTarget = true;

        while (true) {
            if (getPattern){
                 startPatt = patIter.getOffset();
                 patternElement = getElement(patIter.next());
                 endPatt = patIter.getOffset();
            }
            if ((getTarget)){
                 startTarg  = targIter.getOffset();
                 targetElement   = getElement(targIter.next());
                 endTarg  = targIter.getOffset();
            }
            getTarget = getPattern = true;
            if ((patternElement == done) ||( targetElement == done)) {
                return null;
            } else if (targetElement == 0) {
              getPattern = false;
            } else if (patternElement == 0) {
              getTarget = false;
            } else if (targetElement != patternElement) {// mismatch
                if((startPatt < endPatt) && (startTarg < endTarg)){
                    final String  subText = text.substring(startTarg, endTarg);
                    final String  subPatt = pattern.substring(startPatt, endPatt);
                    final String  subTextUp = subText.toUpperCase(locale);
                    final String  subPattUp = subPatt.toUpperCase(locale);
                    if(m_collator.compare(subTextUp, subPattUp) != 0){ // not case diffference
                        continue;
                    }

                    int diff[] = {UNKNOWN_CASE, UNKNOWN_CASE};
                    if(m_collator.compare(subText, subTextUp) == 0){
                        diff[0] = UPPER_CASE;
                    }else if(m_collator.compare(subText, subText.toLowerCase(locale)) == 0){
                       diff[0] = LOWER_CASE;
                    }
                    if(m_collator.compare(subPatt, subPattUp) == 0){
                        diff[1] = UPPER_CASE;
                    }else if(m_collator.compare(subPatt, subPatt.toLowerCase(locale)) == 0){
                       diff[1] = LOWER_CASE;
                    }

                    if(((diff[0] == UPPER_CASE) && ( diff[1] == LOWER_CASE)) ||
                       ((diff[0] == LOWER_CASE) && ( diff[1] == UPPER_CASE))){
                        return diff;
                    }else{// not case diff
                      continue;
                    }
                }else{
                    continue;
                }

           }
        }

  }
 
Example 8
private final int[] getFirstCaseDiff(final String text, final String pattern, final Locale locale){

        final CollationElementIterator targIter = m_collator.getCollationElementIterator(text);
        final CollationElementIterator patIter = m_collator.getCollationElementIterator(pattern);
        int startTarg = -1;
        int endTarg = -1;
        int startPatt = -1;
        int endPatt = -1;
        final int done = getElement(CollationElementIterator.NULLORDER);
        int patternElement = 0, targetElement = 0;
        boolean getPattern = true, getTarget = true;

        while (true) {
            if (getPattern){
                 startPatt = patIter.getOffset();
                 patternElement = getElement(patIter.next());
                 endPatt = patIter.getOffset();
            }
            if ((getTarget)){
                 startTarg  = targIter.getOffset();
                 targetElement   = getElement(targIter.next());
                 endTarg  = targIter.getOffset();
            }
            getTarget = getPattern = true;
            if ((patternElement == done) ||( targetElement == done)) {
                return null;
            } else if (targetElement == 0) {
              getPattern = false;
            } else if (patternElement == 0) {
              getTarget = false;
            } else if (targetElement != patternElement) {// mismatch
                if((startPatt < endPatt) && (startTarg < endTarg)){
                    final String  subText = text.substring(startTarg, endTarg);
                    final String  subPatt = pattern.substring(startPatt, endPatt);
                    final String  subTextUp = subText.toUpperCase(locale);
                    final String  subPattUp = subPatt.toUpperCase(locale);
                    if(m_collator.compare(subTextUp, subPattUp) != 0){ // not case diffference
                        continue;
                    }

                    int diff[] = {UNKNOWN_CASE, UNKNOWN_CASE};
                    if(m_collator.compare(subText, subTextUp) == 0){
                        diff[0] = UPPER_CASE;
                    }else if(m_collator.compare(subText, subText.toLowerCase(locale)) == 0){
                       diff[0] = LOWER_CASE;
                    }
                    if(m_collator.compare(subPatt, subPattUp) == 0){
                        diff[1] = UPPER_CASE;
                    }else if(m_collator.compare(subPatt, subPatt.toLowerCase(locale)) == 0){
                       diff[1] = LOWER_CASE;
                    }

                    if(((diff[0] == UPPER_CASE) && ( diff[1] == LOWER_CASE)) ||
                       ((diff[0] == LOWER_CASE) && ( diff[1] == UPPER_CASE))){
                        return diff;
                    }else{// not case diff
                      continue;
                    }
                }else{
                    continue;
                }

           }
        }

  }
 
Example 9
Source Project: hottub   Source File: StringComparable.java    License: GNU General Public License v2.0 4 votes vote down vote up
private final int[] getFirstCaseDiff(final String text, final String pattern, final Locale locale){

        final CollationElementIterator targIter = m_collator.getCollationElementIterator(text);
        final CollationElementIterator patIter = m_collator.getCollationElementIterator(pattern);
        int startTarg = -1;
        int endTarg = -1;
        int startPatt = -1;
        int endPatt = -1;
        final int done = getElement(CollationElementIterator.NULLORDER);
        int patternElement = 0, targetElement = 0;
        boolean getPattern = true, getTarget = true;

        while (true) {
            if (getPattern){
                 startPatt = patIter.getOffset();
                 patternElement = getElement(patIter.next());
                 endPatt = patIter.getOffset();
            }
            if ((getTarget)){
                 startTarg  = targIter.getOffset();
                 targetElement   = getElement(targIter.next());
                 endTarg  = targIter.getOffset();
            }
            getTarget = getPattern = true;
            if ((patternElement == done) ||( targetElement == done)) {
                return null;
            } else if (targetElement == 0) {
              getPattern = false;
            } else if (patternElement == 0) {
              getTarget = false;
            } else if (targetElement != patternElement) {// mismatch
                if((startPatt < endPatt) && (startTarg < endTarg)){
                    final String  subText = text.substring(startTarg, endTarg);
                    final String  subPatt = pattern.substring(startPatt, endPatt);
                    final String  subTextUp = subText.toUpperCase(locale);
                    final String  subPattUp = subPatt.toUpperCase(locale);
                    if(m_collator.compare(subTextUp, subPattUp) != 0){ // not case diffference
                        continue;
                    }

                    int diff[] = {UNKNOWN_CASE, UNKNOWN_CASE};
                    if(m_collator.compare(subText, subTextUp) == 0){
                        diff[0] = UPPER_CASE;
                    }else if(m_collator.compare(subText, subText.toLowerCase(locale)) == 0){
                       diff[0] = LOWER_CASE;
                    }
                    if(m_collator.compare(subPatt, subPattUp) == 0){
                        diff[1] = UPPER_CASE;
                    }else if(m_collator.compare(subPatt, subPatt.toLowerCase(locale)) == 0){
                       diff[1] = LOWER_CASE;
                    }

                    if(((diff[0] == UPPER_CASE) && ( diff[1] == LOWER_CASE)) ||
                       ((diff[0] == LOWER_CASE) && ( diff[1] == UPPER_CASE))){
                        return diff;
                    }else{// not case diff
                      continue;
                    }
                }else{
                    continue;
                }

           }
        }

  }
 
Example 10
private final int[] getFirstCaseDiff(final String text, final String pattern, final Locale locale){

        final CollationElementIterator targIter = m_collator.getCollationElementIterator(text);
        final CollationElementIterator patIter = m_collator.getCollationElementIterator(pattern);
        int startTarg = -1;
        int endTarg = -1;
        int startPatt = -1;
        int endPatt = -1;
        final int done = getElement(CollationElementIterator.NULLORDER);
        int patternElement = 0, targetElement = 0;
        boolean getPattern = true, getTarget = true;

        while (true) {
            if (getPattern){
                 startPatt = patIter.getOffset();
                 patternElement = getElement(patIter.next());
                 endPatt = patIter.getOffset();
            }
            if ((getTarget)){
                 startTarg  = targIter.getOffset();
                 targetElement   = getElement(targIter.next());
                 endTarg  = targIter.getOffset();
            }
            getTarget = getPattern = true;
            if ((patternElement == done) ||( targetElement == done)) {
                return null;
            } else if (targetElement == 0) {
              getPattern = false;
            } else if (patternElement == 0) {
              getTarget = false;
            } else if (targetElement != patternElement) {// mismatch
                if((startPatt < endPatt) && (startTarg < endTarg)){
                    final String  subText = text.substring(startTarg, endTarg);
                    final String  subPatt = pattern.substring(startPatt, endPatt);
                    final String  subTextUp = subText.toUpperCase(locale);
                    final String  subPattUp = subPatt.toUpperCase(locale);
                    if(m_collator.compare(subTextUp, subPattUp) != 0){ // not case diffference
                        continue;
                    }

                    int diff[] = {UNKNOWN_CASE, UNKNOWN_CASE};
                    if(m_collator.compare(subText, subTextUp) == 0){
                        diff[0] = UPPER_CASE;
                    }else if(m_collator.compare(subText, subText.toLowerCase(locale)) == 0){
                       diff[0] = LOWER_CASE;
                    }
                    if(m_collator.compare(subPatt, subPattUp) == 0){
                        diff[1] = UPPER_CASE;
                    }else if(m_collator.compare(subPatt, subPatt.toLowerCase(locale)) == 0){
                       diff[1] = LOWER_CASE;
                    }

                    if(((diff[0] == UPPER_CASE) && ( diff[1] == LOWER_CASE)) ||
                       ((diff[0] == LOWER_CASE) && ( diff[1] == UPPER_CASE))){
                        return diff;
                    }else{// not case diff
                      continue;
                    }
                }else{
                    continue;
                }

           }
        }

  }
 
Example 11
/**
 * This method translates the string into a series of collation elements.
 * These elements will get used in the like method.
 * 
 * @return an array of collation elements for the string
 * @throws StandardException
 */
int[] getCollationElementsForString()
	throws StandardException
{
	if (stringData.isNull())
	{
		return (int[]) null;
	}



       // Caching of collationElementsForString is not working properly, in 
       // order to cache it needs to get invalidated everytime the container
       // type's value is changed - through any interface, eg: readExternal, 
       // setValue, ...  To get proper behavior, disabling caching, and will
       // file a performance enhancement to implement correct caching.
       collationElementsForString = null;
       countOfCollationElements   = 0;


	if (collationElementsForString != null)
	{
		return collationElementsForString;
	}

	// countOfCollationElements should always be 0 when 
       // collationElementsForString is null
	if (SanityManager.DEBUG)
	{
		if (countOfCollationElements != 0)
		{
			SanityManager.THROWASSERT(
				"countOfCollationElements expected to be 0, not " + 
                   countOfCollationElements);
		}
	}
       

	collationElementsForString = new int[stringData.getLength()];

	CollationElementIterator cei = 
           collatorForCharacterDatatypes.getCollationElementIterator(
               stringData.getString());

	int nextInt;
	while ((nextInt = cei.next()) != CollationElementIterator.NULLORDER)
	{
		/* Believe it or not, a String might have more
		 * collation elements than characters.
		 * So, we handle that case by increasing the int array
		 * by 5 and copying array elements.
		 */
		if (countOfCollationElements == collationElementsForString.length)
		{
			int[] expandedArray = new int[countOfCollationElements + 5];
			System.arraycopy(collationElementsForString, 0, expandedArray, 
					0, collationElementsForString.length);
			collationElementsForString = expandedArray;
		}
		collationElementsForString[countOfCollationElements++] = nextInt;
	}

	return collationElementsForString;
}
 
Example 12
Source Project: openjdk-8   Source File: StringComparable.java    License: GNU General Public License v2.0 4 votes vote down vote up
private final int[] getFirstCaseDiff(final String text, final String pattern, final Locale locale){

        final CollationElementIterator targIter = m_collator.getCollationElementIterator(text);
        final CollationElementIterator patIter = m_collator.getCollationElementIterator(pattern);
        int startTarg = -1;
        int endTarg = -1;
        int startPatt = -1;
        int endPatt = -1;
        final int done = getElement(CollationElementIterator.NULLORDER);
        int patternElement = 0, targetElement = 0;
        boolean getPattern = true, getTarget = true;

        while (true) {
            if (getPattern){
                 startPatt = patIter.getOffset();
                 patternElement = getElement(patIter.next());
                 endPatt = patIter.getOffset();
            }
            if ((getTarget)){
                 startTarg  = targIter.getOffset();
                 targetElement   = getElement(targIter.next());
                 endTarg  = targIter.getOffset();
            }
            getTarget = getPattern = true;
            if ((patternElement == done) ||( targetElement == done)) {
                return null;
            } else if (targetElement == 0) {
              getPattern = false;
            } else if (patternElement == 0) {
              getTarget = false;
            } else if (targetElement != patternElement) {// mismatch
                if((startPatt < endPatt) && (startTarg < endTarg)){
                    final String  subText = text.substring(startTarg, endTarg);
                    final String  subPatt = pattern.substring(startPatt, endPatt);
                    final String  subTextUp = subText.toUpperCase(locale);
                    final String  subPattUp = subPatt.toUpperCase(locale);
                    if(m_collator.compare(subTextUp, subPattUp) != 0){ // not case diffference
                        continue;
                    }

                    int diff[] = {UNKNOWN_CASE, UNKNOWN_CASE};
                    if(m_collator.compare(subText, subTextUp) == 0){
                        diff[0] = UPPER_CASE;
                    }else if(m_collator.compare(subText, subText.toLowerCase(locale)) == 0){
                       diff[0] = LOWER_CASE;
                    }
                    if(m_collator.compare(subPatt, subPattUp) == 0){
                        diff[1] = UPPER_CASE;
                    }else if(m_collator.compare(subPatt, subPatt.toLowerCase(locale)) == 0){
                       diff[1] = LOWER_CASE;
                    }

                    if(((diff[0] == UPPER_CASE) && ( diff[1] == LOWER_CASE)) ||
                       ((diff[0] == LOWER_CASE) && ( diff[1] == UPPER_CASE))){
                        return diff;
                    }else{// not case diff
                      continue;
                    }
                }else{
                    continue;
                }

           }
        }

  }
 
Example 13
/**
 * This method translates the string into a series of collation elements.
 * These elements will get used in the like method.
 * 
 * @return an array of collation elements for the string
 * @throws StandardException
 */
int[] getCollationElementsForString()
	throws StandardException
{
	if (stringData.isNull())
	{
		return (int[]) null;
	}



       // Caching of collationElementsForString is not working properly, in 
       // order to cache it needs to get invalidated everytime the container
       // type's value is changed - through any interface, eg: readExternal, 
       // setValue, ...  To get proper behavior, disabling caching, and will
       // file a performance enhancement to implement correct caching.
       collationElementsForString = null;
       countOfCollationElements   = 0;


	if (collationElementsForString != null)
	{
		return collationElementsForString;
	}

	// countOfCollationElements should always be 0 when 
       // collationElementsForString is null
	if (SanityManager.DEBUG)
	{
		if (countOfCollationElements != 0)
		{
			SanityManager.THROWASSERT(
				"countOfCollationElements expected to be 0, not " + 
                   countOfCollationElements);
		}
	}
       

	collationElementsForString = new int[stringData.getLength()];

	CollationElementIterator cei = 
           collatorForCharacterDatatypes.getCollationElementIterator(
               stringData.getString());

	int nextInt;
	while ((nextInt = cei.next()) != CollationElementIterator.NULLORDER)
	{
		/* Believe it or not, a String might have more
		 * collation elements than characters.
		 * So, we handle that case by increasing the int array
		 * by 5 and copying array elements.
		 */
		if (countOfCollationElements == collationElementsForString.length)
		{
			int[] expandedArray = new int[countOfCollationElements + 5];
			System.arraycopy(collationElementsForString, 0, expandedArray, 
					0, collationElementsForString.length);
			collationElementsForString = expandedArray;
		}
		collationElementsForString[countOfCollationElements++] = nextInt;
	}

	return collationElementsForString;
}
 
Example 14
/**
 * This method translates the string into a series of collation elements.
 * These elements will get used in the like method.
 * 
 * @return an array of collation elements for the string
 * @throws StandardException
 */
int[] getCollationElementsForString()
	throws StandardException
{
	if (stringData.isNull())
	{
		return (int[]) null;
	}



       // Caching of collationElementsForString is not working properly, in 
       // order to cache it needs to get invalidated everytime the container
       // type's value is changed - through any interface, eg: readExternal, 
       // setValue, ...  To get proper behavior, disabling caching, and will
       // file a performance enhancement to implement correct caching.
       collationElementsForString = null;
       countOfCollationElements   = 0;


	if (collationElementsForString != null)
	{
		return collationElementsForString;
	}

	// countOfCollationElements should always be 0 when 
       // collationElementsForString is null
	if (SanityManager.DEBUG)
	{
		if (countOfCollationElements != 0)
		{
			SanityManager.THROWASSERT(
				"countOfCollationElements expected to be 0, not " + 
                   countOfCollationElements);
		}
	}
       

	collationElementsForString = new int[stringData.getLength()];

	CollationElementIterator cei = 
           collatorForCharacterDatatypes.getCollationElementIterator(
               stringData.getString());

	int nextInt;
	while ((nextInt = cei.next()) != CollationElementIterator.NULLORDER)
	{
		/* Believe it or not, a String might have more
		 * collation elements than characters.
		 * So, we handle that case by increasing the int array
		 * by 5 and copying array elements.
		 */
		if (countOfCollationElements == collationElementsForString.length)
		{
			int[] expandedArray = new int[countOfCollationElements + 5];
			System.arraycopy(collationElementsForString, 0, expandedArray, 
					0, collationElementsForString.length);
			collationElementsForString = expandedArray;
		}
		collationElementsForString[countOfCollationElements++] = nextInt;
	}

	return collationElementsForString;
}