[FOray-commit] SF.net SVN: foray:[12213] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2021-12-13 16:12:35
|
Revision: 12213
http://sourceforge.net/p/foray/code/12213
Author: victormote
Date: 2021-12-13 16:12:32 +0000 (Mon, 13 Dec 2021)
Log Message:
-----------
Steps toward cleaning up CharSequence hierarchy.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/AbstractCharacterSequence.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Character4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/CharacterSequence4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoWordSequence.java
trunk/foray/master/ide/eclipse/launch-configurations/fonts-basic.launch
trunk/foray/master/ide/eclipse/launch-configurations/graphics-basic.launch
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/AbstractCharacterSequence.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/AbstractCharacterSequence.java 2021-12-13 01:11:21 UTC (rev 12212)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/AbstractCharacterSequence.java 2021-12-13 16:12:32 UTC (rev 12213)
@@ -58,7 +58,7 @@
/**
* Abstract superclass for representations of characters.
*/
-public abstract class AbstractCharacterSequence extends FoObj implements CharacterSequence {
+public abstract class AbstractCharacterSequence extends FoObj implements CharacterSequence, CharSequence {
/** Constant indicating that a given character should be discarded. */
public static final char DISCARD_CHAR = 0xFFFF;
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Character4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Character4a.java 2021-12-13 01:11:21 UTC (rev 12212)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Character4a.java 2021-12-13 16:12:32 UTC (rev 12213)
@@ -52,7 +52,7 @@
/**
* A "character" object in XSL-FO.
*/
-public class Character4a extends FoObj implements Character {
+public class Character4a extends FoObj implements Character, CharSequence {
/** The parent of this node. */
private FoObj parent;
@@ -422,4 +422,26 @@
return false;
}
+ @Override
+ public int length() {
+ return 1;
+ }
+
+ @Override
+ public char charAt(final int index) {
+ if (index != 0) {
+ throw new IndexOutOfBoundsException();
+ }
+ return traitCharacter();
+ }
+
+ @Override
+ public CharSequence subSequence(final int start, final int end) {
+ if (start != 0
+ || end != 1) {
+ throw new IndexOutOfBoundsException();
+ }
+ return java.lang.Character.toString(traitCharacter());
+ }
+
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/CharacterSequence4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/CharacterSequence4a.java 2021-12-13 01:11:21 UTC (rev 12212)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/CharacterSequence4a.java 2021-12-13 16:12:32 UTC (rev 12213)
@@ -466,4 +466,19 @@
return false;
}
+ @Override
+ public int length() {
+ return this.ca.length();
+ }
+
+ @Override
+ public char charAt(final int index) {
+ return this.ca.charAt(index);
+ }
+
+ @Override
+ public CharSequence subSequence(final int start, final int end) {
+ return this.ca.subSequence(start, end);
+ }
+
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoWordSequence.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoWordSequence.java 2021-12-13 01:11:21 UTC (rev 12212)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoWordSequence.java 2021-12-13 16:12:32 UTC (rev 12213)
@@ -130,4 +130,42 @@
return false;
}
+ @Override
+ public int length() {
+ int totalLength = 0;
+ for (int index = 0; index < this.content.size(); index ++) {
+ totalLength += this.content.get(index).length();
+ }
+ return totalLength;
+ }
+
+ @Override
+ public char charAt(final int charIndex) {
+ if (charIndex < 0) {
+ throw new IndexOutOfBoundsException();
+ }
+ int totalLength = 0;
+ for (int index = 0; index < this.content.size(); index ++) {
+ final int currentLength = this.content.get(index).length();
+ totalLength += currentLength;
+ if (totalLength > charIndex) {
+ final int currentIndex = charIndex - (totalLength - currentLength);
+ return this.content.get(index).charAt(currentIndex);
+ }
+ }
+ throw new IndexOutOfBoundsException();
+ }
+
+ @Override
+ public CharSequence subSequence(final int start, final int end) {
+ /* TODO: This is horrible performance-wise, but should not be used much. If that turns out to not be true, it
+ * needs to be rewritten, probably using a character iterator concept. */
+ final StringBuilder builder = new StringBuilder();
+ for (int index = start; index < end; index ++) {
+ final char c = charAt(index);
+ builder.append(c);
+ }
+ return builder.toString();
+ }
+
}
Modified: trunk/foray/master/ide/eclipse/launch-configurations/fonts-basic.launch
===================================================================
--- trunk/foray/master/ide/eclipse/launch-configurations/fonts-basic.launch 2021-12-13 01:11:21 UTC (rev 12212)
+++ trunk/foray/master/ide/eclipse/launch-configurations/fonts-basic.launch 2021-12-13 16:12:32 UTC (rev 12213)
@@ -15,7 +15,7 @@
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.foray.app.FOray"/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="foray-app"/>
- <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-configuration-file ${foray-config} -fo ${fo-example-path}/basic/fonts.fo -pdf ${foray-test-output}/fonts-basic.pdf"/>
+ <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-configuration-file ${foray-config} -fo ${fo-example-path}/basic/fonts.fo -pdf ${foray-test-output-file}/fonts-basic.pdf"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="foray-app"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
</launchConfiguration>
Modified: trunk/foray/master/ide/eclipse/launch-configurations/graphics-basic.launch
===================================================================
--- trunk/foray/master/ide/eclipse/launch-configurations/graphics-basic.launch 2021-12-13 01:11:21 UTC (rev 12212)
+++ trunk/foray/master/ide/eclipse/launch-configurations/graphics-basic.launch 2021-12-13 16:12:32 UTC (rev 12213)
@@ -15,7 +15,7 @@
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.foray.app.FOray"/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="foray-app"/>
- <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-configuration-file ${foray-config} -fo ${fo-example-path}/basic/graphics.fo -pdf ${foray-test-output}/graphics-basic.pdf"/>
+ <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-configuration-file ${foray-config} -fo ${fo-example-path}/basic/graphics.fo -pdf ${foray-test-output-file}/graphics-basic.pdf"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="foray-app"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
</launchConfiguration>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|