Home | History | Annotate | Download | only in jdkadapter
      1 //  2016 and later: Unicode, Inc. and others.
      2 // License & terms of use: http://www.unicode.org/copyright.html#License
      3 /*
      4  *******************************************************************************
      5  * Copyright (C) 2008, International Business Machines Corporation and         *
      6  * others. All Rights Reserved.                                                *
      7  *******************************************************************************
      8  */
      9 package com.ibm.icu.impl.jdkadapter;
     10 
     11 import java.text.CharacterIterator;
     12 
     13 import com.ibm.icu.text.BreakIterator;
     14 
     15 /**
     16  * BreakIteratorICU is an adapter class which wraps ICU4J BreakIterator and
     17  * implements java.text.BreakIterator APIs.
     18  */
     19 public class BreakIteratorICU extends java.text.BreakIterator {
     20 
     21     private BreakIterator fIcuBrkItr;
     22 
     23     private BreakIteratorICU(BreakIterator icuBrkItr) {
     24         fIcuBrkItr = icuBrkItr;
     25     }
     26 
     27     public static java.text.BreakIterator wrap(BreakIterator icuBrkItr) {
     28         return new BreakIteratorICU(icuBrkItr);
     29     }
     30 
     31     public BreakIterator unwrap() {
     32         return fIcuBrkItr;
     33     }
     34 
     35     @Override
     36     public Object clone() {
     37         BreakIteratorICU other = (BreakIteratorICU)super.clone();
     38         other.fIcuBrkItr = (BreakIterator)fIcuBrkItr.clone();
     39         return other;
     40     }
     41 
     42     @Override
     43     public int current() {
     44         return fIcuBrkItr.current();
     45     }
     46 
     47     @Override
     48     public int first() {
     49         return fIcuBrkItr.first();
     50     }
     51 
     52     @Override
     53     public int following(int offset) {
     54         return fIcuBrkItr.following(offset);
     55     }
     56 
     57     @Override
     58     public CharacterIterator getText() {
     59         return fIcuBrkItr.getText();
     60     }
     61 
     62     @Override
     63     public boolean isBoundary(int offset) {
     64         return fIcuBrkItr.isBoundary(offset);
     65     }
     66 
     67     @Override
     68     public int last() {
     69         return fIcuBrkItr.last();
     70     }
     71 
     72     @Override
     73     public int next() {
     74         return fIcuBrkItr.next();
     75     }
     76 
     77     @Override
     78     public int next(int n) {
     79         return fIcuBrkItr.next(n);
     80     }
     81 
     82     @Override
     83     public int preceding(int offset) {
     84         return fIcuBrkItr.preceding(offset);
     85     }
     86 
     87     @Override
     88     public int previous() {
     89         return fIcuBrkItr.previous();
     90     }
     91 
     92     @Override
     93     public void setText(CharacterIterator newText) {
     94         fIcuBrkItr.setText(newText);
     95     }
     96 
     97     @Override
     98     public void setText(String newText) {
     99         fIcuBrkItr.setText(newText);
    100     }
    101 
    102 }
    103