package org.apache.fop.complexscripts.fonts;
+import java.nio.Buffer;
import java.nio.IntBuffer;
import java.util.ArrayList;
import java.util.List;
/** alternates index */
private int[] alternatesIndex;
/** current output glyph sequence */
- private IntBuffer ogb;
+ private Buffer ogb;
/** current output glyph to character associations */
private List oal;
/** character association predications */
*/
public void putGlyph(int glyph, CharAssociation a, Object predication) {
if (!ogb.hasRemaining()) {
- ogb = growBuffer(ogb);
+ ogb = growBuffer(getIntBuffer());
}
- ogb.put(glyph);
+ getIntBuffer().put(glyph);
if (predications && (predication != null)) {
a.setPredication(feature, predication);
}
oal.add(a);
}
+ private IntBuffer getIntBuffer() {
+ return (IntBuffer) ogb;
+ }
+
/**
* Put (write) array of glyphs into glyph output buffer.
* @param glyphs to write
if (position > 0) {
ogb.limit(position);
ogb.rewind();
- return new GlyphSequence(igs.getCharacters(), ogb, oal);
+ return new GlyphSequence(igs.getCharacters(), getIntBuffer(), oal);
} else {
return igs;
}
}
}
- private static IntBuffer growBuffer(IntBuffer ib) {
+ private static IntBuffer growBuffer(Buffer ib) {
int capacity = ib.capacity();
int capacityNew = capacity * 2;
IntBuffer ibNew = IntBuffer.allocate(capacityNew);
ib.rewind();
- return ibNew.put(ib);
+ return ibNew.put((IntBuffer) ib);
}
}
package org.apache.fop.fo;
import java.awt.Color;
+import java.nio.Buffer;
import java.nio.CharBuffer;
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
public class FOText extends FONode implements CharSequence, TextFragment {
/** the <code>CharBuffer</code> containing the text */
- private CharBuffer charBuffer;
+ private Buffer charBuffer;
// cached iterator
private CharacterIterator charIterator;
}
CharBuffer newBuffer = CharBuffer.allocate(newCapacity);
charBuffer.rewind();
- newBuffer.put(charBuffer);
+ newBuffer.put(getCharBuffer());
charBuffer = newBuffer;
}
}
// extend limit to capacity
charBuffer.limit(charBuffer.capacity());
// append characters
- charBuffer.put(data, start, length);
+ getCharBuffer().put(data, start, length);
// shrink limit to position
charBuffer.limit(charBuffer.position());
}
+ private CharBuffer getCharBuffer() {
+ return (CharBuffer) charBuffer;
+ }
+
/**
* Return the array of characters for this instance.
*
return null;
}
this.charBuffer.rewind();
- return this.charBuffer.asReadOnlyBuffer().subSequence(0, this.charBuffer.limit());
+ return getCharBuffer().asReadOnlyBuffer().subSequence(0, this.charBuffer.limit());
}
/** {@inheritDoc} */
if (charBuffer != null) {
ft.charBuffer = CharBuffer.allocate(charBuffer.limit());
charBuffer.rewind();
- ft.charBuffer.put(charBuffer);
+ ft.getCharBuffer().put(getCharBuffer());
ft.charBuffer.rewind();
}
}
char ch;
charBuffer.rewind();
while (charBuffer.hasRemaining()) {
- ch = charBuffer.get();
+ ch = getCharBuffer().get();
if (!((ch == CharUtilities.SPACE)
|| (ch == CharUtilities.LINEFEED_CHAR)
|| (ch == CharUtilities.CARRIAGE_RETURN)
}
charBuffer.rewind();
- CharBuffer tmp = charBuffer.slice();
+ CharBuffer tmp = getCharBuffer().slice();
char c;
int lim = charBuffer.limit();
int pos = -1;
while (++pos < lim) {
- c = charBuffer.get();
+ c = getCharBuffer().get();
switch (textTransform) {
case Constants.EN_UPPERCASE:
tmp.put(Character.toUpperCase(c));
if (this.currentPosition < charBuffer.limit()) {
this.canRemove = true;
this.canReplace = true;
- return charBuffer.get(currentPosition++);
+ return getCharBuffer().get(currentPosition++);
} else {
throw new NoSuchElementException();
}
if (this.canRemove) {
charBuffer.position(currentPosition);
// Slice the buffer at the current position
- CharBuffer tmp = charBuffer.slice();
+ CharBuffer tmp = getCharBuffer().slice();
// Reset position to before current character
charBuffer.position(--currentPosition);
if (tmp.hasRemaining()) {
// Transfer any remaining characters
charBuffer.mark();
- charBuffer.put(tmp);
+ getCharBuffer().put(tmp);
charBuffer.reset();
}
// Decrease limit
public void replaceChar(char c) {
if (this.canReplace) {
- charBuffer.put(currentPosition - 1, c);
+ getCharBuffer().put(currentPosition - 1, c);
} else {
throw new IllegalStateException();
}
if (charBuffer == null) {
return "";
} else {
- CharBuffer cb = charBuffer.duplicate();
+ Buffer cb = getCharBuffer().duplicate();
cb.rewind();
return cb.toString();
}
/** {@inheritDoc} */
public char charAt(int position) {
- return charBuffer.get(position);
+ return getCharBuffer().get(position);
}
/** {@inheritDoc} */
public CharSequence subSequence(int start, int end) {
- return charBuffer.subSequence(start, end);
+ return getCharBuffer().subSequence(start, end);
}
/** {@inheritDoc} */