Package nu.validator.htmlparser.impl
Class UTF16Buffer
- java.lang.Object
-
- nu.validator.htmlparser.impl.UTF16Buffer
-
public final class UTF16Buffer extends java.lang.ObjectAn UTF-16 buffer that knows the start and end indeces of its unconsumed content.- Version:
- $Id$
-
-
Field Summary
Fields Modifier and Type Field Description private char[]bufferThe backing store of the buffer.private intendThe index of the slot immediately after the last character in the backing buffer that is part of the logical content of thisUTF16Buffer.private intstartThe index of the first unconsumed character in the backing buffer.
-
Constructor Summary
Constructors Constructor Description UTF16Buffer(char[] buffer, int start, int end)Constructor for wrapping an existing UTF-16 code unit array.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadjust(boolean lastWasCR)Adjusts the start index to skip over the first character if it is a line feed and the previous character was a carriage return.char[]getBuffer()Returns the backing buffer.intgetEnd()Returns the end index.intgetStart()Returns the start index.booleanhasMore()Checks if the buffer has data left.voidsetEnd(int end)Sets the end index.voidsetStart(int start)Sets the start index.
-
-
-
Field Detail
-
buffer
private final char[] buffer
The backing store of the buffer. May be larger than the logical content of thisUTF16Buffer.
-
start
private int start
The index of the first unconsumed character in the backing buffer.
-
end
private int end
The index of the slot immediately after the last character in the backing buffer that is part of the logical content of thisUTF16Buffer.
-
-
Constructor Detail
-
UTF16Buffer
public UTF16Buffer(char[] buffer, int start, int end)Constructor for wrapping an existing UTF-16 code unit array.- Parameters:
buffer- the backing bufferstart- the index of the first character to consumeend- the index immediately after the last character to consume
-
-
Method Detail
-
getStart
public int getStart()
Returns the start index.- Returns:
- the start index
-
setStart
public void setStart(int start)
Sets the start index.- Parameters:
start- the start index
-
getBuffer
public char[] getBuffer()
Returns the backing buffer.- Returns:
- the backing buffer
-
getEnd
public int getEnd()
Returns the end index.- Returns:
- the end index
-
hasMore
public boolean hasMore()
Checks if the buffer has data left.- Returns:
trueif there's data left
-
adjust
public void adjust(boolean lastWasCR)
Adjusts the start index to skip over the first character if it is a line feed and the previous character was a carriage return.- Parameters:
lastWasCR- whether the previous character was a carriage return
-
setEnd
public void setEnd(int end)
Sets the end index.- Parameters:
end- the end index
-
-