Java Code Examples for java.text.CollationElementIterator#getOffset()
The following examples show how to use
java.text.CollationElementIterator#getOffset() .
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: StringComparable.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
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
Source File: StringComparable.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
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 File: StringComparable.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
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 File: StringComparable.java From JDKSourceCode1.8 with MIT License | 4 votes |
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
Source File: StringComparable.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
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
Source File: StringComparable.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
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 File: StringComparable.java From Bytecoder with Apache License 2.0 | 4 votes |
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
Source File: StringComparable.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
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 File: StringComparable.java From hottub with GNU General Public License v2.0 | 4 votes |
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
Source File: StringComparable.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
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
Source File: StringComparable.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
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; } } } }