[FOray-commit] SF.net SVN: foray:[12364] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2022-01-09 22:32:59
|
Revision: 12364
http://sourceforge.net/p/foray/code/12364
Author: victormote
Date: 2022-01-09 22:32:56 +0000 (Sun, 09 Jan 2022)
Log Message:
-----------
Conform to aXSL changes: Move more fotree-related text content features from axsl-orthography to axsl-fotree.
Modified Paths:
--------------
trunk/foray/foray-app/src/main/java/org/foray/app/ForaySpecific.java
trunk/foray/foray-app/src/test/java/org/foray/app/fo/FoDocumentReader.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTree4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeServer4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextFlow4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Root4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Orthography4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/OrthographyServer4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TextFlow4a.java
trunk/foray/foray-orthography/src/test/java/org/foray/orthography/HyphenationConsumer4aTests.java
Modified: trunk/foray/foray-app/src/main/java/org/foray/app/ForaySpecific.java
===================================================================
--- trunk/foray/foray-app/src/main/java/org/foray/app/ForaySpecific.java 2022-01-09 21:08:43 UTC (rev 12363)
+++ trunk/foray/foray-app/src/main/java/org/foray/app/ForaySpecific.java 2022-01-09 22:32:56 UTC (rev 12364)
@@ -46,6 +46,7 @@
import org.axsl.font.FontException;
import org.axsl.font.FontServer;
import org.axsl.fotree.FoTreeFactory;
+import org.axsl.fotree.text.FoOrthographyServer;
import org.axsl.graphic.GraphicServer;
import org.axsl.layout.LayoutFactory;
import org.axsl.linebreak.LineBreakerFactory;
@@ -96,7 +97,7 @@
public static ForaySession makeFOraySession(final SessionConfig sessionConfig) throws ForayException {
final Logger logger = LoggerFactory.getLogger(ForaySpecific.class);
final FontServer fontServer = ForaySpecific.makeFontServer(sessionConfig);
- final OrthographyServer hyphenServer = ForaySpecific.makeHyphenationServer(sessionConfig);
+ final FoOrthographyServer hyphenServer = ForaySpecific.makeHyphenationServer(sessionConfig);
final TextServer textServer = ForaySpecific.makeTextServer(logger, hyphenServer);
final GraphicServer graphicServer = ForaySpecific.makeGraphicServer(logger);
final FoTreeFactory foTreeServer = ForaySpecific.makeFOTreeFactory(
@@ -167,7 +168,7 @@
* @return The newly-created HyphenationServer instance.
* @throws ForayException For errors creating the hyphenation server.
*/
- public static OrthographyServer makeHyphenationServer(final SessionConfig configuration) throws ForayException {
+ public static FoOrthographyServer makeHyphenationServer(final SessionConfig configuration) throws ForayException {
final OrthographyServerConfig config = new OrthographyServerConfig();
config.setOrthographyConfigurationLocation(configuration.optionOrthographyConfiguration());
config.setWordListsBaseDirectory(configuration.optionDictionariesBaseDirectory());
@@ -212,7 +213,7 @@
final FontServer fontServer,
final GraphicServer graphicServer,
final TextServer textServer,
- final OrthographyServer hyphenationServer)
+ final FoOrthographyServer hyphenationServer)
throws ForayException {
final URL[] graphicSearchPath = buildGraphicSearchPath(configuration);
return new FoTreeServer4a(logger, fontServer, textServer, hyphenationServer,
Modified: trunk/foray/foray-app/src/test/java/org/foray/app/fo/FoDocumentReader.java
===================================================================
--- trunk/foray/foray-app/src/test/java/org/foray/app/fo/FoDocumentReader.java 2022-01-09 21:08:43 UTC (rev 12363)
+++ trunk/foray/foray-app/src/test/java/org/foray/app/fo/FoDocumentReader.java 2022-01-09 22:32:56 UTC (rev 12364)
@@ -40,8 +40,8 @@
import org.axsl.font.FontConsumer;
import org.axsl.font.FontServer;
import org.axsl.fotree.FoTreeException;
+import org.axsl.fotree.text.FoOrthographyServer;
import org.axsl.graphic.GraphicServer;
-import org.axsl.orthography.OrthographyServer;
import org.axsl.text.TextServer;
import org.slf4j.Logger;
@@ -90,7 +90,7 @@
final FontServer fontServer = ForaySpecific.makeFontServer(sessionConfig);
final GraphicServer graphicServer = ForaySpecific.makeGraphicServer(logger);
- final OrthographyServer hyphenServer = ForaySpecific.makeHyphenationServer(sessionConfig);
+ final FoOrthographyServer hyphenServer = ForaySpecific.makeHyphenationServer(sessionConfig);
final TextServer textServer = ForaySpecific.makeTextServer(logger, hyphenServer);
final URL[] graphicSearchPath = new URL[1];
final URL testDirUrl = this.testDirectory.toURI().toURL();
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java 2022-01-09 21:08:43 UTC (rev 12363)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java 2022-01-09 22:32:56 UTC (rev 12364)
@@ -140,6 +140,7 @@
import org.axsl.fotree.fo.FoTextCharacters;
import org.axsl.fotree.fo.Marker;
import org.axsl.fotree.fo.prop.WritingModePa;
+import org.axsl.fotree.text.FoOrthographyServer;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicServer;
import org.axsl.orthography.Orthography;
@@ -3640,7 +3641,7 @@
* Returns the orthography server.
* @return The orthography server.
*/
- public OrthographyServer getOrthographyServer() {
+ public FoOrthographyServer getOrthographyServer() {
return getParent().getOrthographyServer();
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTree4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTree4a.java 2022-01-09 21:08:43 UTC (rev 12363)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTree4a.java 2022-01-09 22:32:56 UTC (rev 12364)
@@ -38,8 +38,8 @@
import org.axsl.font.FontConsumer;
import org.axsl.fotree.FoTree;
+import org.axsl.fotree.text.FoOrthographyServer;
import org.axsl.graphic.GraphicServer;
-import org.axsl.orthography.OrthographyServer;
import org.axsl.speech.SpeechServer;
import org.slf4j.Logger;
@@ -70,7 +70,7 @@
private SpeechServer speechServer;
/** The orthography server. */
- private OrthographyServer orthographyServer;
+ private FoOrthographyServer orthographyServer;
/** The URLs to be searched when looking for graphics files. */
private URL[] graphicSearchPath;
@@ -138,12 +138,12 @@
}
@Override
- public void setOrthographyServer(final OrthographyServer orthographyServer) {
+ public void setOrthographyServer(final FoOrthographyServer orthographyServer) {
this.orthographyServer = orthographyServer;
}
@Override
- public OrthographyServer getOrthographyServer() {
+ public FoOrthographyServer getOrthographyServer() {
return this.orthographyServer;
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeServer4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeServer4a.java 2022-01-09 21:08:43 UTC (rev 12363)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeServer4a.java 2022-01-09 22:32:56 UTC (rev 12364)
@@ -38,8 +38,8 @@
import org.axsl.font.FontServer;
import org.axsl.fotree.FoTreeFactory;
+import org.axsl.fotree.text.FoOrthographyServer;
import org.axsl.graphic.GraphicServer;
-import org.axsl.orthography.OrthographyServer;
import org.axsl.text.TextServer;
import org.slf4j.Logger;
@@ -70,7 +70,7 @@
private TextServer textServer;
/** The hyphenation server. */
- private OrthographyServer orthographyServer;
+ private FoOrthographyServer orthographyServer;
/** The array of URLs in which graphics should be searched. */
private URL[] graphicSearchPath;
@@ -116,7 +116,7 @@
public FoTreeServer4a(final Logger logger,
final FontServer fontServer,
final TextServer textServer,
- final OrthographyServer orthographyServer,
+ final FoOrthographyServer orthographyServer,
final GraphicServer graphicServer,
final URL[] graphicSearchPath,
final boolean cachingGraphics) {
@@ -312,7 +312,7 @@
return this.graphicServer;
}
- public OrthographyServer getOrthographyServer() {
+ public FoOrthographyServer getOrthographyServer() {
return this.orthographyServer;
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextFlow4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextFlow4a.java 2022-01-09 21:08:43 UTC (rev 12363)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextFlow4a.java 2022-01-09 22:32:56 UTC (rev 12364)
@@ -33,8 +33,8 @@
import org.axsl.common.para.ParaBranch;
import org.axsl.common.para.ParaLeaf;
import org.axsl.common.para.ParaNode;
-import org.axsl.orthography.Token;
-import org.axsl.orthography.TokenFlow;
+import org.axsl.fotree.text.FoToken;
+import org.axsl.fotree.text.FoTokenFlow;
import org.axsl.orthography.TokenFlowFactory;
import java.util.ArrayList;
@@ -42,9 +42,9 @@
import java.util.ListIterator;
/**
- * FOray implementation of {@link TokenFlow}.
+ * FOray implementation of {@link FoTokenFlow}.
*/
-public class FoTextFlow4a implements TokenFlow, ParaBranch {
+public class FoTextFlow4a implements FoTokenFlow, ParaBranch {
/** Singleton factory. */
private static final TokenFlowFactory<FoTextFlow4a> FACTORY = new TokenFlowFactory<FoTextFlow4a>() {
@@ -55,7 +55,7 @@
};
/** The tokens (children) of this token flow. */
- private List<Token> tokens = new ArrayList<Token>();
+ private List<FoToken> tokens = new ArrayList<FoToken>();
@Override
public int qtyTokens() {
@@ -63,12 +63,12 @@
}
@Override
- public Token tokenAt(final int index) {
+ public FoToken tokenAt(final int index) {
return this.tokens.get(index);
}
@Override
- public void addToken(final Token segment) {
+ public void addToken(final FoToken segment) {
this.tokens.add(segment);
}
@@ -117,7 +117,7 @@
@Override
public void addNode(final ParaNode node) {
- this.tokens.add((Token) node);
+ this.tokens.add((FoToken) node);
}
@Override
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java 2022-01-09 21:08:43 UTC (rev 12363)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java 2022-01-09 22:32:56 UTC (rev 12364)
@@ -39,10 +39,11 @@
import org.axsl.fotree.FoContext;
import org.axsl.fotree.FoVisitor;
import org.axsl.fotree.fo.FoTextWords;
-import org.axsl.orthography.Orthography;
+import org.axsl.fotree.text.FoOrthography;
+import org.axsl.fotree.text.FoOrthographyServer;
+import org.axsl.fotree.text.FoToken;
+import org.axsl.fotree.text.FoTokenFlow;
import org.axsl.orthography.OrthographyException;
-import org.axsl.orthography.OrthographyServer;
-import org.axsl.orthography.Token;
import java.util.ArrayList;
import java.util.List;
@@ -60,7 +61,7 @@
private List<FoWordSequenceContent> content;
/** The parsed words. */
- private FoTextFlow4a paraBranch;
+ private FoTokenFlow paraBranch;
/**
* Constructor.
@@ -71,9 +72,9 @@
public FoTextWords4a(final FoObj parent, final CharSequence content) throws OrthographyException {
super(parent);
this.parent = parent;
- final OrthographyServer orthographyServer = getOrthographyServer();
- final Orthography orthography = orthographyServer.getOrthography(getWritingSystem());
- this.paraBranch = orthography.tokenize(FoTextFlow4a.getFactory(), content, 0, content.length());
+ final FoOrthographyServer orthographyServer = getOrthographyServer();
+ final FoOrthography orthography = orthographyServer.getOrthography(getWritingSystem());
+ this.paraBranch = orthography.tokenize(content, 0, content.length());
this.content = new ArrayList<FoWordSequenceContent>(this.paraBranch.qtyParaNodes());
for (int index = 0; index < this.paraBranch.qtyParaNodes(); index ++) {
final ParaNode wordSequenceContent = this.paraBranch.paraNodeAt(index);
@@ -100,7 +101,7 @@
@Override
public void addNode(final ParaNode node) {
- this.paraBranch.addToken((Token) node);
+ this.paraBranch.addToken((FoToken) node);
}
@Override
@@ -257,13 +258,13 @@
}
@Override
- public Token tokenAt(final int index) {
+ public FoToken tokenAt(final int index) {
// TODO Auto-generated method stub
return null;
}
@Override
- public void addToken(final Token token) {
+ public void addToken(final FoToken token) {
// TODO Auto-generated method stub
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Root4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Root4a.java 2022-01-09 21:08:43 UTC (rev 12363)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Root4a.java 2022-01-09 22:32:56 UTC (rev 12364)
@@ -40,7 +40,7 @@
import org.axsl.fotree.FoTreeException;
import org.axsl.fotree.FoVisitor;
import org.axsl.fotree.fo.Root;
-import org.axsl.orthography.OrthographyServer;
+import org.axsl.fotree.text.FoOrthographyServer;
import org.slf4j.Logger;
@@ -504,7 +504,7 @@
}
@Override
- public OrthographyServer getOrthographyServer() {
+ public FoOrthographyServer getOrthographyServer() {
return this.treeBuilder.getOrthographyServer();
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Orthography4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Orthography4a.java 2022-01-09 21:08:43 UTC (rev 12363)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Orthography4a.java 2022-01-09 22:32:56 UTC (rev 12364)
@@ -35,11 +35,11 @@
import org.foray.orthography.wrapper.ExactWord;
import org.foray.orthography.wrapper.UppercaseWord;
+import org.axsl.fotree.text.FoOrthography;
+import org.axsl.fotree.text.FoToken;
import org.axsl.fotree.text.FoWord;
-import org.axsl.orthography.Orthography;
import org.axsl.orthography.OrthographyException;
import org.axsl.orthography.TokenFlow;
-import org.axsl.orthography.TokenFlowFactory;
import org.axsl.orthography.Word;
import org.axsl.orthography.optional.Dictionary;
import org.axsl.orthography.optional.Lexer;
@@ -52,7 +52,7 @@
/**
* The resources (dictionaries, word wrappers, hyphenation patterns, etc.) that should be used by a given orthography.
*/
-public class Orthography4a implements Orthography {
+public class Orthography4a implements FoOrthography {
/** The list of ids to lists of regex patterns, which, for this orthography, signal a valid word if matched. */
private List<String> matchRuleListIds = new ArrayList<String>();
@@ -262,7 +262,7 @@
}
@Override
- public Word recognizeWord(final CharSequence wordChars, final int offset, final int length,
+ public FoWord recognizeWord(final CharSequence wordChars, final int offset, final int length,
final Word.PartOfSpeech pos, final List<Dictionary> adhocDictionaries) {
// TODO Auto-generated method stub
return null;
@@ -362,7 +362,7 @@
}
@Override
- public Word hyphenateUnrecognizedWord(final CharSequence word, final int offset, final int length) {
+ public FoWord hyphenateUnrecognizedWord(final CharSequence word, final int offset, final int length) {
/* The character sequence containing the characters in the word that we are looking for. */
final CharSequence chars = word.subSequence(offset, offset + length);
FoWord hyphenatedWord = null;
@@ -408,9 +408,9 @@
}
@Override
- public <T extends TokenFlow> T tokenize(final TokenFlowFactory<T> factory,
- final CharSequence characters, final int startIndex, final int length) throws OrthographyException {
- final T wordSequence = factory.makeTextFlow();
+ public TextFlow4a tokenize(final CharSequence characters, final int startIndex, final int length)
+ throws OrthographyException {
+ final TextFlow4a wordSequence = new TextFlow4a();
final CharSequence sequence = characters.subSequence(startIndex, startIndex + length);
final List<CharSequence> chunks = this.lexer.tokenize(sequence);
@@ -425,7 +425,7 @@
parseInterwordContent(wordSequence, chunk);
} else {
/* Chunk is a word. */
- Word word = recognizeWord(chunk, 0, chunk.length(), null, null);
+ FoWord word = recognizeWord(chunk, 0, chunk.length(), null, null);
if (word == null) {
word = hyphenateUnrecognizedWord(chunk, 0, chunk.length());
}
@@ -438,7 +438,7 @@
return wordSequence;
}
- private void parseInterwordContent(final TokenFlow wordSequence, final CharSequence interword)
+ private void parseInterwordContent(final TokenFlow<FoToken> wordSequence, final CharSequence interword)
throws OrthographyException {
int index = 0;
while (index < interword.length()) {
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/OrthographyServer4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/OrthographyServer4a.java 2022-01-09 21:08:43 UTC (rev 12363)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/OrthographyServer4a.java 2022-01-09 22:32:56 UTC (rev 12364)
@@ -41,8 +41,8 @@
import org.foray.orthography.util.OrthographyParser;
import org.axsl.common.i18n.Language;
+import org.axsl.fotree.text.FoOrthographyServer;
import org.axsl.orthography.OrthographyException;
-import org.axsl.orthography.OrthographyServer;
import org.axsl.orthography.WritingSystem;
import org.slf4j.Logger;
@@ -66,7 +66,7 @@
/**
* This class is the main entry point to the hyphenation package.
*/
-public class OrthographyServer4a implements OrthographyServer {
+public class OrthographyServer4a implements FoOrthographyServer {
/** The logger. */
private Logger logger = LoggerFactory.getLogger(OrthographyServer4a.class);
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TextFlow4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TextFlow4a.java 2022-01-09 21:08:43 UTC (rev 12363)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TextFlow4a.java 2022-01-09 22:32:56 UTC (rev 12364)
@@ -28,17 +28,21 @@
package org.foray.orthography;
-import org.axsl.orthography.Token;
-import org.axsl.orthography.TokenFlow;
+import org.axsl.common.para.ParaBranch;
+import org.axsl.common.para.ParaLeaf;
+import org.axsl.common.para.ParaNode;
+import org.axsl.fotree.text.FoToken;
+import org.axsl.fotree.text.FoTokenFlow;
import org.axsl.orthography.TokenFlowFactory;
import java.util.ArrayList;
import java.util.List;
+import java.util.ListIterator;
/**
- * FOray implementation of {@link TokenFlow}.
+ * FOray implementation of {@link FoTokenFlow}.
*/
-public class TextFlow4a implements TokenFlow {
+public class TextFlow4a implements FoTokenFlow {
/** Singleton factory. */
private static final TokenFlowFactory<TextFlow4a> FACTORY = new TokenFlowFactory<TextFlow4a>() {
@@ -49,7 +53,7 @@
};
/** The tokens (children) of this text flow. */
- private List<Token> tokens = new ArrayList<Token>();
+ private List<FoToken> tokens = new ArrayList<FoToken>();
@Override
public int qtyTokens() {
@@ -57,12 +61,12 @@
}
@Override
- public Token tokenAt(final int index) {
+ public FoToken tokenAt(final int index) {
return this.tokens.get(index);
}
@Override
- public void addToken(final Token segment) {
+ public void addToken(final FoToken segment) {
this.tokens.add(segment);
}
@@ -74,4 +78,65 @@
return FACTORY;
}
+ @Override
+ public ParaNode paraNodeAt(final int nodeIndex) {
+ return this.tokens.get(nodeIndex);
+ }
+
+ @Override
+ public void addNode(final ParaNode node) {
+ throw new UnsupportedOperationException("Use addToken(FoToken) instead.");
+ }
+
+ @Override
+ public ParaLeaf paraLeafAt(final int leafIndex) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ListIterator<ParaLeaf> leafIterator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Type getParaNodeType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ParaLeaf asParaLeaf() {
+ return null;
+ }
+
+ @Override
+ public ParaBranch asParaBranch() {
+ return this;
+ }
+
+ @Override
+ public int qtyParaNodes() {
+ return this.tokens.size();
+ }
+
+ @Override
+ public int qtyParaLeaves() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int qtyKpLeaves() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public CharSequence getText() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
Modified: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/HyphenationConsumer4aTests.java
===================================================================
--- trunk/foray/foray-orthography/src/test/java/org/foray/orthography/HyphenationConsumer4aTests.java 2022-01-09 21:08:43 UTC (rev 12363)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/HyphenationConsumer4aTests.java 2022-01-09 22:32:56 UTC (rev 12364)
@@ -82,7 +82,7 @@
/* Spoken by Henry, Henry V, Act III Scene 1. */
final String testString = "Once more unto the breach, dear friends, once more;";
final TextFlow4a wordSequence =
- this.consumer.tokenize(TextFlow4a.getFactory(), testString, 0, testString.length());
+ this.consumer.tokenize(testString, 0, testString.length());
Assert.assertEquals(20, wordSequence.qtyTokens());
Assert.assertEquals("Once", wordSequence.tokenAt(0).toString());
Assert.assertEquals(" ", wordSequence.tokenAt(1).toString());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|