[FOray-commit] SF.net SVN: foray:[12296] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2021-12-29 22:14:08
|
Revision: 12296
http://sourceforge.net/p/foray/code/12296
Author: victormote
Date: 2021-12-29 22:14:05 +0000 (Wed, 29 Dec 2021)
Log Message:
-----------
Rename resolver class to make it more general.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/DictionaryParser.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/NatLangParser.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/OrthographyParser.java
Added Paths:
-----------
trunk/foray/foray-common/src/main/java/org/foray/common/ForayEntityResolver.java
Removed Paths:
-------------
trunk/foray/foray-common/src/main/java/org/foray/common/AxslDtdUtil.java
Deleted: trunk/foray/foray-common/src/main/java/org/foray/common/AxslDtdUtil.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/AxslDtdUtil.java 2021-12-29 21:45:24 UTC (rev 12295)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/AxslDtdUtil.java 2021-12-29 22:14:05 UTC (rev 12296)
@@ -1,113 +0,0 @@
-/*
- * Copyright 2009 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.common;
-
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Utilities related to the aXSL DTDs.
- */
-public final class AxslDtdUtil {
-
- /** The public id of the "natural language" DTD. */
- public static final String NATURAL_LANGUAGE_PUBLIC_ID = "-//aXSL//DTD Natural Language V0.1//EN";
-
- /** The public id of the "hyphenation" DTD. */
- public static final String HYPHENATION_PUBLIC_ID = "-//aXSL//DTD Hyphenation V0.1//EN";
-
- /** The public id of the "dictionary" DTD. */
- public static final String DICTIONARY_PUBLIC_ID = "-//aXSL//DTD Dictionary V0.1//EN";
-
- /** The public id of the "font config" DTD. */
- public static final String FONT_CONFIG_PUBLIC_ID = "-//aXSL//DTD Font Configuration V0.1//EN";
-
- /** The public id of the "orthography config" DTD. */
- public static final String ORTHOGRAPHY_CONFIG_PUBLIC_ID = "-//aXSL//DTD Orthography Configuration V0.1//EN";
-
- /** The public id of the "area tree" DTD. */
- public static final String AREA_TREE_PUBLIC_ID = "-//aXSL//DTD Area Tree V0.1//EN";
-
- /** The public id of the "parts of speech" DTD. */
- public static final String PARTS_OF_SPEECH = "-//aXSL//DTD Parts of Speech V0.1//EN";
-
- /**
- * Private Constructor. This class is a utility class and should never be instantiated.
- */
- private AxslDtdUtil() { }
-
- /**
- * Returns an aXSL DTD as an InputStream.
- * @param dtdName The name of the DTD to be retrieved.
- * @return The appropriate aXSL DTD, or null if not found.
- */
- public static InputStream getAxslDtdAsInputStream(final String dtdName) {
- final InputStream theStream = AxslDtdUtil.class.getResourceAsStream("/resources/org/axsl/dtds/" + dtdName);
- return theStream;
- }
-
- /**
- * Create an entity resolver that knows how to find the local copy of all aXSL DTDs.
- * @return An entity resolver for the appropriate DTD, or null if none is found.
- */
- public static EntityResolver getEntityResolver() {
- final EntityResolver resolver = new EntityResolver() {
- public InputSource resolveEntity(final String publicId, final String systemId) throws SAXException,
- IOException {
- InputStream inputStream = null;
- if (AxslDtdUtil.NATURAL_LANGUAGE_PUBLIC_ID.equals(publicId)) {
- inputStream = AxslDtdUtil.getAxslDtdAsInputStream("axsl-natural-language.dtd");
- } else if (AxslDtdUtil.HYPHENATION_PUBLIC_ID.equals(publicId)) {
- inputStream = AxslDtdUtil.getAxslDtdAsInputStream("axsl-hyphenation.dtd");
- } else if (AxslDtdUtil.DICTIONARY_PUBLIC_ID.equals(publicId)) {
- inputStream = AxslDtdUtil.getAxslDtdAsInputStream("axsl-dictionary.dtd");
- } else if (AxslDtdUtil.FONT_CONFIG_PUBLIC_ID.equals(publicId)) {
- inputStream = AxslDtdUtil.getAxslDtdAsInputStream("axsl-font-config.dtd");
- } else if (AxslDtdUtil.ORTHOGRAPHY_CONFIG_PUBLIC_ID.equals(publicId)) {
- inputStream = AxslDtdUtil.getAxslDtdAsInputStream("axsl-orthography-config.dtd");
- } else if (AxslDtdUtil.AREA_TREE_PUBLIC_ID.equals(publicId)) {
- inputStream = AxslDtdUtil.getAxslDtdAsInputStream("axsl-area-tree.dtd");
- } else if (AxslDtdUtil.PARTS_OF_SPEECH.equals(publicId)) {
- inputStream = AxslDtdUtil.getAxslDtdAsInputStream("axsl-parts-of-speech.dtd");
- }
- if (inputStream == null) {
- return null;
- }
- final InputSource inputSource = new InputSource(inputStream);
- return inputSource;
- }
- };
- return resolver;
- }
-
-}
Copied: trunk/foray/foray-common/src/main/java/org/foray/common/ForayEntityResolver.java (from rev 12181, trunk/foray/foray-common/src/main/java/org/foray/common/AxslDtdUtil.java)
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/ForayEntityResolver.java (rev 0)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/ForayEntityResolver.java 2021-12-29 22:14:05 UTC (rev 12296)
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2009 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.common;
+
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Utilities related to the aXSL DTDs.
+ */
+public final class ForayEntityResolver {
+
+ /** The public id of the "natural language" DTD. */
+ public static final String NATURAL_LANGUAGE_PUBLIC_ID = "-//aXSL//DTD Natural Language V0.1//EN";
+
+ /** The public id of the "hyphenation" DTD. */
+ public static final String HYPHENATION_PUBLIC_ID = "-//aXSL//DTD Hyphenation V0.1//EN";
+
+ /** The public id of the "dictionary" DTD. */
+ public static final String DICTIONARY_PUBLIC_ID = "-//aXSL//DTD Dictionary V0.1//EN";
+
+ /** The public id of the "font config" DTD. */
+ public static final String FONT_CONFIG_PUBLIC_ID = "-//aXSL//DTD Font Configuration V0.1//EN";
+
+ /** The public id of the "orthography config" DTD. */
+ public static final String ORTHOGRAPHY_CONFIG_PUBLIC_ID = "-//aXSL//DTD Orthography Configuration V0.1//EN";
+
+ /** The public id of the "area tree" DTD. */
+ public static final String AREA_TREE_PUBLIC_ID = "-//aXSL//DTD Area Tree V0.1//EN";
+
+ /** The public id of the "parts of speech" DTD. */
+ public static final String PARTS_OF_SPEECH = "-//aXSL//DTD Parts of Speech V0.1//EN";
+
+ /**
+ * Private Constructor. This class is a utility class and should never be instantiated.
+ */
+ private ForayEntityResolver() { }
+
+ /**
+ * Returns an aXSL DTD as an InputStream.
+ * @param dtdName The name of the DTD to be retrieved.
+ * @return The appropriate aXSL DTD, or null if not found.
+ */
+ public static InputStream getAxslDtdAsInputStream(final String dtdName) {
+ final InputStream theStream =
+ ForayEntityResolver.class.getResourceAsStream("/resources/org/axsl/dtds/" + dtdName);
+ return theStream;
+ }
+
+ /**
+ * Create an entity resolver that knows how to find the local copy of all aXSL DTDs.
+ * @return An entity resolver for the appropriate DTD, or null if none is found.
+ */
+ public static EntityResolver getEntityResolver() {
+ final EntityResolver resolver = new EntityResolver() {
+ public InputSource resolveEntity(final String publicId, final String systemId) throws SAXException,
+ IOException {
+ InputStream inputStream = null;
+ if (ForayEntityResolver.NATURAL_LANGUAGE_PUBLIC_ID.equals(publicId)) {
+ inputStream = ForayEntityResolver.getAxslDtdAsInputStream("axsl-natural-language.dtd");
+ } else if (ForayEntityResolver.HYPHENATION_PUBLIC_ID.equals(publicId)) {
+ inputStream = ForayEntityResolver.getAxslDtdAsInputStream("axsl-hyphenation.dtd");
+ } else if (ForayEntityResolver.DICTIONARY_PUBLIC_ID.equals(publicId)) {
+ inputStream = ForayEntityResolver.getAxslDtdAsInputStream("axsl-dictionary.dtd");
+ } else if (ForayEntityResolver.FONT_CONFIG_PUBLIC_ID.equals(publicId)) {
+ inputStream = ForayEntityResolver.getAxslDtdAsInputStream("axsl-font-config.dtd");
+ } else if (ForayEntityResolver.ORTHOGRAPHY_CONFIG_PUBLIC_ID.equals(publicId)) {
+ inputStream = ForayEntityResolver.getAxslDtdAsInputStream("axsl-orthography-config.dtd");
+ } else if (ForayEntityResolver.AREA_TREE_PUBLIC_ID.equals(publicId)) {
+ inputStream = ForayEntityResolver.getAxslDtdAsInputStream("axsl-area-tree.dtd");
+ } else if (ForayEntityResolver.PARTS_OF_SPEECH.equals(publicId)) {
+ inputStream = ForayEntityResolver.getAxslDtdAsInputStream("axsl-parts-of-speech.dtd");
+ }
+ if (inputStream == null) {
+ return null;
+ }
+ final InputSource inputSource = new InputSource(inputStream);
+ return inputSource;
+ }
+ };
+ return resolver;
+ }
+
+}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java 2021-12-29 21:45:24 UTC (rev 12295)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java 2021-12-29 22:14:05 UTC (rev 12296)
@@ -28,7 +28,7 @@
package org.foray.font.config;
-import org.foray.common.AxslDtdUtil;
+import org.foray.common.ForayEntityResolver;
import org.foray.common.url.UrlFactory;
import org.foray.common.xml.SaxParser;
import org.foray.font.FontServer4a;
@@ -150,7 +150,7 @@
@Override
public Object parse(final InputSource inputSource) throws IOException, ParserConfigurationException, SAXException {
- final XMLReader parser = createSax2Parser(true, true, true, AxslDtdUtil.getEntityResolver(), false);
+ final XMLReader parser = createSax2Parser(true, true, true, ForayEntityResolver.getEntityResolver(), false);
parser.parse(inputSource);
return null;
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/DictionaryParser.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/DictionaryParser.java 2021-12-29 21:45:24 UTC (rev 12295)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/DictionaryParser.java 2021-12-29 22:14:05 UTC (rev 12296)
@@ -28,7 +28,7 @@
package org.foray.orthography.util;
-import org.foray.common.AxslDtdUtil;
+import org.foray.common.ForayEntityResolver;
import org.foray.common.i18n.WritingSystem4a;
import org.foray.common.primitive.StringUtils;
import org.foray.common.xml.SaxParser;
@@ -141,7 +141,7 @@
throws IOException, SAXException, ParserConfigurationException {
getLogger().debug("Begin dictionary word list parsing: " + inputSource.getSystemId());
- final XMLReader parser = this.createSax2Parser(true, true, true, AxslDtdUtil.getEntityResolver(), false);
+ final XMLReader parser = createSax2Parser(true, true, true, ForayEntityResolver.getEntityResolver(), false);
if (parser != null) {
parser.parse(inputSource);
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/NatLangParser.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/NatLangParser.java 2021-12-29 21:45:24 UTC (rev 12295)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/NatLangParser.java 2021-12-29 22:14:05 UTC (rev 12296)
@@ -28,7 +28,7 @@
package org.foray.orthography.util;
-import org.foray.common.AxslDtdUtil;
+import org.foray.common.ForayEntityResolver;
import org.foray.common.primitive.UnicodeCharUtils;
import org.foray.common.xml.SaxParser;
@@ -57,7 +57,7 @@
@Override
public NaturalLanguage parse(final InputSource inputSource)
throws IOException, SAXException, ParserConfigurationException {
- final XMLReader parser = createSax2Parser(false, true, true, AxslDtdUtil.getEntityResolver(), false);
+ final XMLReader parser = createSax2Parser(false, true, true, ForayEntityResolver.getEntityResolver(), false);
parser.parse(inputSource);
return this.nl;
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/OrthographyParser.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/OrthographyParser.java 2021-12-29 21:45:24 UTC (rev 12295)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/OrthographyParser.java 2021-12-29 22:14:05 UTC (rev 12296)
@@ -28,7 +28,7 @@
package org.foray.orthography.util;
-import org.foray.common.AxslDtdUtil;
+import org.foray.common.ForayEntityResolver;
import org.foray.common.i18n.Country4a;
import org.foray.common.i18n.Language4a;
import org.foray.common.i18n.Script4a;
@@ -152,7 +152,7 @@
@Override
public Orthography4a parse(final InputSource inputSource)
throws IOException, SAXException, ParserConfigurationException {
- final XMLReader parser = createSax2Parser(true, true, true, AxslDtdUtil.getEntityResolver(), false);
+ final XMLReader parser = createSax2Parser(true, true, true, ForayEntityResolver.getEntityResolver(), false);
parser.parse(inputSource);
return this.currentOrthographyConfig;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|