]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-3132: Link against Java 8 API
authorSimon Steiner <ssteiner@apache.org>
Tue, 2 May 2023 09:30:07 +0000 (10:30 +0100)
committerSimon Steiner <ssteiner@apache.org>
Tue, 2 May 2023 09:30:07 +0000 (10:30 +0100)
fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java
fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionState.java
fop-core/src/main/java/org/apache/fop/complexscripts/util/GlyphSequence.java
fop-core/src/main/java/org/apache/fop/fo/FOText.java
fop-core/src/main/java/org/apache/fop/fonts/MultiByteFont.java

index f7b3d5e9c2c230ff77d264d0c9976258a922c0d3..20abd16169457349c9ae75e1205f34fd80b062b4 100644 (file)
@@ -19,6 +19,7 @@
 
 package org.apache.fop.complexscripts.fonts;
 
+import java.nio.Buffer;
 import java.nio.IntBuffer;
 import java.util.ArrayList;
 import java.util.List;
@@ -935,7 +936,8 @@ public class GlyphProcessingState {
             gb.put(igs.getGlyph(i));
             al.add(igs.getAssociation(i));
         }
-        gb.flip();
+        Buffer gbBase = gb;
+        gbBase.flip();
         assert igs != null;
         if (igs.compareGlyphs(gb) != 0) {
             this.igs = new GlyphSequence(igs.getCharacters(), gb, al);
index 0be47b8c1c1451071e0f01a8436486d14e1d19fb..788fe25743fe4a2daee5fefe8ae62808188ef8dc 100644 (file)
@@ -19,6 +19,7 @@
 
 package org.apache.fop.complexscripts.fonts;
 
+import java.nio.Buffer;
 import java.nio.IntBuffer;
 import java.util.ArrayList;
 import java.util.List;
@@ -41,7 +42,7 @@ public class GlyphSubstitutionState extends GlyphProcessingState {
     /** 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 */
@@ -131,15 +132,19 @@ public class GlyphSubstitutionState extends GlyphProcessingState {
      */
     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
@@ -165,7 +170,7 @@ public class GlyphSubstitutionState extends GlyphProcessingState {
         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;
         }
@@ -241,12 +246,12 @@ public class GlyphSubstitutionState extends GlyphProcessingState {
         }
     }
 
-    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);
     }
 
 }
index e5cdd07f56a560fe521e8e9ab3746f40be5fec2b..797fd4784c2eb640380e72c643a7eb3d3760f507 100644 (file)
@@ -19,6 +19,7 @@
 
 package org.apache.fop.complexscripts.util;
 
+import java.nio.Buffer;
 import java.nio.IntBuffer;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -464,7 +465,8 @@ public class GlyphSequence implements Cloneable {
         if (lga != null) {
             gb.put(lga);
         }
-        gb.flip();
+        Buffer gbBase = gb;
+        gbBase.flip();
         return gb;
     }
 
index 207c3184ce9f5e6b428a3902fd6cd312c6d64e54..e80063d1a54df1a5f6ea32b84e17a7d46c914911 100644 (file)
@@ -20,6 +20,7 @@
 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;
@@ -49,7 +50,7 @@ import org.apache.fop.util.CharUtilities;
 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;
@@ -135,18 +136,22 @@ public class FOText extends FONode implements CharSequence, TextFragment {
                 }
                 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.
      *
@@ -157,7 +162,7 @@ public class FOText extends FONode implements CharSequence, TextFragment {
             return null;
         }
         this.charBuffer.rewind();
-        return this.charBuffer.asReadOnlyBuffer().subSequence(0, this.charBuffer.limit());
+        return getCharBuffer().asReadOnlyBuffer().subSequence(0, this.charBuffer.limit());
     }
 
     /** {@inheritDoc} */
@@ -170,7 +175,7 @@ public class FOText extends FONode implements CharSequence, TextFragment {
             if (charBuffer != null) {
                 ft.charBuffer = CharBuffer.allocate(charBuffer.limit());
                 charBuffer.rewind();
-                ft.charBuffer.put(charBuffer);
+                ft.getCharBuffer().put(getCharBuffer());
                 ft.charBuffer.rewind();
             }
         }
@@ -232,7 +237,7 @@ public class FOText extends FONode implements CharSequence, TextFragment {
         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)
@@ -282,12 +287,12 @@ public class FOText extends FONode implements CharSequence, TextFragment {
         }
 
         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));
@@ -537,7 +542,7 @@ public class FOText extends FONode implements CharSequence, TextFragment {
             if (this.currentPosition < charBuffer.limit()) {
                 this.canRemove = true;
                 this.canReplace = true;
-                return charBuffer.get(currentPosition++);
+                return getCharBuffer().get(currentPosition++);
             } else {
                 throw new NoSuchElementException();
             }
@@ -550,13 +555,13 @@ public class FOText extends FONode implements CharSequence, TextFragment {
             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
@@ -573,7 +578,7 @@ public class FOText extends FONode implements CharSequence, TextFragment {
         public void replaceChar(char c) {
 
             if (this.canReplace) {
-                charBuffer.put(currentPosition - 1, c);
+                getCharBuffer().put(currentPosition - 1, c);
             } else {
                 throw new IllegalStateException();
             }
@@ -698,7 +703,7 @@ public class FOText extends FONode implements CharSequence, TextFragment {
         if (charBuffer == null) {
             return "";
         } else {
-            CharBuffer cb = charBuffer.duplicate();
+            Buffer cb = getCharBuffer().duplicate();
             cb.rewind();
             return cb.toString();
         }
@@ -725,12 +730,12 @@ public class FOText extends FONode implements CharSequence, TextFragment {
 
     /** {@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} */
index 929b4bf6f22c11e425a6ecdc8b787849a2aa2160..cbaace8a2e9a55207adb7afe5a2ed2aad26bc6f8 100644 (file)
@@ -21,6 +21,7 @@ package org.apache.fop.fonts;
 
 import java.awt.Rectangle;
 import java.io.InputStream;
+import java.nio.Buffer;
 import java.nio.CharBuffer;
 import java.nio.IntBuffer;
 import java.util.ArrayList;
@@ -682,8 +683,10 @@ public class MultiByteFont extends CIDFont implements Substitutable, Positionabl
             cb.put(cc);
             gb.put(gi);
         }
-        cb.flip();
-        gb.flip();
+        Buffer cbBase = cb;
+        cbBase.flip();
+        Buffer gbBase = gb;
+        gbBase.flip();
         if ((associations != null) && (associations.size() == cs.length())) {
             associations = new java.util.ArrayList(associations);
         } else {
@@ -732,7 +735,8 @@ public class MultiByteFont extends CIDFont implements Substitutable, Positionabl
             cb.put(c);
         }
 
-        cb.flip();
+        Buffer cbBase = cb;
+        cbBase.flip();
         return cb;
     }
 
@@ -799,7 +803,8 @@ public class MultiByteFont extends CIDFont implements Substitutable, Positionabl
                     nal.add(a);
                 }
             }
-            ngb.flip();
+            Buffer ngbBase = ngb;
+            ngbBase.flip();
             return new GlyphSequence(gs.getCharacters(), ngb, nal, gs.getPredications());
         } else {
             return gs;