org.apache.abdera.i18n.text
Class CodepointIterator

java.lang.Object
  extended by org.apache.abdera.i18n.text.CodepointIterator
All Implemented Interfaces:
Iterator<Codepoint>
Direct Known Subclasses:
DelegatingCodepointIterator

public abstract class CodepointIterator
extends Object
implements Iterator<Codepoint>

Provides an iterator over Unicode Codepoints


Nested Class Summary
static class CodepointIterator.RestrictedCodepointIterator
           
 
Field Summary
protected  int limit
           
protected  int position
           
 
Constructor Summary
CodepointIterator()
           
 
Method Summary
static CodepointIterator forByteArray(byte[] array)
          Get a CodepointIterator for the specified byte array, using the default charset
static CodepointIterator forByteArray(byte[] array, String charset)
          Get a CodepointIterator for the specified byte array, using the specified charset
static CodepointIterator forCharArray(char[] array)
          Get a CodepointIterator for the specified char array
static CodepointIterator forCharBuffer(CharBuffer buffer)
          Get a CodepointIterator for the specified CharBuffer
static CodepointIterator forCharSequence(CharSequence seq)
          Get a CodepointIterator for the specified CharSequence
static CodepointIterator forInputStream(InputStream in)
          Get a CodepointIterator for the specified InputStream
static CodepointIterator forInputStream(InputStream in, String charset)
          Get a CodepointIterator for the specified InputStream using the specified charset
static CodepointIterator forReadableByteChannel(ReadableByteChannel channel)
          Get a CodepointIterator for the specified ReadableByteChannel
static CodepointIterator forReadableByteChannel(ReadableByteChannel channel, String charset)
          Get a CodepointIterator for the specified ReadableByteChannel
static CodepointIterator forReader(Reader in)
          Get a CodepointIterator for the specified Reader
protected abstract  char get()
          Get the next char
protected abstract  char get(int index)
          Get the specified char
 boolean hasNext()
          True if there are codepoints remaining
 boolean isHigh(int index)
          Returns true if the char at the specified index is a high surrogate
 boolean isLow(int index)
          Returns true if the char at the specified index is a low surrogate
 int lastPosition()
          Return the final index position
 int limit()
          Return the iterator limit
 Codepoint next()
          Return the next codepoint
 char[] nextChars()
          Return the next chars.
 Codepoint peek()
          Peek the next codepoint
 Codepoint peek(int index)
          Peek the specified codepoint
 char[] peekChars()
          Peek the next chars in the iterator.
 int position()
          Get the iterator position
 void position(int n)
          Set the iterator position
 int remaining()
          Return the remaining iterator size
 void remove()
           
static CodepointIterator restrict(CodepointIterator ci, Filter filter)
           
static CodepointIterator restrict(CodepointIterator ci, Filter filter, boolean scanning)
           
static CodepointIterator restrict(CodepointIterator ci, Filter filter, boolean scanning, boolean invert)
           
 CodepointIterator restrict(Filter filter)
           
 CodepointIterator restrict(Filter filter, boolean scanning)
           
 CodepointIterator restrict(Filter filter, boolean scanning, boolean invert)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

position

protected int position

limit

protected int limit
Constructor Detail

CodepointIterator

public CodepointIterator()
Method Detail

forCharArray

public static CodepointIterator forCharArray(char[] array)
Get a CodepointIterator for the specified char array


forCharSequence

public static CodepointIterator forCharSequence(CharSequence seq)
Get a CodepointIterator for the specified CharSequence


forByteArray

public static CodepointIterator forByteArray(byte[] array)
Get a CodepointIterator for the specified byte array, using the default charset


forByteArray

public static CodepointIterator forByteArray(byte[] array,
                                             String charset)
Get a CodepointIterator for the specified byte array, using the specified charset


forCharBuffer

public static CodepointIterator forCharBuffer(CharBuffer buffer)
Get a CodepointIterator for the specified CharBuffer


forReadableByteChannel

public static CodepointIterator forReadableByteChannel(ReadableByteChannel channel)
Get a CodepointIterator for the specified ReadableByteChannel


forReadableByteChannel

public static CodepointIterator forReadableByteChannel(ReadableByteChannel channel,
                                                       String charset)
Get a CodepointIterator for the specified ReadableByteChannel


forInputStream

public static CodepointIterator forInputStream(InputStream in)
Get a CodepointIterator for the specified InputStream


forInputStream

public static CodepointIterator forInputStream(InputStream in,
                                               String charset)
Get a CodepointIterator for the specified InputStream using the specified charset


forReader

public static CodepointIterator forReader(Reader in)
Get a CodepointIterator for the specified Reader


restrict

public static CodepointIterator restrict(CodepointIterator ci,
                                         Filter filter)

restrict

public static CodepointIterator restrict(CodepointIterator ci,
                                         Filter filter,
                                         boolean scanning)

restrict

public static CodepointIterator restrict(CodepointIterator ci,
                                         Filter filter,
                                         boolean scanning,
                                         boolean invert)

restrict

public CodepointIterator restrict(Filter filter)

restrict

public CodepointIterator restrict(Filter filter,
                                  boolean scanning)

restrict

public CodepointIterator restrict(Filter filter,
                                  boolean scanning,
                                  boolean invert)

get

protected abstract char get()
Get the next char


get

protected abstract char get(int index)
Get the specified char


hasNext

public boolean hasNext()
True if there are codepoints remaining

Specified by:
hasNext in interface Iterator<Codepoint>

lastPosition

public int lastPosition()
Return the final index position


nextChars

public char[] nextChars()
                 throws InvalidCharacterException
Return the next chars. If the codepoint is not supplemental, the char array will have a single member. If the codepoint is supplemental, the char array will have two members, representing the high and low surrogate chars

Throws:
InvalidCharacterException

peekChars

public char[] peekChars()
                 throws InvalidCharacterException
Peek the next chars in the iterator. If the codepoint is not supplemental, the char array will have a single member. If the codepoint is supplemental, the char array will have two members, representing the high and low surrogate chars

Throws:
InvalidCharacterException

next

public Codepoint next()
               throws InvalidCharacterException
Return the next codepoint

Specified by:
next in interface Iterator<Codepoint>
Throws:
InvalidCharacterException

peek

public Codepoint peek()
               throws InvalidCharacterException
Peek the next codepoint

Throws:
InvalidCharacterException

peek

public Codepoint peek(int index)
               throws InvalidCharacterException
Peek the specified codepoint

Throws:
InvalidCharacterException

position

public void position(int n)
Set the iterator position


position

public int position()
Get the iterator position


limit

public int limit()
Return the iterator limit


remaining

public int remaining()
Return the remaining iterator size


isHigh

public boolean isHigh(int index)
Returns true if the char at the specified index is a high surrogate


isLow

public boolean isLow(int index)
Returns true if the char at the specified index is a low surrogate


remove

public void remove()
Specified by:
remove in interface Iterator<Codepoint>


Copyright © 2006-2010 Apache Software Foundation. All Rights Reserved.