Thread: [FOray-commit] SF.net SVN: foray:[10798] trunk/foray (Page 3)
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2009-04-29 16:22:14
|
Revision: 10798
http://foray.svn.sourceforge.net/foray/?rev=10798&view=rev
Author: victormote
Date: 2009-04-29 16:22:11 +0000 (Wed, 29 Apr 2009)
Log Message:
-----------
1. Make CharSet an implementation of the aXSL CharSet interface.
2. Conform to the aXSL CharSet requirements, renaming a method.
Modified Paths:
--------------
trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java
trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java
trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFilePFM.java
trunk/foray/foray-font/src/java/org/foray/font/output/FontOutput4a.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSet.java
Modified: trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java 2009-04-29 16:05:47 UTC (rev 10797)
+++ trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java 2009-04-29 16:22:11 UTC (rev 10798)
@@ -272,7 +272,7 @@
*/
public int width(final int c, final int fontSize) {
final int metricIndex =
- this.metricsFile.getCharSet().getCharSetIndex(c);
+ this.metricsFile.getCharSet().getIndex(c);
if (metricIndex < 0
|| metricIndex > this.getWidths().length) {
return Integer.MIN_VALUE;
@@ -367,7 +367,7 @@
* {@inheritDoc}
*/
public boolean glyphAvailable(final int c) {
- return this.getCharSet().getCharSetIndex(c) != -1;
+ return this.getCharSet().getIndex(c) != -1;
}
/**
Modified: trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java 2009-04-29 16:05:47 UTC (rev 10797)
+++ trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java 2009-04-29 16:22:11 UTC (rev 10798)
@@ -1564,7 +1564,7 @@
this.nextCharArrayIndex++;
this.codePoints[charIndex] = theChar;
} else {
- charIndex = this.charSet.getCharSetIndex(theChar);
+ charIndex = this.charSet.getIndex(theChar);
}
final short[] extentTable = this.getExtentTable();
if (charIndex < 0
Modified: trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFilePFM.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFilePFM.java 2009-04-29 16:05:47 UTC (rev 10797)
+++ trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFilePFM.java 2009-04-29 16:22:11 UTC (rev 10798)
@@ -392,7 +392,7 @@
final char encodedIndex = (char) i;
final int codePoint = internalEncoding.decodeCharacter(
encodedIndex);
- final int charSetIndex = charSet.getCharSetIndex(codePoint);
+ final int charSetIndex = charSet.getIndex(codePoint);
if (charSetIndex < 0
|| charSetIndex >= extentTable.length) {
continue;
Modified: trunk/foray/foray-font/src/java/org/foray/font/output/FontOutput4a.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/output/FontOutput4a.java 2009-04-29 16:05:47 UTC (rev 10797)
+++ trunk/foray/foray-font/src/java/org/foray/font/output/FontOutput4a.java 2009-04-29 16:22:11 UTC (rev 10798)
@@ -227,7 +227,7 @@
// Decode the character for this index
final int codePoint = encoding.decodeCharacter(i);
// Find the charSet index for that character.
- final int charSetIndex = charSet.getCharSetIndex(codePoint);
+ final int charSetIndex = charSet.getIndex(codePoint);
if (charSetIndex < 0) {
continue;
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSet.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSet.java 2009-04-29 16:05:47 UTC (rev 10797)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSet.java 2009-04-29 16:22:11 UTC (rev 10798)
@@ -37,24 +37,9 @@
import java.util.Map;
/**
- * <p>Instances of CharSet are collections of related characters.
- * Fonts are frequently designed to cover a specific collection of characters.
- * For example, 12 of the Base-14 fonts cover the ExtendedRoman collection.</p>
- *
- * <p>The main purpose of the class is to efficiently map a Unicode code point
- * to an array index that can be used in other classes to store information
- * about that code point.
- * For example, as an AFM file is parsed, width metric information is
- * accumulated about each glyph in the font.
- * The font Encoding is not a suitable concept to use as an index for such
- * information, because it is limited to 256 characters and most Encodings use
- * less than that.
- * A font may contain more than 256 glyphs.
- * For example, the ExtendedRoman character set contains 315 glyphs.
- * By separating CharSet from Encoding, we can record all of the information
- * about a font without caring how it will be encoded as it is used.</p>
+ * The FOray implementation of {@link org.axsl.ps.CharSet}.
*/
-public class CharSet implements Serializable {
+public class CharSet implements org.axsl.ps.CharSet, Serializable {
/** Constant needed for serialization. */
public static final long serialVersionUID = -194139196582956914L;
@@ -158,12 +143,9 @@
}
/**
- * Returns the array index for a character in this character set.
- * @param codePoint The character whose index should be found.
- * @return The index for codePoint, or -1 if codePoint is not in the
- * character set.
+ * {@inheritDoc}
*/
- public int getCharSetIndex(final int codePoint) {
+ public int getIndex(final int codePoint) {
int index = -1;
if (this.characterSet16 != null) {
index = Arrays.binarySearch(this.characterSet16, (char) codePoint);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-04-29 16:27:05
|
Revision: 10799
http://foray.svn.sourceforge.net/foray/?rev=10799&view=rev
Author: victormote
Date: 2009-04-29 16:26:47 +0000 (Wed, 29 Apr 2009)
Log Message:
-----------
Rename class for clarity.
Modified Paths:
--------------
trunk/foray/foray-font/src/java/org/foray/font/Font4a.java
trunk/foray/foray-font/src/java/org/foray/font/FreeStandingFont.java
trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java
trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFile.java
trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java
trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFilePFM.java
trunk/foray/foray-font/src/java/org/foray/font/output/FontOutput4a.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetExtendedRoman.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetWindowsANSI.java
Added Paths:
-----------
trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSet4a.java
Removed Paths:
-------------
trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSet.java
Modified: trunk/foray/foray-font/src/java/org/foray/font/Font4a.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/Font4a.java 2009-04-29 16:22:11 UTC (rev 10798)
+++ trunk/foray/foray-font/src/java/org/foray/font/Font4a.java 2009-04-29 16:26:47 UTC (rev 10799)
@@ -29,7 +29,7 @@
import org.foray.common.WKConstants;
import org.foray.font.format.Kerning;
-import org.foray.ps.encode.CharSet;
+import org.foray.ps.encode.CharSet4a;
import org.axsl.font.Font;
@@ -366,7 +366,7 @@
* Returns the character set used by this font.
* @return The character set for this font.
*/
- public abstract CharSet getCharSet();
+ public abstract CharSet4a getCharSet();
/**
* {@inheritDoc}
Modified: trunk/foray/foray-font/src/java/org/foray/font/FreeStandingFont.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/FreeStandingFont.java 2009-04-29 16:22:11 UTC (rev 10798)
+++ trunk/foray/foray-font/src/java/org/foray/font/FreeStandingFont.java 2009-04-29 16:26:47 UTC (rev 10799)
@@ -32,7 +32,7 @@
import org.foray.font.format.FontFileReader;
import org.foray.font.format.Kerning;
import org.foray.font.format.Panose;
-import org.foray.ps.encode.CharSet;
+import org.foray.ps.encode.CharSet4a;
import org.axsl.font.Font;
import org.axsl.ps.Encoding;
@@ -112,7 +112,7 @@
private int numGlyphs = 0;
/** The character set for this font. */
- private CharSet charSet;
+ private CharSet4a charSet;
/** The Panose for this font. */
private Panose panose;
@@ -387,7 +387,7 @@
/**
* {@inheritDoc}
*/
- public CharSet getCharSet() {
+ public CharSet4a getCharSet() {
return this.charSet;
}
@@ -418,7 +418,7 @@
* Sets the character set for this font.
* @param charSet The character set to set.
*/
- protected void setCharSet(final CharSet charSet) {
+ protected void setCharSet(final CharSet4a charSet) {
this.charSet = charSet;
}
Modified: trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java 2009-04-29 16:22:11 UTC (rev 10798)
+++ trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java 2009-04-29 16:26:47 UTC (rev 10799)
@@ -32,7 +32,7 @@
import org.foray.common.WKConstants;
import org.foray.font.format.FontFileReader;
import org.foray.font.format.Kerning;
-import org.foray.ps.encode.CharSet;
+import org.foray.ps.encode.CharSet4a;
import org.axsl.font.FontException;
@@ -522,7 +522,7 @@
/**
* {@inheritDoc}
*/
- public CharSet getCharSet() {
+ public CharSet4a getCharSet() {
return null;
}
Modified: trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFile.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFile.java 2009-04-29 16:22:11 UTC (rev 10798)
+++ trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFile.java 2009-04-29 16:26:47 UTC (rev 10799)
@@ -28,7 +28,7 @@
package org.foray.font.format;
-import org.foray.ps.encode.CharSet;
+import org.foray.ps.encode.CharSet4a;
import org.axsl.ps.EncodingVector;
@@ -215,7 +215,7 @@
* Returns the character set for this font.
* @return The character set for this font.
*/
- public abstract CharSet getCharSet();
+ public abstract CharSet4a getCharSet();
/**
* Returns the internal encoding vector for this font.
Modified: trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java 2009-04-29 16:22:11 UTC (rev 10798)
+++ trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java 2009-04-29 16:26:47 UTC (rev 10799)
@@ -30,7 +30,7 @@
import org.foray.common.Bit;
import org.foray.font.output.FontPdf4a;
-import org.foray.ps.encode.CharSet;
+import org.foray.ps.encode.CharSet4a;
import org.foray.ps.encode.EncodingCustom;
import org.foray.ps.encode.EncodingVector4a;
import org.foray.ps.encode.GlyphList;
@@ -639,7 +639,7 @@
private EncodingVector4a internalEncoding;
/** The characters set used by this font. */
- private CharSet charSet;
+ private CharSet4a charSet;
/**
* Constructor.
@@ -1118,7 +1118,7 @@
this.charSet = null;
if (this.charSetString != null) {
/* See if this one is already registered. */
- this.charSet = CharSet.getRegisteredCharSet(this.charSetString);
+ this.charSet = CharSet4a.getRegisteredCharSet(this.charSetString);
}
if (this.charSet == null) {
this.codePoints = new int[this.qtyCharMetricsExpected];
@@ -1171,7 +1171,7 @@
}
}
}
- this.charSet = new CharSet(this.getPostscriptName(), this.codePoints);
+ this.charSet = new CharSet4a(this.getPostscriptName(), this.codePoints);
}
/**
@@ -1544,7 +1544,7 @@
/**
* Returns the String description of the character set parsed from this
- * file (as opposed to the {@link CharSet} instance).
+ * file (as opposed to the {@link CharSet4a} instance).
* @return The String description of the character set.
*/
public String getCharSetString() {
@@ -1666,7 +1666,7 @@
/**
* {@inheritDoc}
*/
- public CharSet getCharSet() {
+ public CharSet4a getCharSet() {
return this.charSet;
}
Modified: trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFilePFM.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFilePFM.java 2009-04-29 16:22:11 UTC (rev 10798)
+++ trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFilePFM.java 2009-04-29 16:26:47 UTC (rev 10799)
@@ -31,7 +31,7 @@
import org.foray.common.Bit;
import org.foray.common.WKConstants;
import org.foray.font.output.FontPdf4a;
-import org.foray.ps.encode.CharSet;
+import org.foray.ps.encode.CharSet4a;
import org.foray.ps.encode.EncodingVector4a;
import org.axsl.ps.BoundingBox;
@@ -381,7 +381,7 @@
if (internalEncoding == null) {
return;
}
- final CharSet charSet = this.getCharSet();
+ final CharSet4a charSet = this.getCharSet();
if (charSet == null) {
return;
}
@@ -456,10 +456,10 @@
/**
* {@inheritDoc}
*/
- public CharSet getCharSet() {
+ public CharSet4a getCharSet() {
switch (this.getCharSetID()) {
case 0:
- return CharSet.getRegisteredCharSet("WindowsANSI");
+ return CharSet4a.getRegisteredCharSet("WindowsANSI");
default:
return null;
}
Modified: trunk/foray/foray-font/src/java/org/foray/font/output/FontOutput4a.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/output/FontOutput4a.java 2009-04-29 16:22:11 UTC (rev 10798)
+++ trunk/foray/foray-font/src/java/org/foray/font/output/FontOutput4a.java 2009-04-29 16:26:47 UTC (rev 10799)
@@ -34,7 +34,7 @@
import org.foray.font.FSTrueTypeFont;
import org.foray.font.FreeStandingFont;
import org.foray.font.Subset;
-import org.foray.ps.encode.CharSet;
+import org.foray.ps.encode.CharSet4a;
import org.axsl.font.Font;
import org.axsl.font.FontUse;
@@ -218,7 +218,7 @@
return getSubsetWidths();
}
final Encoding encoding = this.fontUse.getEncoding();
- final CharSet charSet = fsf.getCharSet();
+ final CharSet4a charSet = fsf.getCharSet();
final int firstIndex = encoding.getFirstIndex();
final int lastIndex = encoding.getLastIndex();
final int size = lastIndex - firstIndex + 1;
Deleted: trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSet.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSet.java 2009-04-29 16:22:11 UTC (rev 10798)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSet.java 2009-04-29 16:26:47 UTC (rev 10799)
@@ -1,267 +0,0 @@
-/*
- * Copyright 2005 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.ps.encode;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * The FOray implementation of {@link org.axsl.ps.CharSet}.
- */
-public class CharSet implements org.axsl.ps.CharSet, Serializable {
-
- /** Constant needed for serialization. */
- public static final long serialVersionUID = -194139196582956914L;
-
- /**
- * A map of all registered CharSet instances.
- * The key to the map is a String containing the name of the charset.
- * The value is the CharSet instance.
- */
- private static Map<String, CharSet> registeredCharSets
- = new HashMap<String, CharSet>();
-
- /** The name of this character set. */
- private transient String name;
-
- /** The 16-bit Unicode codepoints. */
- private transient char[] characterSet16;
-
- /** The 32-bit Unicode codepoints. These are conceptually appended to the
- * end of {@link #characterSet16} as if they were all in one array. */
- private transient int[] characterSet32;
-
- /**
- * Constructor suitable for character sets that contain only 16-bit
- * characters. If there are any 32-bit code points in the character set,
- * use {@link #CharSet(String, int[])} instead.
- * @param name The name of this character set.
- * @param characterSet The array containing the code points in this
- * character set.
- */
- public CharSet(final String name, final char[] characterSet) {
- this.name = name;
- if (characterSet == null) {
- return;
- }
- /* Make sure the input array is sorted. */
- Arrays.sort(characterSet);
- this.characterSet16 = characterSet;
- }
-
- /**
- * General constructor suitable for character sets containing 16-bit
- * codePoints, 32-bit code points, or both.
- * If all code points in the character set are 16-bit (less than or equal to
- * 0xFFFF), then {@link #CharSet(String, char[])} may also be used.
- * @param name The name of this character set.
- * @param characterSet The array containing the code points in this
- * character set.
- */
- public CharSet(final String name, final int[] characterSet) {
- this.name = name;
- if (characterSet == null) {
- return;
- }
-
- /* Make sure the input array is sorted. */
- Arrays.sort(characterSet);
-
- /* Find the index to the first code point > 0xFFFF. */
- int first32bitIndex = Integer.MAX_VALUE;
- for (int i = characterSet.length - 1; i > -1 && first32bitIndex < 0;
- i--) {
- if (characterSet[i] <= Character.MAX_VALUE) {
- /* We are down to the 16-bit items, so we are done. */
- break;
- }
- /* We are still in the 32-bit items, so this one is now the first
- * known 32-bit item. */
- first32bitIndex = i;
- }
-
- /* Split the input array into 2 arrays, one for 16-bit items, one for
- * 32-bit items. */
- if (first32bitIndex == Integer.MAX_VALUE) {
- /* There are no 32-bit values. */
- this.characterSet32 = null;
- this.characterSet16 = new char[characterSet.length];
- for (int i = 0; i < characterSet.length; i++) {
- this.characterSet16[i] = (char) characterSet[i];
- }
- } else {
- final int num16bits = first32bitIndex;
- final int num32bits = characterSet.length - num16bits;
- this.characterSet16 = new char[num16bits];
- for (int i = 0; i < first32bitIndex; i++) {
- this.characterSet16[i] = (char) characterSet[i];
- }
- this.characterSet32 = new int[num32bits];
- for (int i = first32bitIndex; i < characterSet.length; i++) {
- this.characterSet32[i - first32bitIndex] = characterSet[i];
- }
- }
- }
-
- /**
- * Returns the name of this character set.
- * @return The name of this character set.
- */
- public String getName() {
- return this.name;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getIndex(final int codePoint) {
- int index = -1;
- if (this.characterSet16 != null) {
- index = Arrays.binarySearch(this.characterSet16, (char) codePoint);
- }
- if (index > -1) {
- return index;
- }
- if (this.characterSet32 != null) {
- index = Arrays.binarySearch(this.characterSet32, codePoint);
- if (index > -1
- && this.characterSet16 != null) {
- index += this.characterSet16.length;
- }
- }
- if (index < 0) {
- index = -1;
- }
- return index;
- }
-
- /**
- * This is a factory method that either finds or creates the known
- * predefined CharSet instances.
- * @param name The name of the predefined charset to be returned.
- * @return The CharSet instance for <code>name</code>, or null if
- * <code>name</code> does not describe a predefined character set.
- */
- public static CharSet getRegisteredCharSet(final String name) {
- // If already instantiated, return it.
- CharSet charSet = CharSet.registeredCharSets.get(name);
- if (charSet != null) {
- return charSet;
- }
- // Otherwise, try to instantiate it.
- if (name.equals("WindowsANSI")) {
- charSet = CharSetWindowsANSI.getInstance();
- } else if (name.equals("ExtendedRoman")) {
- charSet = CharSetExtendedRoman.getInstance();
- }
- if (charSet == null) {
- return null;
- }
- CharSet.registeredCharSets.put(name, charSet);
- return charSet;
- }
-
- /**
- * Returns the size, in characters, of this character set.
- * @return The size of this character set.
- */
- public int size() {
- int size = 0;
- if (this.characterSet16 != null) {
- size += this.characterSet16.length;
- }
- if (this.characterSet32 != null) {
- size += this.characterSet32.length;
- }
- return size;
- }
-
- /**
- * Indicates whether the data in this character set is static, that is,
- * tied entirely to the class itself and not built dynamically.
- * This is used primarily to determine whether the instance should actually
- * be serialized.
- * Static subclasses should override this method.
- * @return True iff all data in this glyph list is static and does not
- * need to be serialized.
- */
- public boolean isStatic() {
- return false;
- }
-
- /**
- * Serialize this {@link CharSet} instance.
- * @param stream The output stream to which the serialized data is written.
- * @throws IOException For I/O errors.
- * @serialData
- * <ol>
- * <li>The name of the character set (String).</li>
- * <li>The The 16-bit Unicode codepoints (char[]).</li>
- * <li>The The 32-bit Unicode codepoints (int[]).</li>
- * </ol>
- */
- private void writeObject(final ObjectOutputStream stream)
- throws IOException {
- if (this.isStatic()) {
- /* The static instances do not need to be serialized as they are
- * derived entirely from static data. */
- return;
- }
- stream.defaultWriteObject();
- stream.writeObject(this.name);
- stream.writeObject(this.characterSet16);
- stream.writeObject(this.characterSet32);
- }
-
- /**
- * Deserialize this {@link CharSet} instance.
- * @param stream The input stream from which the serialized data is read.
- * @throws IOException For I/O errors reading the input.
- * @throws ClassNotFoundException For classes in the input that cannot be
- * found.
- */
- private void readObject(final ObjectInputStream stream)
- throws IOException, ClassNotFoundException {
- if (this.isStatic()) {
- /* The static instances do not need to be serialized as they are
- * derived entirely from static data. */
- return;
- }
- stream.defaultReadObject();
- this.name = (String) stream.readObject();
- this.characterSet16 = (char[]) stream.readObject();
- this.characterSet32 = (int[]) stream.readObject();
- }
-
-}
Copied: trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSet4a.java (from rev 10798, trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSet.java)
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSet4a.java (rev 0)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSet4a.java 2009-04-29 16:26:47 UTC (rev 10799)
@@ -0,0 +1,267 @@
+/*
+ * Copyright 2005 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.ps.encode;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * The FOray implementation of {@link org.axsl.ps.CharSet}.
+ */
+public class CharSet4a implements org.axsl.ps.CharSet, Serializable {
+
+ /** Constant needed for serialization. */
+ public static final long serialVersionUID = -194139196582956914L;
+
+ /**
+ * A map of all registered CharSet instances.
+ * The key to the map is a String containing the name of the charset.
+ * The value is the CharSet instance.
+ */
+ private static Map<String, CharSet4a> registeredCharSets
+ = new HashMap<String, CharSet4a>();
+
+ /** The name of this character set. */
+ private transient String name;
+
+ /** The 16-bit Unicode codepoints. */
+ private transient char[] characterSet16;
+
+ /** The 32-bit Unicode codepoints. These are conceptually appended to the
+ * end of {@link #characterSet16} as if they were all in one array. */
+ private transient int[] characterSet32;
+
+ /**
+ * Constructor suitable for character sets that contain only 16-bit
+ * characters. If there are any 32-bit code points in the character set,
+ * use {@link #CharSet4a(String, int[])} instead.
+ * @param name The name of this character set.
+ * @param characterSet The array containing the code points in this
+ * character set.
+ */
+ public CharSet4a(final String name, final char[] characterSet) {
+ this.name = name;
+ if (characterSet == null) {
+ return;
+ }
+ /* Make sure the input array is sorted. */
+ Arrays.sort(characterSet);
+ this.characterSet16 = characterSet;
+ }
+
+ /**
+ * General constructor suitable for character sets containing 16-bit
+ * codePoints, 32-bit code points, or both.
+ * If all code points in the character set are 16-bit (less than or equal to
+ * 0xFFFF), then {@link #CharSet4a(String, char[])} may also be used.
+ * @param name The name of this character set.
+ * @param characterSet The array containing the code points in this
+ * character set.
+ */
+ public CharSet4a(final String name, final int[] characterSet) {
+ this.name = name;
+ if (characterSet == null) {
+ return;
+ }
+
+ /* Make sure the input array is sorted. */
+ Arrays.sort(characterSet);
+
+ /* Find the index to the first code point > 0xFFFF. */
+ int first32bitIndex = Integer.MAX_VALUE;
+ for (int i = characterSet.length - 1; i > -1 && first32bitIndex < 0;
+ i--) {
+ if (characterSet[i] <= Character.MAX_VALUE) {
+ /* We are down to the 16-bit items, so we are done. */
+ break;
+ }
+ /* We are still in the 32-bit items, so this one is now the first
+ * known 32-bit item. */
+ first32bitIndex = i;
+ }
+
+ /* Split the input array into 2 arrays, one for 16-bit items, one for
+ * 32-bit items. */
+ if (first32bitIndex == Integer.MAX_VALUE) {
+ /* There are no 32-bit values. */
+ this.characterSet32 = null;
+ this.characterSet16 = new char[characterSet.length];
+ for (int i = 0; i < characterSet.length; i++) {
+ this.characterSet16[i] = (char) characterSet[i];
+ }
+ } else {
+ final int num16bits = first32bitIndex;
+ final int num32bits = characterSet.length - num16bits;
+ this.characterSet16 = new char[num16bits];
+ for (int i = 0; i < first32bitIndex; i++) {
+ this.characterSet16[i] = (char) characterSet[i];
+ }
+ this.characterSet32 = new int[num32bits];
+ for (int i = first32bitIndex; i < characterSet.length; i++) {
+ this.characterSet32[i - first32bitIndex] = characterSet[i];
+ }
+ }
+ }
+
+ /**
+ * Returns the name of this character set.
+ * @return The name of this character set.
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getIndex(final int codePoint) {
+ int index = -1;
+ if (this.characterSet16 != null) {
+ index = Arrays.binarySearch(this.characterSet16, (char) codePoint);
+ }
+ if (index > -1) {
+ return index;
+ }
+ if (this.characterSet32 != null) {
+ index = Arrays.binarySearch(this.characterSet32, codePoint);
+ if (index > -1
+ && this.characterSet16 != null) {
+ index += this.characterSet16.length;
+ }
+ }
+ if (index < 0) {
+ index = -1;
+ }
+ return index;
+ }
+
+ /**
+ * This is a factory method that either finds or creates the known
+ * predefined CharSet instances.
+ * @param name The name of the predefined charset to be returned.
+ * @return The CharSet instance for <code>name</code>, or null if
+ * <code>name</code> does not describe a predefined character set.
+ */
+ public static CharSet4a getRegisteredCharSet(final String name) {
+ // If already instantiated, return it.
+ CharSet4a charSet = CharSet4a.registeredCharSets.get(name);
+ if (charSet != null) {
+ return charSet;
+ }
+ // Otherwise, try to instantiate it.
+ if (name.equals("WindowsANSI")) {
+ charSet = CharSetWindowsANSI.getInstance();
+ } else if (name.equals("ExtendedRoman")) {
+ charSet = CharSetExtendedRoman.getInstance();
+ }
+ if (charSet == null) {
+ return null;
+ }
+ CharSet4a.registeredCharSets.put(name, charSet);
+ return charSet;
+ }
+
+ /**
+ * Returns the size, in characters, of this character set.
+ * @return The size of this character set.
+ */
+ public int size() {
+ int size = 0;
+ if (this.characterSet16 != null) {
+ size += this.characterSet16.length;
+ }
+ if (this.characterSet32 != null) {
+ size += this.characterSet32.length;
+ }
+ return size;
+ }
+
+ /**
+ * Indicates whether the data in this character set is static, that is,
+ * tied entirely to the class itself and not built dynamically.
+ * This is used primarily to determine whether the instance should actually
+ * be serialized.
+ * Static subclasses should override this method.
+ * @return True iff all data in this glyph list is static and does not
+ * need to be serialized.
+ */
+ public boolean isStatic() {
+ return false;
+ }
+
+ /**
+ * Serialize this {@link CharSet4a} instance.
+ * @param stream The output stream to which the serialized data is written.
+ * @throws IOException For I/O errors.
+ * @serialData
+ * <ol>
+ * <li>The name of the character set (String).</li>
+ * <li>The The 16-bit Unicode codepoints (char[]).</li>
+ * <li>The The 32-bit Unicode codepoints (int[]).</li>
+ * </ol>
+ */
+ private void writeObject(final ObjectOutputStream stream)
+ throws IOException {
+ if (this.isStatic()) {
+ /* The static instances do not need to be serialized as they are
+ * derived entirely from static data. */
+ return;
+ }
+ stream.defaultWriteObject();
+ stream.writeObject(this.name);
+ stream.writeObject(this.characterSet16);
+ stream.writeObject(this.characterSet32);
+ }
+
+ /**
+ * Deserialize this {@link CharSet4a} instance.
+ * @param stream The input stream from which the serialized data is read.
+ * @throws IOException For I/O errors reading the input.
+ * @throws ClassNotFoundException For classes in the input that cannot be
+ * found.
+ */
+ private void readObject(final ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ if (this.isStatic()) {
+ /* The static instances do not need to be serialized as they are
+ * derived entirely from static data. */
+ return;
+ }
+ stream.defaultReadObject();
+ this.name = (String) stream.readObject();
+ this.characterSet16 = (char[]) stream.readObject();
+ this.characterSet32 = (int[]) stream.readObject();
+ }
+
+}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetExtendedRoman.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetExtendedRoman.java 2009-04-29 16:22:11 UTC (rev 10798)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetExtendedRoman.java 2009-04-29 16:26:47 UTC (rev 10799)
@@ -40,7 +40,7 @@
* "C" entries in the following AFM file:
* foray/foray-font/resource/base-14/Helvetica.afm</p>
*/
-public final class CharSetExtendedRoman extends CharSet {
+public final class CharSetExtendedRoman extends CharSet4a {
/** Constant needed for serialization. */
public static final long serialVersionUID = -78856854976712859L;
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetWindowsANSI.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetWindowsANSI.java 2009-04-29 16:22:11 UTC (rev 10798)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetWindowsANSI.java 2009-04-29...
[truncated message content] |
|
From: <vic...@us...> - 2009-04-29 18:37:52
|
Revision: 10809
http://foray.svn.sourceforge.net/foray/?rev=10809&view=rev
Author: victormote
Date: 2009-04-29 18:37:33 +0000 (Wed, 29 Apr 2009)
Log Message:
-----------
Rename class for clarity in preparation for extraction of an interface.
Modified Paths:
--------------
trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java
trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetParser.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCE.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCustom.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpert.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpertSubset.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingFOrayLatinExtra.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingISOLatin1.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacExpert.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacRoman.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacStandard.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingPDFDoc.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingStandard.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingSymbol.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingVector4a.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingWinAnsi.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingZapfDingbats.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphListAGL.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphListZapfDingbats.java
Added Paths:
-----------
trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphList4a.java
Removed Paths:
-------------
trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphList.java
Modified: trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java 2009-04-29 18:32:27 UTC (rev 10808)
+++ trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java 2009-04-29 18:37:33 UTC (rev 10809)
@@ -33,7 +33,7 @@
import org.foray.ps.encode.EncodingCustom;
import org.foray.ps.encode.EncodingParser;
import org.foray.ps.encode.EncodingVector4a;
-import org.foray.ps.encode.GlyphList;
+import org.foray.ps.encode.GlyphList4a;
import org.foray.ps.encode.GlyphListParser;
import org.axsl.font.FontException;
@@ -787,7 +787,7 @@
+ "element \"glyph-list\".");
return;
}
- GlyphList glyphList = GlyphList.getGlyphList(name);
+ GlyphList4a glyphList = GlyphList4a.getGlyphList(name);
if (glyphList != null) {
logError("Glyph-list already defined: " + name);
return;
@@ -820,10 +820,10 @@
} catch (final IOException e2) {
logError("Error parsing: " + file);
}
- glyphList = new GlyphList(name, parser.getGlyphNames(),
+ glyphList = new GlyphList4a(name, parser.getGlyphNames(),
parser.getCodePointsForGlyphNames(), parser.getCodePoints(),
parser.getGlyphNameIndex());
- GlyphList.registerGlyphList(name, glyphList);
+ GlyphList4a.registerGlyphList(name, glyphList);
}
/**
Modified: trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java 2009-04-29 18:32:27 UTC (rev 10808)
+++ trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java 2009-04-29 18:37:33 UTC (rev 10809)
@@ -32,7 +32,7 @@
import org.foray.font.output.FontPdf4a;
import org.foray.ps.encode.EncodingCustom;
import org.foray.ps.encode.EncodingVector4a;
-import org.foray.ps.encode.GlyphList;
+import org.foray.ps.encode.GlyphList4a;
import org.axsl.font.Font;
import org.axsl.font.FontException;
@@ -1598,10 +1598,10 @@
* @return The Unicode code point that corresponds to glyphName.
*/
private char getCodePointForGlyphName(final String glyphName) {
- GlyphList gl = GlyphList.getGlyphList("AGL");
+ GlyphList4a gl = GlyphList4a.getGlyphList("AGL");
char theChar = gl.mapGlyphNameToCodePoint(glyphName);
if (theChar == Character.MAX_VALUE) {
- gl = GlyphList.getGlyphList("ZapfDingbats");
+ gl = GlyphList4a.getGlyphList("ZapfDingbats");
theChar = gl.mapGlyphNameToCodePoint(glyphName);
}
return theChar;
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetParser.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetParser.java 2009-04-29 18:32:27 UTC (rev 10808)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetParser.java 2009-04-29 18:37:33 UTC (rev 10809)
@@ -172,7 +172,7 @@
* @param arrayIndex The current glyph index being processed.
*/
private void processCurrentLine(final String line, final int arrayIndex) {
- final GlyphList gl = GlyphList.getGlyphList("AGL");
+ final GlyphList4a gl = GlyphList4a.getGlyphList("AGL");
final char theChar = gl.mapGlyphNameToCodePoint(line);
if (theChar == Character.MAX_VALUE) {
this.logger.error("Character not found in Adobe Glyph List, line "
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCE.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCE.java 2009-04-29 18:32:27 UTC (rev 10808)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCE.java 2009-04-29 18:37:33 UTC (rev 10809)
@@ -939,7 +939,7 @@
* {@link #getInstance()}.
*/
private EncodingCE() {
- super("CEEncoding", GlyphList.standardSourceGlyphLists(),
+ super("CEEncoding", GlyphList4a.standardSourceGlyphLists(),
EncodingCE.CODE_POINTS,
EncodingCE.CODE_POINT_INDEXES);
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCustom.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCustom.java 2009-04-29 18:32:27 UTC (rev 10808)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCustom.java 2009-04-29 18:37:33 UTC (rev 10809)
@@ -52,7 +52,7 @@
* codePoints. codePointIndexes[n] should contain the encoded index that
* corresponds to the Unicode code point at codePoints[n].
*/
- public EncodingCustom(final String name, final GlyphList[] sourceGlyphLists,
+ public EncodingCustom(final String name, final GlyphList4a[] sourceGlyphLists,
final char[] codePoints, final char[] codePointIndexes) {
super(name, sourceGlyphLists, codePoints, codePointIndexes);
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpert.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpert.java 2009-04-29 18:32:27 UTC (rev 10808)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpert.java 2009-04-29 18:37:33 UTC (rev 10809)
@@ -738,7 +738,7 @@
* {@link #getInstance()}.
*/
private EncodingExpert() {
- super("ExpertEncoding", GlyphList.standardSourceGlyphLists(),
+ super("ExpertEncoding", GlyphList4a.standardSourceGlyphLists(),
EncodingExpert.CODE_POINTS,
EncodingExpert.CODE_POINT_INDEXES);
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpertSubset.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpertSubset.java 2009-04-29 18:32:27 UTC (rev 10808)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpertSubset.java 2009-04-29 18:37:33 UTC (rev 10809)
@@ -423,7 +423,7 @@
* {@link #getInstance()}.
*/
private EncodingExpertSubset() {
- super("ExpertSubsetEncoding", GlyphList.standardSourceGlyphLists(),
+ super("ExpertSubsetEncoding", GlyphList4a.standardSourceGlyphLists(),
EncodingExpertSubset.CODE_POINTS,
EncodingExpertSubset.CODE_POINT_INDEXES);
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingFOrayLatinExtra.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingFOrayLatinExtra.java 2009-04-29 18:32:27 UTC (rev 10808)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingFOrayLatinExtra.java 2009-04-29 18:37:33 UTC (rev 10809)
@@ -273,7 +273,7 @@
* {@link #getInstance()}.
*/
private EncodingFOrayLatinExtra() {
- super("FOrayLatinExtraEncoding", GlyphList.standardSourceGlyphLists(),
+ super("FOrayLatinExtraEncoding", GlyphList4a.standardSourceGlyphLists(),
EncodingFOrayLatinExtra.CODE_POINTS,
EncodingFOrayLatinExtra.CODE_POINT_INDEXES);
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingISOLatin1.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingISOLatin1.java 2009-04-29 18:32:27 UTC (rev 10808)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingISOLatin1.java 2009-04-29 18:37:33 UTC (rev 10809)
@@ -878,7 +878,7 @@
* {@link #getInstance()}.
*/
private EncodingISOLatin1() {
- super("ISOLatin1Encoding", GlyphList.standardSourceGlyphLists(),
+ super("ISOLatin1Encoding", GlyphList4a.standardSourceGlyphLists(),
EncodingISOLatin1.CODE_POINTS,
EncodingISOLatin1.CODE_POINT_INDEXES);
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacExpert.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacExpert.java 2009-04-29 18:32:27 UTC (rev 10808)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacExpert.java 2009-04-29 18:37:33 UTC (rev 10809)
@@ -738,7 +738,7 @@
* {@link #getInstance()}.
*/
private EncodingMacExpert() {
- super("MacExpertEncoding", GlyphList.standardSourceGlyphLists(),
+ super("MacExpertEncoding", GlyphList4a.standardSourceGlyphLists(),
EncodingMacExpert.CODE_POINTS,
EncodingMacExpert.CODE_POINT_INDEXES);
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacRoman.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacRoman.java 2009-04-29 18:32:27 UTC (rev 10808)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacRoman.java 2009-04-29 18:37:33 UTC (rev 10809)
@@ -906,7 +906,7 @@
* {@link #getInstance()}.
*/
private EncodingMacRoman() {
- super("MacRomanEncoding", GlyphList.standardSourceGlyphLists(),
+ super("MacRomanEncoding", GlyphList4a.standardSourceGlyphLists(),
EncodingMacRoman.CODE_POINTS,
EncodingMacRoman.CODE_POINT_INDEXES);
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacStandard.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacStandard.java 2009-04-29 18:32:27 UTC (rev 10808)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacStandard.java 2009-04-29 18:37:33 UTC (rev 10809)
@@ -1120,7 +1120,7 @@
* {@link #getInstance()}.
*/
private EncodingMacStandard() {
- super(EncodingVector.Predefined.STANDARD_MACINTOSH_ORDERING.getName(), GlyphList.standardSourceGlyphLists(),
+ super(EncodingVector.Predefined.STANDARD_MACINTOSH_ORDERING.getName(), GlyphList4a.standardSourceGlyphLists(),
EncodingMacStandard.CODE_POINTS, EncodingMacStandard.CODE_POINT_INDEXES);
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingPDFDoc.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingPDFDoc.java 2009-04-29 18:32:27 UTC (rev 10808)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingPDFDoc.java 2009-04-29 18:37:33 UTC (rev 10809)
@@ -994,7 +994,7 @@
* {@link #getInstance()}.
*/
private EncodingPDFDoc() {
- super("PDFDocEncoding", GlyphList.standardSourceGlyphLists(),
+ super("PDFDocEncoding", GlyphList4a.standardSourceGlyphLists(),
EncodingPDFDoc.CODE_POINTS,
EncodingPDFDoc.CODE_POINT_INDEXES);
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java 2009-04-29 18:32:27 UTC (rev 10808)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java 2009-04-29 18:37:33 UTC (rev 10809)
@@ -132,7 +132,7 @@
private String glyphLists;
/** The array of glyph lists that can be used to map names to codepoints. */
- private GlyphList[] glyphListsToCheck = null;
+ private GlyphList4a[] glyphListsToCheck = null;
/** The names of the glyphs parsed from the encoding. */
private String[] glyphNames;
@@ -362,17 +362,17 @@
tokenizer = new StringTokenizer(this.glyphLists);
numListsToCheck += tokenizer.countTokens();
}
- this.glyphListsToCheck = new GlyphList[numListsToCheck];
+ this.glyphListsToCheck = new GlyphList4a[numListsToCheck];
int index = 0;
- GlyphList glyphList = null;
+ GlyphList4a glyphList = null;
if (tokenizer != null) {
while (tokenizer.hasMoreTokens()) {
- glyphList = GlyphList.getGlyphList(tokenizer.nextToken());
+ glyphList = GlyphList4a.getGlyphList(tokenizer.nextToken());
this.glyphListsToCheck[index] = glyphList;
index++;
}
}
- this.glyphListsToCheck[index] = GlyphList.getGlyphList("AGL");
+ this.glyphListsToCheck[index] = GlyphList4a.getGlyphList("AGL");
this.codePoints = new char[this.glyphNames.length];
this.codePointIndexes = new char[this.codePoints.length];
for (int i = 0; i < this.glyphNames.length; i++) {
@@ -697,7 +697,7 @@
* Returns the glyph lists to check.
* @return The glyph lists to check.
*/
- public GlyphList[] getGlyphListsToCheck() {
+ public GlyphList4a[] getGlyphListsToCheck() {
return this.glyphListsToCheck;
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingStandard.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingStandard.java 2009-04-29 18:32:27 UTC (rev 10808)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingStandard.java 2009-04-29 18:37:33 UTC (rev 10809)
@@ -677,7 +677,7 @@
* {@link #getInstance()}.
*/
private EncodingStandard() {
- super("StandardEncoding", GlyphList.standardSourceGlyphLists(),
+ super("StandardEncoding", GlyphList4a.standardSourceGlyphLists(),
EncodingStandard.CODE_POINTS,
EncodingStandard.CODE_POINT_INDEXES);
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingSymbol.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingSymbol.java 2009-04-29 18:32:27 UTC (rev 10808)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingSymbol.java 2009-04-29 18:37:33 UTC (rev 10809)
@@ -842,7 +842,7 @@
* {@link #getInstance()}.
*/
private EncodingSymbol() {
- super("SymbolEncoding", GlyphList.standardSourceGlyphLists(),
+ super("SymbolEncoding", GlyphList4a.standardSourceGlyphLists(),
EncodingSymbol.CODE_POINTS,
EncodingSymbol.CODE_POINT_INDEXES);
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingVector4a.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingVector4a.java 2009-04-29 18:32:27 UTC (rev 10808)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingVector4a.java 2009-04-29 18:37:33 UTC (rev 10809)
@@ -106,7 +106,7 @@
/** The GlyphList instances, in order, which were used to create this
* encoding. */
- private transient GlyphList[] sourceGlyphLists;
+ private transient GlyphList4a[] sourceGlyphLists;
/** Array of Unicode code points, sorted. Elements in this array are keys
* to elements in {@link #codePointIndexes}. */
@@ -131,7 +131,7 @@
* codePoints. codePointIndexes[n] should contain the encoded index that
* corresponds to the Unicode code point at codePoints[n].
*/
- public EncodingVector4a(final String name, final GlyphList[] sourceGlyphLists,
+ public EncodingVector4a(final String name, final GlyphList4a[] sourceGlyphLists,
final char[] codePoints, final char[] codePointIndexes) {
this.name = name;
this.sourceGlyphLists = sourceGlyphLists;
@@ -307,7 +307,7 @@
}
for (int i = 0; i < this.codePoints.length; i++) {
final char codePoint = this.codePoints[i];
- final String glyphName = GlyphList.mapCodePointToGlyphName(
+ final String glyphName = GlyphList4a.mapCodePointToGlyphName(
this.sourceGlyphLists, codePoint);
final int encodingIndex = this.codePointIndexes[i];
glyphList[encodingIndex] = glyphName;
@@ -421,7 +421,7 @@
// codePoint is not in this encoding.
return null;
}
- return GlyphList.mapCodePointToGlyphName(this.sourceGlyphLists,
+ return GlyphList4a.mapCodePointToGlyphName(this.sourceGlyphLists,
codePoint);
}
@@ -477,7 +477,7 @@
* @serialData
* <ol>
* <li>The name of the encoding (String).</li>
- * <li>The source {@link GlyphList} instances used to build this encoding
+ * <li>The source {@link GlyphList4a} instances used to build this encoding
* (GlyphList[]), in order.</li>
* <li>The code points (char[]).</li>
* <li>The code point indexes (char[]).</li>
@@ -513,7 +513,7 @@
}
stream.defaultReadObject();
this.name = (String) stream.readObject();
- this.sourceGlyphLists = (GlyphList[]) stream.readObject();
+ this.sourceGlyphLists = (GlyphList4a[]) stream.readObject();
this.codePoints = (char[]) stream.readObject();
this.codePointIndexes = (char[]) stream.readObject();
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingWinAnsi.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingWinAnsi.java 2009-04-29 18:32:27 UTC (rev 10808)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingWinAnsi.java 2009-04-29 18:37:33 UTC (rev 10809)
@@ -942,7 +942,7 @@
* {@link #getInstance()}.
*/
private EncodingWinAnsi() {
- super("WinAnsiEncoding", GlyphList.standardSourceGlyphLists(),
+ super("WinAnsiEncoding", GlyphList4a.standardSourceGlyphLists(),
EncodingWinAnsi.CODE_POINTS,
EncodingWinAnsi.CODE_POINT_INDEXES);
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingZapfDingbats.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingZapfDingbats.java 2009-04-29 18:32:27 UTC (rev 10808)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingZapfDingbats.java 2009-04-29 18:37:33 UTC (rev 10809)
@@ -60,10 +60,10 @@
/** The array of glyph lists that should be used to map glyph names to
* Unicode code points for this font. */
- private static final GlyphList[] GLYPH_LISTS_USED = {
- GlyphList.getGlyphList("ZapfDingbats"),
+ private static final GlyphList4a[] GLYPH_LISTS_USED = {
+ GlyphList4a.getGlyphList("ZapfDingbats"),
/* We need the Adobe Glyph List to get the "space" char. */
- GlyphList.getGlyphList("AGL")
+ GlyphList4a.getGlyphList("AGL")
};
/*
Deleted: trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphList.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphList.java 2009-04-29 18:32:27 UTC (rev 10808)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphList.java 2009-04-29 18:37:33 UTC (rev 10809)
@@ -1,359 +0,0 @@
-/*
- * Copyright 2005 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.ps.encode;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Class handling glyph-to-Unicode mappings. Instances of this class manage a
- * set of four arrays. One set of two arrays is used to convert glyph names
- * to Unicode code points. The other set is used to convert Unicode code points
- * to glyph names. Each set can be thought of as a key-value pair, with the keys
- * being in one array and the values being in the other, and the two joined
- * together by a common index. In each set, the "key" array is sorted, which
- * allows an efficient binary search.
- */
-public class GlyphList implements Serializable {
-
- /** Constant needed for serialization. */
- public static final long serialVersionUID = -271250133295639106L;
-
- /** Map of GlyphList instances that have already been registered. The key
- * is a String with the GlyphList name, and the value is the GlyphList
- * instance. */
- private static Map<String, GlyphList> glyphListMap
- = new HashMap<String, GlyphList>();
-
- /** An array of glyph lists representing those that should be consulted
- * as a standard source. */
- private static final GlyphList[] STANDARD_SOURCE_GLYPH_LISTS = {
- GlyphList.getGlyphList("AGL")
- };
-
- /** A unique, descriptive name for this GlyphList. */
- private transient String name;
-
- /** Array of glyph names, sorted.
- * This array is parallel with {@link #codePointsForGlyphNames}.
- * Elements of {@link #sortedGlyphNames} can be thought of as the "key" for
- * the "value" that is in {@link #codePointsForGlyphNames}.
- * At all times, for {@link #sortedGlyphNames}[n], the corresponding
- * Unicode code point(s) can be found in
- * {@link #codePointsForGlyphNames}[n]. */
- private transient String[] sortedGlyphNames = null;
-
- /** Array of Unicode code points.
- * This array is parallel with {@link #sortedGlyphNames}.
- * Elements of {@link #codePointsForGlyphNames} can be thought of as the
- * "value" corresponding to the "key" that is in {@link #sortedGlyphNames}.
- * At all times, for {@link #sortedGlyphNames}[n], the corresponding
- * Unicode code point(s) can be found in
- * {@link #codePointsForGlyphNames}[n]. */
- private transient char[][] codePointsForGlyphNames = null;
-
- /** Array of Unicode code points, sorted.
- * This array is parallel with {@link #glyphNamesForCodePoints}.
- * Elements of {@link #sortedCodePoints} can be thought of as the "key" for
- * the "value" that is in {@link #glyphNamesForCodePoints}.
- * At all times, for {@link #sortedCodePoints}[n], the corresponding
- * index to sortedGlyphNames can be found in
- * {@link #glyphNamesForCodePoints}[n]. */
- private transient char[] sortedCodePoints = null;
-
- /** Array of indexes to elements in sortedGlyphNames.
- * This array is parallel with {@link #sortedCodePoints}.
- * Elements of {@link #glyphNamesForCodePoints} can be thought of as the
- * "value" for the "key" that is in {@link #sortedCodePoints}.
- * At all times, for {@link #sortedCodePoints}[n], the corresponding
- * index to sortedGlyphNames can be found in
- * {@link #glyphNamesForCodePoints}[n]. */
- private transient short[] glyphNamesForCodePoints = null;
-
- /**
- * Constructor.
- * @param name The name of the glyph list being created.
- * @param sortedGlyphNames The array of sorted glyph names.
- * @param codePointsForGlyphNames The array of Unicode code points for each
- * glyph name.
- * @param sortedCodePoints The sorted array of Unicode code points.
- * @param glyphNamesForCodePoints The array of indexes into the glyph name
- * list that correspond to the sorted code points.
- */
- public GlyphList(final String name, final String[] sortedGlyphNames,
- final char[][] codePointsForGlyphNames,
- final char[] sortedCodePoints,
- final short[] glyphNamesForCodePoints) {
- this.name = name;
- this.sortedGlyphNames = sortedGlyphNames;
- this.codePointsForGlyphNames = codePointsForGlyphNames;
- this.sortedCodePoints = sortedCodePoints;
- this.glyphNamesForCodePoints = glyphNamesForCodePoints;
- }
-
- /**
- * Finds the glyph name for a given Unicode code point.
- * @param codePoint The Unicode code point for which a glyph name is sought.
- * @return The glyph name which corresponds to codePoint, or null if there
- * is none.
- */
- public String mapCodePointToGlyphName(final int codePoint) {
- if (this.sortedCodePoints == null
- || this.glyphNamesForCodePoints == null
- || this.sortedGlyphNames == null) {
- return null;
- }
- final int sortedCodePointIndex = Arrays.binarySearch(
- this.sortedCodePoints, (char) codePoint);
- if (sortedCodePointIndex < 0
- || sortedCodePointIndex
- >= this.glyphNamesForCodePoints.length) {
- return null;
- }
- final int glyphNameIndex =
- this.glyphNamesForCodePoints[sortedCodePointIndex];
- if (glyphNameIndex < 0
- || glyphNameIndex >= this.sortedGlyphNames.length) {
- return null;
- }
- return this.sortedGlyphNames[glyphNameIndex];
- }
-
- /**
- * Finds the Unicode code point which corresponds to a given glyph name.
- * @param glyphName The glyphe anem for which a code point is sought.
- * @return The Unicode code point which corresponds to glyphName, or 0xFFFF
- * if there is none.
- */
- public char mapGlyphNameToCodePoint(final String glyphName) {
- final char errorValue = 0xFFFF;
- if (this.sortedGlyphNames == null
- || this.codePointsForGlyphNames == null) {
- return errorValue;
- }
- final int sortedGlyphNameIndex = Arrays.binarySearch(
- this.sortedGlyphNames, glyphName);
- if (sortedGlyphNameIndex < 0
- || sortedGlyphNameIndex
- >= this.codePointsForGlyphNames.length) {
- return errorValue;
- }
- final char[] codePointArray =
- this.codePointsForGlyphNames[sortedGlyphNameIndex];
- if (codePointArray == null) {
- return errorValue;
- }
- return codePointArray[0];
- }
-
- /**
- * Returns the named GlyphList if it already exists, or, if it is a
- * predefined GlyphList, creates it and returns it.
- * @param name The name of the GlyphList to be returned.
- * @return The named glyph list, if it exists or can be created, or null
- * otherwise.
- */
- public static GlyphList getGlyphList(final String name) {
- // If already instantiated, return it.
- GlyphList list = GlyphList.glyphListMap.get(name);
- if (list != null) {
- return list;
- }
- // Otherwise, try to instantiate it.
- if (name.equals("AGL")) {
- list = GlyphListAGL.getInstance();
- } else if (name.equals("ZapfDingbats")) {
- list = new GlyphListZapfDingbats();
- }
- if (list == null) {
- return null;
- }
- GlyphList.glyphListMap.put(name, list);
- return list;
- }
-
- /**
- * Registers a new glyph list. Each glyph list is managed as a singleton
- * since there is no need for more than one copy.
- * @param name The name of the glyph list to be registered.
- * @param glyphList The glyph list to be registered.
- */
- public static voi...
[truncated message content] |
|
From: <vic...@us...> - 2009-04-29 19:15:09
|
Revision: 10814
http://foray.svn.sourceforge.net/foray/?rev=10814&view=rev
Author: victormote
Date: 2009-04-29 19:14:59 +0000 (Wed, 29 Apr 2009)
Log Message:
-----------
Remove some FOrayFont dependencies on FOrayPS.
Modified Paths:
--------------
trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingVector4a.java
Modified: trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java 2009-04-29 19:07:21 UTC (rev 10813)
+++ trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java 2009-04-29 19:14:59 UTC (rev 10814)
@@ -1154,7 +1154,7 @@
* metrics. */
createCharSet(psServer);
}
- this.internalEncoding = findInternalEncoding();
+ this.internalEncoding = findInternalEncoding(psServer);
}
/**
@@ -1624,9 +1624,10 @@
/**
* Converts the encoding and character set information for this font into an
* encoding instance, using standard encodings if possible.
+ * @param psServer The PostScript server.
* @return The internal encoding for this font.
*/
- protected EncodingVector findInternalEncoding() {
+ protected EncodingVector findInternalEncoding(final PsServer psServer) {
// Truncate the arrays to the right size.
if (this.internalCodePointCount < MetricsFileAFM.MAX_CODE_POINTS) {
char[] newArray = new char[this.internalCodePointCount];
@@ -1646,23 +1647,20 @@
+ this.getPostscriptName(), null, this.internalCodePoints,
this.internalCodePointIndexes);
/* Is this a predefined encoding? */
- EncodingVector4a predefinedEncoding = null;
+ EncodingVector predefinedEncoding = null;
if (this.getPostscriptName().equals("ZapfDingbats")) {
- predefinedEncoding = EncodingVector4a.getPredefinedEncoding(
- "ZapfDingbatsEncoding");
+ predefinedEncoding = psServer.getPredefinedEncoding(EncodingVector.Predefined.ZAPF_DINGBATS);
if (newEncoding.isSubsetOf(predefinedEncoding)) {
return predefinedEncoding;
}
}
if (this.getPostscriptName().equals("Symbol")) {
- predefinedEncoding = EncodingVector4a.getPredefinedEncoding(
- "SymbolEncoding");
+ predefinedEncoding = psServer.getPredefinedEncoding(EncodingVector.Predefined.SYMBOL);
if (newEncoding.isSubsetOf(predefinedEncoding)) {
return predefinedEncoding;
}
}
- predefinedEncoding = EncodingVector4a.getPredefinedEncoding(
- this.encodingScheme);
+ predefinedEncoding = psServer.getPredefinedEncoding(this.encodingScheme);
if (newEncoding.isSubsetOf(predefinedEncoding)) {
return predefinedEncoding;
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingVector4a.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingVector4a.java 2009-04-29 19:07:21 UTC (rev 10813)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingVector4a.java 2009-04-29 19:14:59 UTC (rev 10814)
@@ -447,7 +447,7 @@
* @return True iff otherVector encodes all items that this does, and
* encodes them the same way.
*/
- public boolean isSubsetOf(final EncodingVector4a otherVector) {
+ public boolean isSubsetOf(final EncodingVector otherVector) {
for (int i = 0; i < this.codePoints.length; i++) {
final int thisEncodedValue = this.encodeCharacter(
this.codePoints[i]);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-04-30 15:17:47
|
Revision: 10831
http://foray.svn.sourceforge.net/foray/?rev=10831&view=rev
Author: victormote
Date: 2009-04-30 15:17:46 +0000 (Thu, 30 Apr 2009)
Log Message:
-----------
Use lists instead of arrays to avoid needing to read the file twice.
Modified Paths:
--------------
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java
Added Paths:
-----------
trunk/foray/foray-common/src/java/org/foray/common/CharacterUtil.java
Added: trunk/foray/foray-common/src/java/org/foray/common/CharacterUtil.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/CharacterUtil.java (rev 0)
+++ trunk/foray/foray-common/src/java/org/foray/common/CharacterUtil.java 2009-04-30 15:17:46 UTC (rev 10831)
@@ -0,0 +1,59 @@
+/*
+ * 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 java.util.List;
+
+/**
+ * Utilities related to char and Character.
+ */
+public final class CharacterUtil {
+
+ /**
+ * Private constructor. This is a utility class, and should never be instantiated.
+ */
+ private CharacterUtil() { }
+
+ /**
+ * Converts a List of Character instances into an array of chars.
+ * @param list The List of Character instances to be converted to an array.
+ * @return The array of chars.
+ */
+ public static char[] toArray(final List<Character> list) {
+ if (list == null) {
+ return new char[0];
+ }
+ final char[] returnArray = new char[list.size()];
+ for (int i = 0; i < list.size(); i++) {
+ returnArray[i] = list.get(i);
+ }
+ return returnArray;
+ }
+
+}
Property changes on: trunk/foray/foray-common/src/java/org/foray/common/CharacterUtil.java
___________________________________________________________________
Added: svn:keywords
+ "Author Id Rev Date URL"
Added: svn:eol-style
+ native
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java 2009-04-30 14:23:39 UTC (rev 10830)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java 2009-04-30 15:17:46 UTC (rev 10831)
@@ -28,6 +28,7 @@
package org.foray.ps.encode;
+import org.foray.common.CharacterUtil;
import org.foray.common.Logging;
import org.foray.common.RandomReader;
import org.foray.common.StringUtil;
@@ -42,6 +43,8 @@
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
import java.util.StringTokenizer;
/**
@@ -134,21 +137,21 @@
/** The array of glyph lists that can be used to map names to codepoints. */
private GlyphList4a[] glyphListsToCheck = null;
- /** The names of the glyphs parsed from the encoding. */
- private String[] glyphNames;
-
/** The radix which should be used for parsing. For base-10 numbers, this
* value should be 10. For octal numbers, it should be 8. */
private int radix;
+ /** The names of the glyphs parsed from the encoding. */
+ private List<String> glyphNames = new ArrayList<String>();
+
/** The parsed glyph indexes. */
- private char[] glyphIndexes;
+ private List<Character> glyphIndexes = new ArrayList<Character>();
/** The parsed Unicode codepoints. */
- private char[] codePoints;
+ private List<Character> codePoints = new ArrayList<Character>();
/** The parsed encoded indexes. */
- private char[] codePointIndexes;
+ private List<Character> codePointIndexes = new ArrayList<Character>();
/**
* Create a new EncodingParser instance.
@@ -179,42 +182,13 @@
* @throws IOException For I/O Errors.
*/
public void parseList() throws IOException {
- final int numberOfLines = countLines();
- if (numberOfLines < 1) {
- return;
- }
- this.glyphNames = new String[numberOfLines];
- this.glyphIndexes = new char[numberOfLines];
parseLines();
sortGlyphNames();
createCodePoints();
- EncodingVector4a.sortCodePoints(this.codePoints, this.codePointIndexes);
+ EncodingVector4a.sortCodePoints(this.getCodePoints(), this.getCodePointIndexes());
}
/**
- * Counts the number of content lines in the input file.
- * @return The number of content lines in the input file.
- * @throws IOException For I/O Exception.
- */
- private int countLines() throws IOException {
- int count = 0;
- this.reader.seek(0);
- boolean endOfFile = false;
- while (! endOfFile) {
- final String currentLine = this.reader.readLine();
- if (currentLine == null) {
- endOfFile = true;
- break;
- }
- if (lineHasContent(currentLine)
- && lineAppliesToEncoding(currentLine)) {
- count++;
- }
- }
- return count;
- }
-
- /**
* Parses the lines of the file.
* @throws IOException For I/O Error.
*/
@@ -286,8 +260,13 @@
* data.
*/
private void processCurrentLine(final String line, final int arrayIndex) {
+ this.glyphNames.add(StringUtil.EMPTY_STRING);
+ this.glyphIndexes.add(Character.MIN_VALUE);
+ this.codePoints.add(Character.MIN_VALUE);
+ this.codePointIndexes.add(Character.MIN_VALUE);
+
final String[] tokens = tokenizeLine(line);
- this.glyphNames[arrayIndex] = tokens[0];
+ this.glyphNames.set(arrayIndex, tokens[0]);
final String numericString = tokens[this.columnNum];
int index = -1;
try {
@@ -303,7 +282,7 @@
if (index < 0) {
index = 0;
}
- this.glyphIndexes[arrayIndex] = (char) index;
+ this.glyphIndexes.set(arrayIndex, (char) index);
}
/**
@@ -331,18 +310,17 @@
boolean anyChanges = true;
while (anyChanges) {
anyChanges = false;
- for (int i = 0; i < this.glyphNames.length - 1; i++) {
- final int compareValue = this.glyphNames[i].compareTo(
- this.glyphNames[i + 1]);
+ for (int i = 0; i < this.glyphNames.size() - 1; i++) {
+ final int compareValue = this.glyphNames.get(i).compareTo(this.glyphNames.get(i + 1));
if (compareValue > 0) {
/* Item at [i + 1] is less than item at [i]. Switch them
* and the same elements in codePointsForGlyphNames. */
- final String storeString = this.glyphNames[i];
- this.glyphNames[i] = this.glyphNames[i + 1];
- this.glyphNames[i + 1] = storeString;
- final char storeChar = this.glyphIndexes[i];
- this.glyphIndexes[i] = this.glyphIndexes[i + 1];
- this.glyphIndexes[i + 1] = storeChar;
+ final String storeString = this.glyphNames.get(i);
+ this.glyphNames.set(i, this.glyphNames.get(i + 1));
+ this.glyphNames.set(i + 1, storeString);
+ final Character storeChar = this.glyphIndexes.get(i);
+ this.glyphIndexes.set(i, this.glyphIndexes.get(i + 1));
+ this.glyphIndexes.set(i + 1, storeChar);
anyChanges = true;
}
}
@@ -373,22 +351,20 @@
}
}
this.glyphListsToCheck[index] = GlyphList4a.getGlyphList("AGL");
- this.codePoints = new char[this.glyphNames.length];
- this.codePointIndexes = new char[this.codePoints.length];
- for (int i = 0; i < this.glyphNames.length; i++) {
- final String glyphName = this.glyphNames[i];
+ for (int i = 0; i < this.glyphNames.size(); i++) {
+ final String glyphName = this.glyphNames.get(i);
for (int j = 0; j < this.glyphListsToCheck.length; j++) {
glyphList = this.glyphListsToCheck[j];
final char codePoint = glyphList.mapGlyphNameToCodePoint(
glyphName);
if (codePoint != Character.MAX_VALUE) {
- this.codePoints[i] = codePoint;
- final char glyphIndex = this.glyphIndexes[i];
- this.codePointIndexes[i] = glyphIndex;
+ this.codePoints.set(i, codePoint);
+ final char glyphIndex = this.glyphIndexes.get(i);
+ this.codePointIndexes.set(i, glyphIndex);
break;
}
}
- if (this.codePointIndexes[i] == 0
+ if (this.codePointIndexes.get(i) == 0
&& ! glyphName.equals(EncodingVector4a.NOTDEF)) {
this.logger.error("Glyph name not found: " + glyphName);
}
@@ -419,20 +395,20 @@
// Write the glyph names.
s = " public static final String[] sortedGlyphNames = {\n";
out.write(s.getBytes());
- for (int i = 0; i < this.glyphNames.length; i++) {
+ for (int i = 0; i < this.glyphNames.size(); i++) {
s = " \"";
- s = s + this.glyphNames[i];
+ s = s + this.glyphNames.get(i);
s = s + "\"";
- if (i < this.glyphNames.length - 1) {
+ if (i < this.glyphNames.size() - 1) {
s = s + ",";
}
s = padSpaces(s, EncodingParser.GLYPH_NAMES_COLUMN_1, 2);
s = s + "// " + formatArrayIndex(i);
s = padSpaces(s, EncodingParser.GLYPH_NAMES_COLUMN_2, 1);
s = s + " glyph-index: 0x"
- + StringUtil.charToHexString(this.glyphIndexes[i], true,
+ + StringUtil.charToHexString(this.glyphIndexes.get(i), true,
EncodingParser.HEX_STRING_SIZE);
- s = s + " \\" + StringUtil.charToOctalString(this.glyphIndexes[i],
+ s = s + " \\" + StringUtil.charToOctalString(this.glyphIndexes.get(i),
EncodingParser.OCTAL_STRING_SIZE);
s = s + "\n";
out.write(s.getBytes());
@@ -445,13 +421,13 @@
out.write(s.getBytes());
s = " public static final short[] glyphIndexes = {\n";
out.write(s.getBytes());
- for (int i = 0; i < this.glyphIndexes.length; i++) {
- final char index = this.glyphIndexes[i];
+ for (int i = 0; i < this.glyphIndexes.size(); i++) {
+ final char index = this.glyphIndexes.get(i);
s = " ";
s = s + "0x";
s = s + StringUtil.charToHexString(index, true,
EncodingParser.HEX_STRING_SIZE);
- if (i < this.glyphIndexes.length - 1) {
+ if (i < this.glyphIndexes.size() - 1) {
s = s + ",";
}
s = padSpaces(s, EncodingParser.GLYPH_NAME_CODE_POINTS_COLUMN_1, 2);
@@ -460,7 +436,7 @@
s = s + "\\" + StringUtil.charToOctalString(index,
EncodingParser.OCTAL_STRING_SIZE);
s = padSpaces(s, EncodingParser.GLYPH_NAME_CODE_POINTS_COLUMN_3, 1);
- s = s + this.glyphNames[i];
+ s = s + this.glyphNames.get(i);
s = s + "\n";
out.write(s.getBytes());
}
@@ -476,23 +452,23 @@
out.write(s.getBytes());
s = " public static final char[] codePoints = {\n";
out.write(s.getBytes());
- for (int i = 0; i < this.codePoints.length; i++) {
- final char index = this.codePoints[i];
+ for (int i = 0; i < this.codePoints.size(); i++) {
+ final char index = this.codePoints.get(i);
s = " ";
s = s + "0x";
s = s + StringUtil.charToHexString(index, true,
EncodingParser.HEX_STRING_SIZE);
- if (i < this.codePoints.length - 1) {
+ if (i < this.codePoints.size() - 1) {
s = s + ",";
}
s = padSpaces(s, EncodingParser.CODE_POINTS_COLUMN_1, 2);
s = s + "// " + formatArrayIndex(i);
s = padSpaces(s, EncodingParser.CODE_POINTS_COLUMN_2, 2);
s = s + " glyph: 0x" + StringUtil.charToHexString(
- this.codePointIndexes[i], true,
+ this.codePointIndexes.get(i), true,
EncodingParser.HEX_STRING_SIZE);
s = s + " \\" + StringUtil.charToOctalString(
- this.codePointIndexes[i], EncodingParser.HEX_STRING_SIZE);
+ this.codePointIndexes.get(i), EncodingParser.HEX_STRING_SIZE);
s = s + "\n";
out.write(s.getBytes());
}
@@ -504,13 +480,13 @@
out.write(s.getBytes());
s = " public static final char[] codePointIndexes = {\n";
out.write(s.getBytes());
- for (int i = 0; i < this.codePointIndexes.length; i++) {
- final char index = this.codePointIndexes[i];
+ for (int i = 0; i < this.codePointIndexes.size(); i++) {
+ final char index = this.codePointIndexes.get(i);
s = " ";
s = s + "0x";
s = s + StringUtil.charToHexString(index, true,
EncodingParser.HEX_STRING_SIZE);
- if (i < this.codePointIndexes.length - 1) {
+ if (i < this.codePointIndexes.size() - 1) {
s = s + ",";
}
s = padSpaces(s, EncodingParser.CODE_POINTS_INDEX_1, 2);
@@ -558,7 +534,7 @@
* @return The codepoint indexes.
*/
public char[] getCodePointIndexes() {
- return this.codePointIndexes;
+ return CharacterUtil.toArray(this.codePointIndexes);
}
/**
@@ -566,7 +542,7 @@
* @return The codepoints.
*/
public char[] getCodePoints() {
- return this.codePoints;
+ return CharacterUtil.toArray(this.codePoints);
}
/**
@@ -574,7 +550,7 @@
* @return The glyph indexes.
*/
public char[] getGlyphIndexes() {
- return this.glyphIndexes;
+ return CharacterUtil.toArray(this.glyphIndexes);
}
/**
@@ -582,7 +558,8 @@
* @return The glyph names.
*/
public String[] getGlyphNames() {
- return this.glyphNames;
+ final String[] returnArray = new String[this.glyphNames.size()];
+ return this.glyphNames.toArray(returnArray);
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-04-30 16:03:13
|
Revision: 10834
http://foray.svn.sourceforge.net/foray/?rev=10834&view=rev
Author: victormote
Date: 2009-04-30 16:03:09 +0000 (Thu, 30 Apr 2009)
Log Message:
-----------
Change the input to InputStream for a more general solution.
Modified Paths:
--------------
trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetParser.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphListParser.java
trunk/foray/foray-ps/src/javatest/org/foray/ps/encode/TestEncodingParser.java
trunk/foray/foray-ps/src/javatest/org/foray/ps/encode/TestGlyphListParser.java
Modified: trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java 2009-04-30 15:48:23 UTC (rev 10833)
+++ trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java 2009-04-30 16:03:09 UTC (rev 10834)
@@ -28,7 +28,6 @@
package org.foray.font;
-import org.foray.common.RandomReader;
import org.foray.common.url.URLFactory;
import org.foray.ps.encode.EncodingCustom;
import org.foray.ps.encode.EncodingParser;
@@ -52,6 +51,7 @@
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
@@ -738,9 +738,9 @@
logError("Unable to create URL: " + encodingFile);
return;
}
- RandomReader reader;
+ InputStream input;
try {
- reader = new RandomReader(url);
+ input = url.openStream();
} catch (final IOException e1) {
logError("Unable to read: " + encodingFile);
return;
@@ -762,7 +762,7 @@
}
final int radix = Integer.parseInt(radixString);
final EncodingParser parser = new EncodingParser(
- this.fontServer.getLogger(), reader, columnNumber, radix,
+ this.fontServer.getLogger(), input, columnNumber, radix,
attributes.getValue("glyph-lists"));
try {
parser.parseList();
@@ -806,15 +806,14 @@
logError("Unable to create URL: " + file);
return;
}
- RandomReader reader;
+ InputStream input;
try {
- reader = new RandomReader(url);
+ input = url.openStream();
} catch (final IOException e1) {
logError("Unable to read: " + file);
return;
}
- final GlyphListParser parser = new GlyphListParser(
- this.fontServer.getLogger(), reader);
+ final GlyphListParser parser = new GlyphListParser(this.fontServer.getLogger(), input);
try {
parser.parseList();
} catch (final IOException e2) {
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetParser.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetParser.java 2009-04-30 15:48:23 UTC (rev 10833)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetParser.java 2009-04-30 16:03:09 UTC (rev 10834)
@@ -30,15 +30,17 @@
import org.foray.common.CharacterUtil;
import org.foray.common.Logging;
-import org.foray.common.RandomReader;
import org.foray.common.StringUtil;
import org.foray.common.url.URLFactory;
import org.apache.commons.logging.Log;
+import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
@@ -63,7 +65,7 @@
private static final int DESIRED_COLUMN = 28;
/** The reader for the file. */
- private RandomReader reader = null;
+ private BufferedReader reader = null;
/** The current line number. */
private transient int currentLineNumber = 0;
@@ -80,11 +82,12 @@
/**
* Create a new CharSetParser instance.
* @param logger The logger to use for user messages.
- * @param reader The reader encapsulating the file to be read.
+ * @param input The reader encapsulating the file to be read.
*/
- public CharSetParser(final Log logger, final RandomReader reader) {
+ public CharSetParser(final Log logger, final InputStream input) {
this.logger = logger;
- this.reader = reader;
+ final InputStreamReader isr = new InputStreamReader(input);
+ this.reader = new BufferedReader(isr);
}
/**
@@ -101,7 +104,6 @@
* @throws IOException For I/O error.
*/
private void parseLines() throws IOException {
- this.reader.seek(0);
boolean endOfFile = false;
endOfFile = false;
int arrayIndex = 0;
@@ -257,9 +259,9 @@
logger.error(" " + e.getMessage());
System.exit(1);
}
- RandomReader input = null;
+ InputStream input = null;
try {
- input = new RandomReader(url);
+ input = url.openStream();
} catch (final IOException e1) {
logger.error("Unable to create Reader for: " + args[0] + "\n");
System.exit(1);
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java 2009-04-30 15:48:23 UTC (rev 10833)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java 2009-04-30 16:03:09 UTC (rev 10834)
@@ -30,16 +30,18 @@
import org.foray.common.CharacterUtil;
import org.foray.common.Logging;
-import org.foray.common.RandomReader;
import org.foray.common.StringUtil;
import org.foray.common.WKConstants;
import org.foray.common.url.URLFactory;
import org.apache.commons.logging.Log;
+import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
@@ -116,7 +118,7 @@
private static final int CODE_POINTS_INDEX_1 = 18;
/** The reader for the input file. */
- private RandomReader reader = null;
+ private BufferedReader reader = null;
/** Counter for the current line number. */
private int currentLineNumber = 0;
@@ -156,7 +158,7 @@
/**
* Create a new EncodingParser instance.
* @param logger The logger.
- * @param reader The reader encapsulating the file to be parsed.
+ * @param input The reader encapsulating the file to be parsed.
* @param columnNum The column number in the input file that should be
* read to get the encoded value for this encoding.
* Column number 1 is the first field after the glyph name, that is, field
@@ -168,10 +170,11 @@
* The Adobe Glyph List is always consulted, but only after any custom ones
* listed here.
*/
- public EncodingParser(final Log logger, final RandomReader reader,
- final int columnNum, final int radix, final String glyphLists) {
+ public EncodingParser(final Log logger, final InputStream input, final int columnNum, final int radix,
+ final String glyphLists) {
this.logger = logger;
- this.reader = reader;
+ final InputStreamReader isr = new InputStreamReader(input);
+ this.reader = new BufferedReader(isr);
this.columnNum = columnNum;
this.radix = radix;
this.glyphLists = glyphLists;
@@ -193,7 +196,6 @@
* @throws IOException For I/O Error.
*/
private void parseLines() throws IOException {
- this.reader.seek(0);
boolean endOfFile = false;
endOfFile = false;
int arrayIndex = 0;
@@ -613,9 +615,9 @@
logger.error(" " + e.getMessage());
System.exit(1);
}
- RandomReader input = null;
+ InputStream input = null;
try {
- input = new RandomReader(url);
+ input = url.openStream();
} catch (final IOException e1) {
logger.error("Unable to create Reader for: "
+ args[EncodingParser.ARG_INPUT_URL]
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphListParser.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphListParser.java 2009-04-30 15:48:23 UTC (rev 10833)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphListParser.java 2009-04-30 16:03:09 UTC (rev 10834)
@@ -29,16 +29,18 @@
package org.foray.ps.encode;
import org.foray.common.Logging;
-import org.foray.common.RandomReader;
import org.foray.common.StringUtil;
import org.foray.common.WKConstants;
import org.foray.common.url.URLFactory;
import org.apache.commons.logging.Log;
+import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
@@ -55,7 +57,7 @@
private static final char[] EMPTY_CHAR_ARRAY = new char[0];
/** The reader used by this parser. */
- private RandomReader reader = null;
+ private BufferedReader reader = null;
/** Counter for the current line number. */
private int currentLineNumber = 0;
@@ -84,11 +86,12 @@
/**
* Create a new GlyphListParser instance.
* @param logger The logger.
- * @param reader The reader encapsulating the file to be parsed.
+ * @param input The file to be parsed.
*/
- public GlyphListParser(final Log logger, final RandomReader reader) {
+ public GlyphListParser(final Log logger, final InputStream input) {
this.logger = logger;
- this.reader = reader;
+ final InputStreamReader isr = new InputStreamReader(input);
+ this.reader = new BufferedReader(isr);
}
/**
@@ -108,7 +111,6 @@
* @throws IOException For I/O Error.
*/
private void parseLines() throws IOException {
- this.reader.seek(0);
boolean endOfFile = false;
endOfFile = false;
int arrayIndex = 0;
@@ -420,9 +422,9 @@
logger.error(" " + e.getMessage());
System.exit(1);
}
- RandomReader input = null;
+ InputStream input = null;
try {
- input = new RandomReader(url);
+ input = url.openStream();
} catch (final IOException e1) {
logger.error("Unable to create Reader for: " + args[0] + "\n");
System.exit(1);
Modified: trunk/foray/foray-ps/src/javatest/org/foray/ps/encode/TestEncodingParser.java
===================================================================
--- trunk/foray/foray-ps/src/javatest/org/foray/ps/encode/TestEncodingParser.java 2009-04-30 15:48:23 UTC (rev 10833)
+++ trunk/foray/foray-ps/src/javatest/org/foray/ps/encode/TestEncodingParser.java 2009-04-30 16:03:09 UTC (rev 10834)
@@ -29,11 +29,12 @@
package org.foray.ps.encode;
import org.foray.common.Logging;
-import org.foray.common.RandomReader;
import org.foray.common.TestFOrayCommon;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
import junit.framework.TestCase;
@@ -49,11 +50,11 @@
public void testWinAnsi() throws IOException {
final File sandbox = TestFOrayCommon.getSandbox();
final File testFile = new File(sandbox, "foray-ps/resource/encoding/latin-pdf.txt");
- final RandomReader reader = new RandomReader(testFile.toURI().toURL());
- assertNotNull(reader);
+ final InputStream input = new FileInputStream(testFile);
+ assertNotNull(input);
/* The WinAnsi content is in column 3, and the radix is octal. See the file itself for details. */
- final EncodingParser parser = new EncodingParser(Logging.makeDefaultLogger(), reader, 3, 8, null);
+ final EncodingParser parser = new EncodingParser(Logging.makeDefaultLogger(), input, 3, 8, null);
parser.parseList();
/* Did we parse the right number of elements. Last element is on line 237. First 8 lines are blank. In the
Modified: trunk/foray/foray-ps/src/javatest/org/foray/ps/encode/TestGlyphListParser.java
===================================================================
--- trunk/foray/foray-ps/src/javatest/org/foray/ps/encode/TestGlyphListParser.java 2009-04-30 15:48:23 UTC (rev 10833)
+++ trunk/foray/foray-ps/src/javatest/org/foray/ps/encode/TestGlyphListParser.java 2009-04-30 16:03:09 UTC (rev 10834)
@@ -29,10 +29,10 @@
package org.foray.ps.encode;
import org.foray.common.Logging;
-import org.foray.common.RandomReader;
import org.foray.common.TestFOrayCommon;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import junit.framework.TestCase;
@@ -49,10 +49,10 @@
public void testZdGl() throws IOException {
final File sandbox = TestFOrayCommon.getSandbox();
final File testFile = new File(sandbox, "foray-ps/resource/glyph-list/zapfdingbats.txt");
- final RandomReader reader = new RandomReader(testFile.toURI().toURL());
- assertNotNull(reader);
+ final FileInputStream input = new FileInputStream(testFile);
+ assertNotNull(input);
- final GlyphListParser parser = new GlyphListParser(Logging.makeDefaultLogger(), reader);
+ final GlyphListParser parser = new GlyphListParser(Logging.makeDefaultLogger(), input);
parser.parseList();
/* Test that we parsed the right number of elements. */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-04-30 16:23:05
|
Revision: 10835
http://foray.svn.sourceforge.net/foray/?rev=10835&view=rev
Author: victormote
Date: 2009-04-30 16:22:59 +0000 (Thu, 30 Apr 2009)
Log Message:
-----------
Throw Exceptions instead of logging errors.
Modified Paths:
--------------
trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetParser.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphListParser.java
trunk/foray/foray-ps/src/javatest/org/foray/ps/encode/TestEncodingParser.java
trunk/foray/foray-ps/src/javatest/org/foray/ps/encode/TestGlyphListParser.java
Modified: trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java 2009-04-30 16:03:09 UTC (rev 10834)
+++ trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java 2009-04-30 16:22:59 UTC (rev 10835)
@@ -36,6 +36,7 @@
import org.foray.ps.encode.GlyphListParser;
import org.axsl.font.FontException;
+import org.axsl.ps.PsException;
import org.apache.commons.logging.Log;
@@ -761,13 +762,14 @@
return;
}
final int radix = Integer.parseInt(radixString);
- final EncodingParser parser = new EncodingParser(
- this.fontServer.getLogger(), input, columnNumber, radix,
+ final EncodingParser parser = new EncodingParser(input, columnNumber, radix,
attributes.getValue("glyph-lists"));
try {
parser.parseList();
} catch (final IOException e2) {
logError("Error parsing: " + encodingFile);
+ } catch (final PsException e2) {
+ logError("Error parsing: " + encodingFile);
}
encoding = new EncodingCustom(name, parser.getGlyphListsToCheck(),
parser.getCodePoints(),
@@ -813,11 +815,13 @@
logError("Unable to read: " + file);
return;
}
- final GlyphListParser parser = new GlyphListParser(this.fontServer.getLogger(), input);
+ final GlyphListParser parser = new GlyphListParser(input);
try {
parser.parseList();
} catch (final IOException e2) {
logError("Error parsing: " + file);
+ } catch (final PsException e2) {
+ logError("Error parsing: " + file);
}
glyphList = new GlyphList4a(name, parser.getGlyphNames(),
parser.getCodePointsForGlyphNames(), parser.getCodePoints(),
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetParser.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetParser.java 2009-04-30 16:03:09 UTC (rev 10834)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetParser.java 2009-04-30 16:22:59 UTC (rev 10835)
@@ -33,6 +33,8 @@
import org.foray.common.StringUtil;
import org.foray.common.url.URLFactory;
+import org.axsl.ps.PsException;
+
import org.apache.commons.logging.Log;
import java.io.BufferedReader;
@@ -76,16 +78,11 @@
/** The array of glyph names in the character set. */
private List<String> glyphNames = new ArrayList<String>();
- /** The logger. */
- private Log logger;
-
/**
* Create a new CharSetParser instance.
- * @param logger The logger to use for user messages.
* @param input The reader encapsulating the file to be read.
*/
- public CharSetParser(final Log logger, final InputStream input) {
- this.logger = logger;
+ public CharSetParser(final InputStream input) {
final InputStreamReader isr = new InputStreamReader(input);
this.reader = new BufferedReader(isr);
}
@@ -93,8 +90,9 @@
/**
* Parses a glyph list.
* @throws IOException For I/O error.
+ * @throws PsException For errors parsing the input.
*/
- public void parseList() throws IOException {
+ public void parseList() throws IOException, PsException {
parseLines();
sortCharacterSet();
}
@@ -102,8 +100,9 @@
/**
* Parses the lines of the character set input file.
* @throws IOException For I/O error.
+ * @throws PsException For errors parsing the input.
*/
- private void parseLines() throws IOException {
+ private void parseLines() throws IOException, PsException {
boolean endOfFile = false;
endOfFile = false;
int arrayIndex = 0;
@@ -147,14 +146,15 @@
* Process a content line.
* @param line The text from the line.
* @param arrayIndex The current glyph index being processed.
+ * @throws PsException For errors parsing the line.
*/
- private void processCurrentLine(final String line, final int arrayIndex) {
+ private void processCurrentLine(final String line, final int arrayIndex) throws PsException {
this.characterSet.add(Character.MIN_VALUE);
this.glyphNames.add(StringUtil.EMPTY_STRING);
final GlyphList4a gl = GlyphList4a.getGlyphList("AGL");
final char theChar = gl.mapGlyphNameToCodePoint(line);
if (theChar == Character.MAX_VALUE) {
- this.logger.error("Character not found in Adobe Glyph List, line "
+ throw new PsException("Character not found in Adobe Glyph List, line "
+ this.currentLineNumber + ": " + line);
}
@@ -274,13 +274,17 @@
+ args[1] + "\n");
System.exit(1);
}
- final CharSetParser parser = new CharSetParser(logger, input);
+ final CharSetParser parser = new CharSetParser(input);
try {
parser.parseList();
} catch (final IOException e3) {
logger.error("Error parsing: " + args[0] + "\n");
logger.error(" " + e3.getMessage());
System.exit(1);
+ } catch (final PsException e3) {
+ logger.error("Error parsing: " + args[0] + "\n");
+ logger.error(" " + e3.getMessage());
+ System.exit(1);
}
try {
parser.writeAsJavaStatics(output);
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java 2009-04-30 16:03:09 UTC (rev 10834)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java 2009-04-30 16:22:59 UTC (rev 10835)
@@ -34,6 +34,8 @@
import org.foray.common.WKConstants;
import org.foray.common.url.URLFactory;
+import org.axsl.ps.PsException;
+
import org.apache.commons.logging.Log;
import java.io.BufferedReader;
@@ -129,9 +131,6 @@
* different column. */
private int columnNum = -1;
- /** The logger. */
- private Log logger;
-
/** The raw space-separated list of glyphs lists that should be consulted to
* map glyph names to Unicode codepoints for this encoding. */
private String glyphLists;
@@ -157,22 +156,16 @@
/**
* Create a new EncodingParser instance.
- * @param logger The logger.
* @param input The reader encapsulating the file to be parsed.
- * @param columnNum The column number in the input file that should be
- * read to get the encoded value for this encoding.
- * Column number 1 is the first field after the glyph name, that is, field
- * 2.
- * @param radix The radix of the numbering system (10 for decimal, 8 for
- * octal, etc.).
- * @param glyphLists A space-separated list of glyph lists to be consulted
- * when mapping glyph names to Unicode code points.
- * The Adobe Glyph List is always consulted, but only after any custom ones
- * listed here.
+ * @param columnNum The column number in the input file that should be read to get the encoded value for this
+ * encoding.
+ * Column number 1 is the first field after the glyph name, that is, field 2.
+ * @param radix The radix of the numbering system (10 for decimal, 8 for octal, etc.).
+ * @param glyphLists A space-separated list of glyph lists to be consulted when mapping glyph names to Unicode code
+ * points.
+ * The Adobe Glyph List is always consulted, but only after any custom ones listed here.
*/
- public EncodingParser(final Log logger, final InputStream input, final int columnNum, final int radix,
- final String glyphLists) {
- this.logger = logger;
+ public EncodingParser(final InputStream input, final int columnNum, final int radix, final String glyphLists) {
final InputStreamReader isr = new InputStreamReader(input);
this.reader = new BufferedReader(isr);
this.columnNum = columnNum;
@@ -183,8 +176,9 @@
/**
* Parses a glyph list.
* @throws IOException For I/O Errors.
+ * @throws PsException For errors parsing the input.
*/
- public void parseList() throws IOException {
+ public void parseList() throws IOException, PsException {
parseLines();
sortGlyphNames();
createCodePoints();
@@ -194,8 +188,9 @@
/**
* Parses the lines of the file.
* @throws IOException For I/O Error.
+ * @throws PsException For errors parsing the input.
*/
- private void parseLines() throws IOException {
+ private void parseLines() throws IOException, PsException {
boolean endOfFile = false;
endOfFile = false;
int arrayIndex = 0;
@@ -258,10 +253,10 @@
/**
* Parsed the content line.
* @param line The String of text for the line being parsed.
- * @param arrayIndex The current index into the arrays containing the parsed
- * data.
+ * @param arrayIndex The current index into the arrays containing the parsed data.
+ * @throws PsException For errors parsing the line.
*/
- private void processCurrentLine(final String line, final int arrayIndex) {
+ private void processCurrentLine(final String line, final int arrayIndex) throws PsException {
this.glyphNames.add(StringUtil.EMPTY_STRING);
this.glyphIndexes.add(Character.MIN_VALUE);
this.codePoints.add(Character.MIN_VALUE);
@@ -274,9 +269,7 @@
try {
index = Integer.parseInt(numericString, this.radix);
} catch (final NumberFormatException e) {
- this.logger.error("Invalid octal string, line "
- + this.currentLineNumber
- + ": " + numericString);
+ throw new PsException("Invalid octal string, line " + this.currentLineNumber + ": " + numericString, e);
}
if (index > WKConstants.MAX_8_BIT_UNSIGNED_VALUES - 1) {
index = WKConstants.MAX_8_BIT_UNSIGNED_VALUES - 1;
@@ -333,8 +326,9 @@
* For each glyph name in the encoding, finds all known Unicode code points
* that map to that glyph name, and writes them to an array. It also writes
* the glyph index for this encoding to a parallel array.
+ * @throws PsException If a glyph name cannot be mapped to a code point.
*/
- private void createCodePoints() {
+ private void createCodePoints() throws PsException {
StringTokenizer tokenizer = null;
int numListsToCheck = 1;
if (this.glyphLists != null
@@ -368,7 +362,7 @@
}
if (this.codePointIndexes.get(i) == 0
&& ! glyphName.equals(EncodingVector4a.NOTDEF)) {
- this.logger.error("Glyph name not found: " + glyphName);
+ throw new PsException("Glyph name not found: " + glyphName);
}
}
}
@@ -658,8 +652,7 @@
if (args.length > EncodingParser.ARG_GLYPH_LISTS) {
customGlyphLists = args[EncodingParser.ARG_GLYPH_LISTS];
}
- final EncodingParser parser = new EncodingParser(logger, input,
- columnNum, radix, customGlyphLists);
+ final EncodingParser parser = new EncodingParser(input, columnNum, radix, customGlyphLists);
try {
parser.parseList();
} catch (final IOException e3) {
@@ -667,6 +660,11 @@
+ args[EncodingParser.ARG_INPUT_URL] + "\n");
logger.error(" " + e3.getMessage());
System.exit(1);
+ } catch (final PsException e3) {
+ logger.error("Error parsing: "
+ + args[EncodingParser.ARG_INPUT_URL] + "\n");
+ logger.error(" " + e3.getMessage());
+ System.exit(1);
}
try {
parser.writeAsJavaStatics(output);
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphListParser.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphListParser.java 2009-04-30 16:03:09 UTC (rev 10834)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphListParser.java 2009-04-30 16:22:59 UTC (rev 10835)
@@ -33,6 +33,8 @@
import org.foray.common.WKConstants;
import org.foray.common.url.URLFactory;
+import org.axsl.ps.PsException;
+
import org.apache.commons.logging.Log;
import java.io.BufferedReader;
@@ -80,16 +82,11 @@
* @see #getGlyphNameIndex() */
private short[] glyphNameIndex;
- /** The logger. */
- private Log logger;
-
/**
* Create a new GlyphListParser instance.
- * @param logger The logger.
* @param input The file to be parsed.
*/
- public GlyphListParser(final Log logger, final InputStream input) {
- this.logger = logger;
+ public GlyphListParser(final InputStream input) {
final InputStreamReader isr = new InputStreamReader(input);
this.reader = new BufferedReader(isr);
}
@@ -97,8 +94,9 @@
/**
* Parses a glyph list.
* @throws IOException For I/O Error.
+ * @throws PsException For errors parsing the input.
*/
- public void parseList() throws IOException {
+ public void parseList() throws IOException, PsException {
parseLines();
sortGlyphNames();
copyCodePoints();
@@ -109,8 +107,9 @@
/**
* Parse the lines of the file.
* @throws IOException For I/O Error.
+ * @throws PsException For errors parsing the input.
*/
- private void parseLines() throws IOException {
+ private void parseLines() throws IOException, PsException {
boolean endOfFile = false;
endOfFile = false;
int arrayIndex = 0;
@@ -153,10 +152,10 @@
/**
* Parsed the current line of content.
* @param line The line from the input file.
- * @param arrayIndex The index into the arrays of parsed input into which
- * the parsed input should be placed.
+ * @param arrayIndex The index into the arrays of parsed input into which the parsed input should be placed.
+ * @throws PsException For errors parsing the line.
*/
- private void processCurrentLine(final String line, final int arrayIndex) {
+ private void processCurrentLine(final String line, final int arrayIndex) throws PsException {
this.glyphNames.add(StringUtil.EMPTY_STRING);
this.codePointsForGlyphNames.add(GlyphListParser.EMPTY_CHAR_ARRAY);
@@ -167,17 +166,12 @@
this.glyphNames.set(arrayIndex, tokens[0]);
final char[] charArray = new char[tokens.length - 1];
for (int i = 1; i < tokens.length; i++) {
- int parsedValue = Integer.parseInt(tokens[i],
- WKConstants.MAX_4_BIT_UNSIGNED_VALUES);
+ final int parsedValue = Integer.parseInt(tokens[i], WKConstants.MAX_4_BIT_UNSIGNED_VALUES);
if (parsedValue < 0) {
- this.logger.error("Value out of range, line "
- + this.currentLineNumber);
- parsedValue = 0;
+ throw new PsException("Value out of range, line " + this.currentLineNumber);
}
if (parsedValue > WKConstants.MAX_16_BIT_UNSIGNED_VALUES - 1) {
- this.logger.error("Value out of range, line "
- + this.currentLineNumber);
- parsedValue = WKConstants.MAX_16_BIT_UNSIGNED_VALUES - 1;
+ throw new PsException("Value out of range, line " + this.currentLineNumber);
}
charArray[i - 1] = (char) parsedValue;
}
@@ -437,13 +431,17 @@
+ args[1] + "\n");
System.exit(1);
}
- final GlyphListParser parser = new GlyphListParser(logger, input);
+ final GlyphListParser parser = new GlyphListParser(input);
try {
parser.parseList();
} catch (final IOException e3) {
logger.error("Error parsing: " + args[0] + "\n");
logger.error(" " + e3.getMessage());
System.exit(1);
+ } catch (final PsException e3) {
+ logger.error("Error parsing: " + args[0] + "\n");
+ logger.error(" " + e3.getMessage());
+ System.exit(1);
}
try {
parser.writeAsJavaStatics(output);
Modified: trunk/foray/foray-ps/src/javatest/org/foray/ps/encode/TestEncodingParser.java
===================================================================
--- trunk/foray/foray-ps/src/javatest/org/foray/ps/encode/TestEncodingParser.java 2009-04-30 16:03:09 UTC (rev 10834)
+++ trunk/foray/foray-ps/src/javatest/org/foray/ps/encode/TestEncodingParser.java 2009-04-30 16:22:59 UTC (rev 10835)
@@ -28,9 +28,10 @@
package org.foray.ps.encode;
-import org.foray.common.Logging;
import org.foray.common.TestFOrayCommon;
+import org.axsl.ps.PsException;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -46,15 +47,16 @@
/**
* Black-box test, parsing the glyph list for the WinAnsi Encoding.
* @throws IOException For errors opening or reading the input file.
+ * @throws PsException For errors parsing the input.
*/
- public void testWinAnsi() throws IOException {
+ public void testWinAnsi() throws IOException, PsException {
final File sandbox = TestFOrayCommon.getSandbox();
final File testFile = new File(sandbox, "foray-ps/resource/encoding/latin-pdf.txt");
final InputStream input = new FileInputStream(testFile);
assertNotNull(input);
/* The WinAnsi content is in column 3, and the radix is octal. See the file itself for details. */
- final EncodingParser parser = new EncodingParser(Logging.makeDefaultLogger(), input, 3, 8, null);
+ final EncodingParser parser = new EncodingParser(input, 3, 8, null);
parser.parseList();
/* Did we parse the right number of elements. Last element is on line 237. First 8 lines are blank. In the
Modified: trunk/foray/foray-ps/src/javatest/org/foray/ps/encode/TestGlyphListParser.java
===================================================================
--- trunk/foray/foray-ps/src/javatest/org/foray/ps/encode/TestGlyphListParser.java 2009-04-30 16:03:09 UTC (rev 10834)
+++ trunk/foray/foray-ps/src/javatest/org/foray/ps/encode/TestGlyphListParser.java 2009-04-30 16:22:59 UTC (rev 10835)
@@ -28,9 +28,10 @@
package org.foray.ps.encode;
-import org.foray.common.Logging;
import org.foray.common.TestFOrayCommon;
+import org.axsl.ps.PsException;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -45,14 +46,15 @@
/**
* Black-box test, parsing the glyph list for Zapf Dingbats.
* @throws IOException For errors opening or reading the input file.
+ * @throws PsException For errors parsing the input.
*/
- public void testZdGl() throws IOException {
+ public void testZdGl() throws IOException, PsException {
final File sandbox = TestFOrayCommon.getSandbox();
final File testFile = new File(sandbox, "foray-ps/resource/glyph-list/zapfdingbats.txt");
final FileInputStream input = new FileInputStream(testFile);
assertNotNull(input);
- final GlyphListParser parser = new GlyphListParser(Logging.makeDefaultLogger(), input);
+ final GlyphListParser parser = new GlyphListParser(input);
parser.parseList();
/* Test that we parsed the right number of elements. */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-04-30 22:50:32
|
Revision: 10838
http://foray.svn.sourceforge.net/foray/?rev=10838&view=rev
Author: victormote
Date: 2009-04-30 22:50:12 +0000 (Thu, 30 Apr 2009)
Log Message:
-----------
Add server method to parse an encoding vector.
Modified Paths:
--------------
trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java
trunk/foray/foray-ps/src/java/org/foray/ps/PsServer4a.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java
Modified: trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java 2009-04-30 17:50:15 UTC (rev 10837)
+++ trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java 2009-04-30 22:50:12 UTC (rev 10838)
@@ -55,9 +55,12 @@
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Stack;
+import java.util.StringTokenizer;
import javax.xml.parsers.SAXParserFactory;
@@ -762,8 +765,14 @@
return;
}
final int radix = Integer.parseInt(radixString);
- final EncodingParser parser = new EncodingParser(input, columnNumber, radix,
- attributes.getValue("glyph-lists"));
+ final List<String> glyphList = new ArrayList<String>();
+ final String glyphListString = attributes.getValue("glyph-lists");
+ final StringTokenizer tokenizer = new StringTokenizer(glyphListString);
+ while (tokenizer.hasMoreTokens()) {
+ final String token = tokenizer.nextToken();
+ glyphList.add(token);
+ }
+ final EncodingParser parser = new EncodingParser(input, columnNumber, radix, glyphList);
try {
parser.parseList();
} catch (final IOException e2) {
@@ -771,8 +780,7 @@
} catch (final PsException e2) {
logError("Error parsing: " + encodingFile);
}
- encoding = new EncodingCustom(name, parser.getGlyphListsToCheck(),
- parser.getCodePoints(),
+ encoding = new EncodingCustom(name, parser.getGlyphListsToCheck(), parser.getCodePoints(),
parser.getCodePointIndexes());
EncodingVector4a.registerEncoding(name, encoding);
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/PsServer4a.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/PsServer4a.java 2009-04-30 17:50:15 UTC (rev 10837)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/PsServer4a.java 2009-04-30 22:50:12 UTC (rev 10838)
@@ -33,6 +33,8 @@
import org.foray.ps.encode.CharSet4a;
import org.foray.ps.encode.CharSetParser;
import org.foray.ps.encode.EncodingCustom;
+import org.foray.ps.encode.EncodingParser;
+import org.foray.ps.encode.EncodingVector4a;
import org.foray.ps.encode.GlyphList4a;
import org.foray.ps.encode.GlyphListParser;
import org.foray.ps.filter.Ascii85DecodeFilter;
@@ -67,6 +69,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.List;
/**
* Implementation of {@link PsServer} for FOray.
@@ -225,15 +228,14 @@
* @throws IOException For errors opening or reading the input stream.
* @throws PsException For errors parsing the encoding vector.
*/
-// public EncodingVector4a parseEncodingVector(final String name, final InputStream inputStream, final int columnNum,
-// final int radix, final List<GlyphList> glyphLists) throws IOException, PsException {
-// final EncodingParser parser = new EncodingParser(inputStream, columnNum, radix, glyphLists);
-// parser.parseList();
-// final EncodingVector4a encodingVector = new EncodingVector4a(name, parser.getGlyphNames(),
-// parser.getCodePointsForGlyphNames(),
-// parser.getCodePoints(), parser.getGlyphNameIndex());
-// return encodingVector;
-// }
+ public EncodingVector4a parseEncodingVector(final String name, final InputStream inputStream, final int columnNum,
+ final int radix, final List<String> glyphLists) throws IOException, PsException {
+ final EncodingParser parser = new EncodingParser(inputStream, columnNum, radix, glyphLists);
+ parser.parseList();
+ final EncodingVector4a encodingVector = new EncodingCustom(name, parser.getGlyphListsToCheck(),
+ parser.getCodePoints(), parser.getCodePointIndexes());
+ return encodingVector;
+ }
/**
* {@inheritDoc}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java 2009-04-30 17:50:15 UTC (rev 10837)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java 2009-04-30 22:50:12 UTC (rev 10838)
@@ -34,6 +34,7 @@
import org.foray.common.WKConstants;
import org.foray.common.url.URLFactory;
+import org.axsl.ps.GlyphList;
import org.axsl.ps.PsException;
import org.apache.commons.logging.Log;
@@ -133,7 +134,7 @@
/** The raw space-separated list of glyphs lists that should be consulted to
* map glyph names to Unicode codepoints for this encoding. */
- private String glyphLists;
+ private List<String> glyphLists;
/** The array of glyph lists that can be used to map names to codepoints. */
private List<GlyphList4a> glyphListsToCheck = null;
@@ -161,16 +162,20 @@
* encoding.
* Column number 1 is the first field after the glyph name, that is, field 2.
* @param radix The radix of the numbering system (10 for decimal, 8 for octal, etc.).
- * @param glyphLists A space-separated list of glyph lists to be consulted when mapping glyph names to Unicode code
- * points.
+ * @param glyphLists The list of glyph lists to be consulted when mapping glyph names to Unicode code points, listed
+ * in the order in which they should be checked.
* The Adobe Glyph List is always consulted, but only after any custom ones listed here.
*/
- public EncodingParser(final InputStream input, final int columnNum, final int radix, final String glyphLists) {
+ public EncodingParser(final InputStream input, final int columnNum, final int radix,
+ final List<String> glyphLists) {
final InputStreamReader isr = new InputStreamReader(input);
this.reader = new BufferedReader(isr);
this.columnNum = columnNum;
this.radix = radix;
this.glyphLists = glyphLists;
+ if (this.glyphLists == null) {
+ this.glyphLists = new ArrayList<String>();
+ }
}
/**
@@ -329,28 +334,17 @@
* @throws PsException If a glyph name cannot be mapped to a code point.
*/
private void createCodePoints() throws PsException {
- StringTokenizer tokenizer = null;
- int numListsToCheck = 1;
- if (this.glyphLists != null
- && ! this.glyphLists.equals("")) {
- tokenizer = new StringTokenizer(this.glyphLists);
- numListsToCheck += tokenizer.countTokens();
+ this.glyphListsToCheck = new ArrayList<GlyphList4a>(this.glyphLists.size() + 1);
+ for (String glyphListString : this.glyphLists) {
+ final GlyphList4a glyphList = GlyphList4a.getGlyphList(glyphListString);
+ this.glyphListsToCheck.add(glyphList);
}
- this.glyphListsToCheck = new ArrayList<GlyphList4a>(numListsToCheck);
- int index = 0;
- GlyphList4a glyphList = null;
- if (tokenizer != null) {
- while (tokenizer.hasMoreTokens()) {
- glyphList = GlyphList4a.getGlyphList(tokenizer.nextToken());
- this.glyphListsToCheck.add(glyphList);
- index++;
- }
- }
this.glyphListsToCheck.add(GlyphList4a.getGlyphList("AGL"));
+
for (int i = 0; i < this.glyphNames.size(); i++) {
final String glyphName = this.glyphNames.get(i);
for (int j = 0; j < this.glyphListsToCheck.size(); j++) {
- glyphList = this.glyphListsToCheck.get(j);
+ final GlyphList glyphList = this.glyphListsToCheck.get(j);
final char codePoint = glyphList.mapGlyphNameToCodePoint(
glyphName);
if (codePoint != Character.MAX_VALUE) {
@@ -648,9 +642,14 @@
}
// Get the custom glyph lists.
- String customGlyphLists = null;
+ final List<String> customGlyphLists = new ArrayList<String>();
if (args.length > EncodingParser.ARG_GLYPH_LISTS) {
- customGlyphLists = args[EncodingParser.ARG_GLYPH_LISTS];
+ final String customGlyphListsString = args[EncodingParser.ARG_GLYPH_LISTS];
+ final StringTokenizer tokenizer = new StringTokenizer(customGlyphListsString);
+ while (tokenizer.hasMoreTokens()) {
+ final String token = tokenizer.nextToken();
+ customGlyphLists.add(token);
+ }
}
final EncodingParser parser = new EncodingParser(input, columnNum, radix, customGlyphLists);
try {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-05-01 12:41:49
|
Revision: 10843
http://foray.svn.sourceforge.net/foray/?rev=10843&view=rev
Author: victormote
Date: 2009-05-01 12:41:47 +0000 (Fri, 01 May 2009)
Log Message:
-----------
Remove some FOrayFont dependencies on FOrayPS.
Modified Paths:
--------------
trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetParser.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCustom.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingVector4a.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingZapfDingbats.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphList4a.java
Modified: trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java 2009-05-01 00:10:13 UTC (rev 10842)
+++ trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java 2009-05-01 12:41:47 UTC (rev 10843)
@@ -35,6 +35,7 @@
import org.axsl.font.FontException;
import org.axsl.ps.EncodingVector;
+import org.axsl.ps.GlyphList;
import org.axsl.ps.PsException;
import org.apache.commons.logging.Log;
@@ -794,7 +795,7 @@
+ "element \"glyph-list\".");
return;
}
- GlyphList4a glyphList = GlyphList4a.getGlyphList(name);
+ GlyphList glyphList = GlyphList4a.getGlyphList(name);
if (glyphList != null) {
logError("Glyph-list already defined: " + name);
return;
@@ -828,10 +829,14 @@
} catch (final PsException e2) {
logError("Error parsing: " + file);
}
- glyphList = new GlyphList4a(name, parser.getGlyphNames(),
- parser.getCodePointsForGlyphNames(), parser.getCodePoints(),
- parser.getGlyphNameIndex());
- GlyphList4a.registerGlyphList(name, glyphList);
+ try {
+ glyphList = this.fontServer.getPsServer().parseGlyphList(name, input);
+ GlyphList4a.registerGlyphList(name, glyphList);
+ } catch (final IOException e) {
+ logError("Error parsing \"" + file + "\": " + e.getMessage());
+ } catch (final PsException e) {
+ logError("Error parsing \"" + file + "\": " + e.getMessage());
+ }
}
/**
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetParser.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetParser.java 2009-05-01 00:10:13 UTC (rev 10842)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetParser.java 2009-05-01 12:41:47 UTC (rev 10843)
@@ -33,6 +33,7 @@
import org.foray.common.StringUtil;
import org.foray.common.url.URLFactory;
+import org.axsl.ps.GlyphList;
import org.axsl.ps.PsException;
import org.apache.commons.logging.Log;
@@ -151,7 +152,7 @@
private void processCurrentLine(final String line, final int arrayIndex) throws PsException {
this.characterSet.add(Character.MIN_VALUE);
this.glyphNames.add(StringUtil.EMPTY_STRING);
- final GlyphList4a gl = GlyphList4a.getGlyphList("AGL");
+ final GlyphList gl = GlyphList4a.getGlyphList("AGL");
final char theChar = gl.mapGlyphNameToCodePoint(line);
if (theChar == Character.MAX_VALUE) {
throw new PsException("Character not found in Adobe Glyph List, line "
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCustom.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCustom.java 2009-05-01 00:10:13 UTC (rev 10842)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCustom.java 2009-05-01 12:41:47 UTC (rev 10843)
@@ -29,6 +29,7 @@
package org.foray.ps.encode;
import org.axsl.ps.EncodingVector;
+import org.axsl.ps.GlyphList;
import java.util.List;
@@ -56,7 +57,7 @@
* codePoints. codePointIndexes[n] should contain the encoded index that
* corresponds to the Unicode code point at codePoints[n].
*/
- public EncodingCustom(final String name, final List<GlyphList4a> sourceGlyphLists,
+ public EncodingCustom(final String name, final List<GlyphList> sourceGlyphLists,
final char[] codePoints, final char[] codePointIndexes) {
super(name, sourceGlyphLists, codePoints, codePointIndexes);
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java 2009-05-01 00:10:13 UTC (rev 10842)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java 2009-05-01 12:41:47 UTC (rev 10843)
@@ -137,7 +137,7 @@
private List<String> glyphLists;
/** The array of glyph lists that can be used to map names to codepoints. */
- private List<GlyphList4a> glyphListsToCheck = null;
+ private List<GlyphList> glyphListsToCheck = null;
/** The radix which should be used for parsing. For base-10 numbers, this
* value should be 10. For octal numbers, it should be 8. */
@@ -334,9 +334,9 @@
* @throws PsException If a glyph name cannot be mapped to a code point.
*/
private void createCodePoints() throws PsException {
- this.glyphListsToCheck = new ArrayList<GlyphList4a>(this.glyphLists.size() + 1);
+ this.glyphListsToCheck = new ArrayList<GlyphList>(this.glyphLists.size() + 1);
for (String glyphListString : this.glyphLists) {
- final GlyphList4a glyphList = GlyphList4a.getGlyphList(glyphListString);
+ final GlyphList glyphList = GlyphList4a.getGlyphList(glyphListString);
this.glyphListsToCheck.add(glyphList);
}
this.glyphListsToCheck.add(GlyphList4a.getGlyphList("AGL"));
@@ -556,7 +556,7 @@
* Returns the glyph lists to check.
* @return The glyph lists to check.
*/
- public List<GlyphList4a> getGlyphListsToCheck() {
+ public List<GlyphList> getGlyphListsToCheck() {
return this.glyphListsToCheck;
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingVector4a.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingVector4a.java 2009-05-01 00:10:13 UTC (rev 10842)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingVector4a.java 2009-05-01 12:41:47 UTC (rev 10843)
@@ -29,6 +29,7 @@
package org.foray.ps.encode;
import org.axsl.ps.EncodingVector;
+import org.axsl.ps.GlyphList;
import java.io.IOException;
import java.io.ObjectInputStream;
@@ -105,7 +106,7 @@
private transient String name;
/** The GlyphList instances, in order, which were used to create this encoding. */
- private transient List<GlyphList4a> sourceGlyphLists;
+ private transient List<GlyphList> sourceGlyphLists;
/** Array of Unicode code points, sorted. Elements in this array are keys
* to elements in {@link #codePointIndexes}. */
@@ -130,7 +131,7 @@
* codePoints. codePointIndexes[n] should contain the encoded index that
* corresponds to the Unicode code point at codePoints[n].
*/
- public EncodingVector4a(final String name, final List<GlyphList4a> sourceGlyphLists,
+ public EncodingVector4a(final String name, final List<GlyphList> sourceGlyphLists,
final char[] codePoints, final char[] codePointIndexes) {
this.name = name;
this.sourceGlyphLists = sourceGlyphLists;
@@ -504,7 +505,7 @@
}
stream.defaultReadObject();
this.name = (String) stream.readObject();
- this.sourceGlyphLists = (List<GlyphList4a>) stream.readObject();
+ this.sourceGlyphLists = (List<GlyphList>) stream.readObject();
this.codePoints = (char[]) stream.readObject();
this.codePointIndexes = (char[]) stream.readObject();
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingZapfDingbats.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingZapfDingbats.java 2009-05-01 00:10:13 UTC (rev 10842)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingZapfDingbats.java 2009-05-01 12:41:47 UTC (rev 10843)
@@ -29,6 +29,7 @@
package org.foray.ps.encode;
import org.axsl.ps.EncodingVector;
+import org.axsl.ps.GlyphList;
import java.io.ObjectStreamException;
import java.io.Serializable;
@@ -64,7 +65,7 @@
/** The array of glyph lists that should be used to map glyph names to
* Unicode code points for this font. */
- private static final List<GlyphList4a> GLYPH_LISTS_USED = new ArrayList<GlyphList4a>(2);
+ private static final List<GlyphList> GLYPH_LISTS_USED = new ArrayList<GlyphList>(2);
static {
EncodingZapfDingbats.GLYPH_LISTS_USED.add(GlyphList4a.getGlyphList("ZapfDingbats"));
/* We need the Adobe Glyph List to get the "space" char. */
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphList4a.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphList4a.java 2009-05-01 00:10:13 UTC (rev 10842)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphList4a.java 2009-05-01 12:41:47 UTC (rev 10843)
@@ -58,18 +58,17 @@
/** Map of GlyphList instances that have already been registered. The key
* is a String with the GlyphList name, and the value is the GlyphList
* instance. */
- private static Map<String, GlyphList4a> glyphListMap
- = new HashMap<String, GlyphList4a>();
+ private static Map<String, GlyphList> glyphListMap = new HashMap<String, GlyphList>();
/** An array of glyph lists representing those that should be consulted
* as a standard source. */
- private static final List<GlyphList4a> STANDARD_SOURCE_GLYPH_LISTS = new ArrayList<GlyphList4a>();
+ private static final List<GlyphList> STANDARD_SOURCE_GLYPH_LISTS = new ArrayList<GlyphList>();
static {
GlyphList4a.STANDARD_SOURCE_GLYPH_LISTS.add(GlyphList4a.getGlyphList("AGL"));
};
/** An immutable view of {@link #STANDARD_SOURCE_GLYPH_LISTS}. */
- private static final List<GlyphList4a> STANDARD_SOURCE_GLYPH_LISTS_IMMUTABLE
+ private static final List<GlyphList> STANDARD_SOURCE_GLYPH_LISTS_IMMUTABLE
= Collections.unmodifiableList(GlyphList4a.STANDARD_SOURCE_GLYPH_LISTS);
/** A unique, descriptive name for this GlyphList. */
@@ -188,9 +187,9 @@
* @return The named glyph list, if it exists or can be created, or null
* otherwise.
*/
- public static GlyphList4a getGlyphList(final String name) {
+ public static GlyphList getGlyphList(final String name) {
// If already instantiated, return it.
- GlyphList4a list = GlyphList4a.glyphListMap.get(name);
+ GlyphList list = GlyphList4a.glyphListMap.get(name);
if (list != null) {
return list;
}
@@ -232,8 +231,7 @@
* @param name The name of the glyph list to be registered.
* @param glyphList The glyph list to be registered.
*/
- public static void registerGlyphList(final String name,
- final GlyphList4a glyphList) {
+ public static void registerGlyphList(final String name, final GlyphList glyphList) {
GlyphList4a.glyphListMap.put(name, glyphList);
}
@@ -255,12 +253,12 @@
* is none.
* @see GlyphList4a#mapCodePointToGlyphName(int)
*/
- public static String mapCodePointToGlyphName(final List<GlyphList4a> glyphLists, final int codePoint) {
+ public static String mapCodePointToGlyphName(final List<GlyphList> glyphLists, final int codePoint) {
if (glyphLists == null) {
return null;
}
for (int i = 0; i < glyphLists.size(); i++) {
- final GlyphList4a list = glyphLists.get(i);
+ final GlyphList list = glyphLists.get(i);
if (list == null) {
continue;
}
@@ -289,12 +287,12 @@
* {@link Encoding4a#INVALID_UNICODE_CHAR} if there is none.
* @see GlyphList4a#mapGlyphNameToCodePoint(String)
*/
- public static char mapGlyphNameToCodePoint(final List<GlyphList4a> glyphLists, final String glyphName) {
+ public static char mapGlyphNameToCodePoint(final List<GlyphList> glyphLists, final String glyphName) {
if (glyphLists == null) {
return Encoding4a.INVALID_UNICODE_CHAR;
}
for (int i = 0; i < glyphLists.size(); i++) {
- final GlyphList4a list = glyphLists.get(i);
+ final GlyphList list = glyphLists.get(i);
if (list == null) {
continue;
}
@@ -310,7 +308,7 @@
* Returns the standard glyphs lists.
* @return The standard glyph lists.
*/
- public static List<GlyphList4a> standardSourceGlyphLists() {
+ public static List<GlyphList> standardSourceGlyphLists() {
return GlyphList4a.STANDARD_SOURCE_GLYPH_LISTS_IMMUTABLE;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-05-01 15:38:37
|
Revision: 10845
http://foray.svn.sourceforge.net/foray/?rev=10845&view=rev
Author: victormote
Date: 2009-05-01 15:38:27 +0000 (Fri, 01 May 2009)
Log Message:
-----------
Remove a FOrayFont dependency on FOrayPS.
Modified Paths:
--------------
trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetParser.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingZapfDingbats.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphList4a.java
Modified: trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java 2009-05-01 12:45:12 UTC (rev 10844)
+++ trunk/foray/foray-font/src/java/org/foray/font/ConfigParser.java 2009-05-01 15:38:27 UTC (rev 10845)
@@ -30,7 +30,6 @@
import org.foray.common.url.URLFactory;
import org.foray.ps.encode.EncodingVector4a;
-import org.foray.ps.encode.GlyphList4a;
import org.axsl.font.FontException;
import org.axsl.ps.EncodingVector;
@@ -135,6 +134,10 @@
* numbers in user messages. */
private Locator locator;
+ /** Map of GlyphList instances that have already been registered.
+ * The key is a String with the GlyphList name, and the value is the GlyphList instance. */
+ private Map<String, GlyphList> glyphListMap = new HashMap<String, GlyphList>();
+
/*
* Register the URLStreamHandler for classpath: URLs. This has to be done
* only once, hence a static statement.
@@ -794,11 +797,6 @@
+ "element \"glyph-list\".");
return;
}
- GlyphList glyphList = GlyphList4a.getGlyphList(name);
- if (glyphList != null) {
- logError("Glyph-list already defined: " + name);
- return;
- }
final String file = attributes.getValue("file");
if (file == null
|| file.equals("")) {
@@ -821,8 +819,8 @@
return;
}
try {
- glyphList = this.fontServer.getPsServer().parseGlyphList(name, input);
- GlyphList4a.registerGlyphList(name, glyphList);
+ final GlyphList glyphList = this.fontServer.getPsServer().parseGlyphList(name, input);
+ this.glyphListMap.put(name, glyphList);
} catch (final IOException e) {
logError("Error parsing \"" + file + "\": " + e.getMessage());
} catch (final PsException e) {
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetParser.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetParser.java 2009-05-01 12:45:12 UTC (rev 10844)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/CharSetParser.java 2009-05-01 15:38:27 UTC (rev 10845)
@@ -152,7 +152,7 @@
private void processCurrentLine(final String line, final int arrayIndex) throws PsException {
this.characterSet.add(Character.MIN_VALUE);
this.glyphNames.add(StringUtil.EMPTY_STRING);
- final GlyphList gl = GlyphList4a.getGlyphList("AGL");
+ final GlyphList gl = GlyphListAGL.getInstance();
final char theChar = gl.mapGlyphNameToCodePoint(line);
if (theChar == Character.MAX_VALUE) {
throw new PsException("Character not found in Adobe Glyph List, line "
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java 2009-05-01 12:45:12 UTC (rev 10844)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java 2009-05-01 15:38:27 UTC (rev 10845)
@@ -339,7 +339,7 @@
final GlyphList glyphList = GlyphList4a.getGlyphList(glyphListString);
this.glyphListsToCheck.add(glyphList);
}
- this.glyphListsToCheck.add(GlyphList4a.getGlyphList("AGL"));
+ this.glyphListsToCheck.add(GlyphListAGL.getInstance());
for (int i = 0; i < this.glyphNames.size(); i++) {
final String glyphName = this.glyphNames.get(i);
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingZapfDingbats.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingZapfDingbats.java 2009-05-01 12:45:12 UTC (rev 10844)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingZapfDingbats.java 2009-05-01 15:38:27 UTC (rev 10845)
@@ -67,9 +67,9 @@
* Unicode code points for this font. */
private static final List<GlyphList> GLYPH_LISTS_USED = new ArrayList<GlyphList>(2);
static {
- EncodingZapfDingbats.GLYPH_LISTS_USED.add(GlyphList4a.getGlyphList("ZapfDingbats"));
+ EncodingZapfDingbats.GLYPH_LISTS_USED.add(GlyphListZapfDingbats.getInstance());
/* We need the Adobe Glyph List to get the "space" char. */
- EncodingZapfDingbats.GLYPH_LISTS_USED.add(GlyphList4a.getGlyphList("AGL"));
+ EncodingZapfDingbats.GLYPH_LISTS_USED.add(GlyphListAGL.getInstance());
};
/*
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphList4a.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphList4a.java 2009-05-01 12:45:12 UTC (rev 10844)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/GlyphList4a.java 2009-05-01 15:38:27 UTC (rev 10845)
@@ -37,9 +37,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
/**
* Class handling glyph-to-Unicode mappings. Instances of this class manage a
@@ -55,16 +53,11 @@
/** Constant needed for serialization. */
public static final long serialVersionUID = -271250133295639106L;
- /** Map of GlyphList instances that have already been registered. The key
- * is a String with the GlyphList name, and the value is the GlyphList
- * instance. */
- private static Map<String, GlyphList> glyphListMap = new HashMap<String, GlyphList>();
-
/** An array of glyph lists representing those that should be consulted
* as a standard source. */
private static final List<GlyphList> STANDARD_SOURCE_GLYPH_LISTS = new ArrayList<GlyphList>();
static {
- GlyphList4a.STANDARD_SOURCE_GLYPH_LISTS.add(GlyphList4a.getGlyphList("AGL"));
+ GlyphList4a.STANDARD_SOURCE_GLYPH_LISTS.add(GlyphListAGL.getInstance());
};
/** An immutable view of {@link #STANDARD_SOURCE_GLYPH_LISTS}. */
@@ -188,22 +181,13 @@
* otherwise.
*/
public static GlyphList getGlyphList(final String name) {
- // If already instantiated, return it.
- GlyphList list = GlyphList4a.glyphListMap.get(name);
- if (list != null) {
- return list;
+ if ("AGL".equals(name)) {
+ return GlyphListAGL.getInstance();
}
- // Otherwise, try to instantiate it.
- if (name.equals("AGL")) {
- list = GlyphListAGL.getInstance();
- } else if (name.equals("ZapfDingbats")) {
- list = new GlyphListZapfDingbats();
+ if (name.equals("ZapfDingbats")) {
+ return GlyphListZapfDingbats.getInstance();
}
- if (list == null) {
- return null;
- }
- GlyphList4a.glyphListMap.put(name, list);
- return list;
+ return null;
}
/**
@@ -226,16 +210,6 @@
}
/**
- * Registers a new glyph list. Each glyph list is managed as a singleton
- * since there is no need for more than one copy.
- * @param name The name of the glyph list to be registered.
- * @param glyphList The glyph list to be registered.
- */
- public static void registerGlyphList(final String name, final GlyphList glyphList) {
- GlyphList4a.glyphListMap.put(name, glyphList);
- }
-
- /**
* Returns the name of this glyph list.
* @return The name of this glyph list.
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-05-01 21:54:39
|
Revision: 10857
http://foray.svn.sourceforge.net/foray/?rev=10857&view=rev
Author: victormote
Date: 2009-05-01 21:54:37 +0000 (Fri, 01 May 2009)
Log Message:
-----------
Move EncodingVector4a from FOrayPs to FOrayCommon, so that it can be used by other packages.
Modified Paths:
--------------
trunk/foray/foray-ps/src/java/org/foray/ps/PsServer4a.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCE.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCustom.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpert.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpertSubset.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingFOrayLatinExtra.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingISOLatin1.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacExpert.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacRoman.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacStandard.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingPDFDoc.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingStandard.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingSymbol.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingWinAnsi.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingZapfDingbats.java
Added Paths:
-----------
trunk/foray/foray-common/src/java/org/foray/common/ps/EncodingVector4a.java
Removed Paths:
-------------
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingVector4a.java
Copied: trunk/foray/foray-common/src/java/org/foray/common/ps/EncodingVector4a.java (from rev 10856, trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingVector4a.java)
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/ps/EncodingVector4a.java (rev 0)
+++ trunk/foray/foray-common/src/java/org/foray/common/ps/EncodingVector4a.java 2009-05-01 21:54:37 UTC (rev 10857)
@@ -0,0 +1,473 @@
+/*
+ * Copyright 2004 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.ps;
+
+import org.axsl.ps.Encoding;
+import org.axsl.ps.EncodingVector;
+import org.axsl.ps.GlyphList;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * <p>Encoding instances provide some standard encoding resources for
+ * PostScript.
+ * When a PostScript file is parsed, the characters in a string are really
+ * indices into an array of glyph names, which are in turn the keys to entries
+ * in a glyph dictionary.
+ * Input to a PostScript interpreter is not really characters, but rather
+ * character indexes.
+ * (The two might be the same, especially for ASCII characters).</p>
+ *
+ * <p>So the PostScript interpreter uses a two-step process, as follows:
+ * 1. It conceptually maps character codes (integer values) to name objects
+ * like /A or /Uacute. This map is known as an "encoding".
+ * There are several standard encoding schemes defined in the PostScript
+ * standard that each interpreter must know how to handle. Those are provided
+ * as Encoding subclasses.
+ * 2. The name objects created in step 1 are then used as the key into a
+ * dictionary (contained in the Font dictionary) whose values contain the
+ * PostScript instructions needed to actually paint the glyph.</p>
+ *
+ * <p>Nowhere in the above scheme is Unicode encoding contemplated or supported.
+ * Applications that <em>create </em> PostScript output from Unicode input need
+ * a way to convert from that Unicode input to the indexes that are expected
+ * for by the selected encoding.
+ * The closest resource that we have for this purpose is the standard glyph
+ * lists supplied by Adobe.</p>
+ *
+ * <p>The canonical method for mapping a Unicode code point to a PostScript
+ * encoding index would be:</p>
+ * <ol>
+ * <li>Use the Adobe Glyph List (or another glyph list) to obtain the glyph name for a given Unicode
+ * code point.</li>
+ * <li>Use an Encoding instance to obtain the index in that Encoding for the
+ * glyph name obtained above.</li>
+ * </ol>
+ *
+ * <p>However, for efficiency, an Encoding combines the above two steps and
+ * provides a direct mapping from a Unicode code point to the encoded index.
+ * Two parallel arrays are used to make this process efficient.
+ * The first is a an array of all Unicode code points supported in the Encoding.
+ * This array is sorted for fast searching.
+ * The second array provides the encoded index for the Unicode code point in
+ * the first array.
+ * Methods are provided to encode and decode characters.</p>
+ */
+public abstract class EncodingVector4a implements EncodingVector, Serializable {
+
+ /** The name of the undefined glyph. */
+ public static final String NOTDEF = ".notdef";
+
+ /** Constant needed for serialization. */
+ private static final long serialVersionUID = 6967489975814026068L;
+
+ /** The name of this encoding. */
+ private transient String name;
+
+ /** The GlyphList instances, in order, which were used to create this encoding. */
+ private transient List<GlyphList> sourceGlyphLists;
+
+ /** Array of Unicode code points, sorted. Elements in this array are keys
+ * to elements in {@link #codePointIndexes}. */
+ private transient char[] codePoints;
+
+ /** Array of encoded indexes for the glyphs that correspond to elements
+ * in {@link #codePoints}. */
+ private transient char[] codePointIndexes;
+
+ /**
+ * Create a new Encoding instance.
+ * @param name The name of this encoding.
+ * This name is not used by the system, but may be useful for debugging.
+ * @param sourceGlyphLists The GlyphList instances that were used to create this encoding.
+ * @param codePoints The array of Unicode code points supported by this encoding.
+ * @param codePointIndexes The array of encoded indexes that is parallel to codePoints.
+ * codePointIndexes[n] should contain the encoded index that corresponds to the Unicode code point at codePoints[n].
+ */
+ public EncodingVector4a(final String name, final List<GlyphList> sourceGlyphLists,
+ final char[] codePoints, final char[] codePointIndexes) {
+ this.name = name;
+ this.sourceGlyphLists = sourceGlyphLists;
+ this.codePoints = codePoints;
+ this.codePointIndexes = codePointIndexes;
+ sortCodePoints(codePoints, codePointIndexes);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int encodeCharacter(final int codePoint) {
+ if (this.codePoints == null
+ || this.codePointIndexes == null) {
+ return 0;
+ }
+ final int index = Arrays.binarySearch(this.codePoints,
+ (char) codePoint);
+ if (index < 0) {
+ return 0;
+ }
+ return this.codePointIndexes[index];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int decodeCharacter(final int encodedIndex) {
+ /* This is not expected to be used much or at all, so the
+ * codePointIndexes array has not been copied and sorted and
+ * referenced.*/
+ if (this.codePoints == null
+ || this.codePointIndexes == null) {
+ return INVALID_UNICODE_CHAR;
+ }
+ for (int i = 0; i < this.codePointIndexes.length; i++) {
+ if (this.codePointIndexes[i] == encodedIndex) {
+ return this.codePoints[i];
+ }
+ }
+ return INVALID_UNICODE_CHAR;
+ }
+
+ /**
+ * Returns the number of entries in this encoding.
+ * @return The number of entries in this encoding.
+ */
+ public int size() {
+ return this.codePoints.length;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String[] getGlyphNames() {
+ final int listSize = getLastIndex() + 1;
+ final String[] glyphList = new String[listSize];
+ // Initialize all items to ".notdef".
+ for (int i = 0; i < glyphList.length; i++) {
+ glyphList[i] = EncodingVector4a.NOTDEF;
+ }
+ for (int i = 0; i < this.codePoints.length; i++) {
+ final char codePoint = this.codePoints[i];
+ final String glyphName = mapCodePointToGlyphName(this.sourceGlyphLists, codePoint);
+ final int encodingIndex = this.codePointIndexes[i];
+ glyphList[encodingIndex] = glyphName;
+ }
+ return glyphList;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getFirstIndex() {
+ char firstIndex = Character.MAX_VALUE;
+ for (int i = 0; i < this.codePointIndexes.length; i++) {
+ if (this.codePointIndexes[i] < firstIndex) {
+ firstIndex = this.codePointIndexes[i];
+ }
+ }
+ return firstIndex;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getLastIndex() {
+ char lastIndex = Character.MIN_VALUE;
+ for (int i = 0; i < this.codePointIndexes.length; i++) {
+ if (this.codePointIndexes[i] > lastIndex) {
+ lastIndex = this.codePointIndexes[i];
+ }
+ }
+ return lastIndex;
+ }
+
+ /**
+ * Sorts the codePoints array by its contents, and sorts the parallel
+ * codePointIndexes arrays in a parallel manner, keeping its elements
+ * synchronized with those in codePoints.
+ * @param codePoints The array of Unicode code points to be sorted.
+ * @param codePointIndexes The array of encoding indexes that whose elements
+ * correspond to elements in codePoints.
+ */
+ public void sortCodePoints(final char[] codePoints,
+ final char[] codePointIndexes) {
+ boolean anyChanges = true;
+ while (anyChanges) {
+ anyChanges = false;
+ for (int i = 0; i < codePoints.length - 1; i++) {
+ if (codePoints[i] > codePoints[i + 1]) {
+ /* They are out of order. Switch corresponding elements
+ * in both arrays.*/
+ char saveChar = codePoints[i];
+ codePoints[i] = codePoints[i + 1];
+ codePoints[i + 1] = saveChar;
+ saveChar = codePointIndexes[i];
+ codePointIndexes[i] = codePointIndexes[i + 1];
+ codePointIndexes[i + 1] = saveChar;
+ anyChanges = true;
+ }
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String asPostScript(final org.axsl.ps.Encoding baseEncoding) {
+ /* TODO: The baseEncoding is ignored for now. We need to consider it. */
+ final int maxCharsPerLine = 80;
+ final String indent = " ";
+ final String[] glyphNames = this.getGlyphNames();
+ if (glyphNames == null) {
+ return null;
+ }
+ final StringBuilder buffer = new StringBuilder();
+ buffer.append("/Differences\n");
+ buffer.append("[ 0 \n");
+ buffer.append(indent);
+ int lineLength = indent.length();
+ for (int i = 0; i < glyphNames.length; i++) {
+ final String glyphName = glyphNames[i];
+ /* If line length will exceed maxCharsPerLine, add linefeed. */
+ final int sizeToAdd = glyphName.length() + 2;
+ if (lineLength + sizeToAdd > maxCharsPerLine) {
+ buffer.append("\n");
+ buffer.append(indent);
+ lineLength = indent.length();
+ } else {
+ if (lineLength > indent.length()) {
+ buffer.append(" ");
+ lineLength += 1;
+ }
+ }
+ buffer.append("/");
+ buffer.append(glyphName);
+ lineLength += glyphName.length() + 1;
+ }
+ /* Add line-feed for the last line. */
+ buffer.append("\n");
+ buffer.append("]\n");
+ return buffer.toString();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String mapCodePointToGlyphName(final int codePoint) {
+ if (this.sourceGlyphLists == null) {
+ return null;
+ }
+ if (encodeCharacter(codePoint) == 0) {
+ // codePoint is not in this encoding.
+ return null;
+ }
+ return mapCodePointToGlyphName(this.sourceGlyphLists, codePoint);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public org.axsl.ps.EncodingVector bestBaseEncodingPdf() {
+ /* Predefined encodings do not need to be written at all. */
+ if (this.isPredefinedPdf()) {
+ return null;
+ }
+ /* TODO: Write a standard implementation of this that compares this
+ * encoding to the predefined PDF encodings and returns one of them if
+ * that is appropriate. */
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isSubsetOf(final EncodingVector otherVector) {
+ for (int i = 0; i < this.codePoints.length; i++) {
+ final int thisEncodedValue = this.encodeCharacter(
+ this.codePoints[i]);
+ final int otherEncodedValue = otherVector.encodeCharacter(
+ this.codePoints[i]);
+ if (thisEncodedValue != otherEncodedValue) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Indicates whether the data in this encoding vector is static, that is,
+ * tied entirely to the class itself and not built dynamically.
+ * This is used primarily to determine whether the instance should actually
+ * be serialized.
+ * @return True iff all data in this encoding vector is static and does not
+ * need to be serialized.
+ */
+ public abstract boolean isStatic();
+
+ /**
+ * Serialize this {@link EncodingVector4a} instance.
+ * @param stream The output stream to which the serialized data is written.
+ * @throws IOException For I/O errors.
+ * @serialData
+ * <ol>
+ * <li>The name of the encoding (String).</li>
+ * <li>The source {@link GlyphList4a} instances used to build this encoding
+ * (GlyphList[]), in order.</li>
+ * <li>The code points (char[]).</li>
+ * <li>The code point indexes (char[]).</li>
+ * </ol>
+ */
+ private void writeObject(final ObjectOutputStream stream)
+ throws IOException {
+ if (this.isStatic()) {
+ /* The static instances do not need to be serialized as they are
+ * derived entirely from static data. */
+ return;
+ }
+ stream.defaultWriteObject();
+ stream.writeObject(this.name);
+ stream.writeObject(this.sourceGlyphLists);
+ stream.writeObject(this.codePoints);
+ stream.writeObject(this.codePointIndexes);
+ }
+
+ /**
+ * Deserialize this {@link EncodingVector4a} instance.
+ * @param stream The input stream from which the serialized data is read.
+ * @throws IOException For I/O errors reading the input.
+ * @throws ClassNotFoundException For classes in the input that cannot be
+ * found.
+ */
+ @SuppressWarnings("unchecked")
+ private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException {
+ if (this.isStatic()) {
+ /* The static instances do not need to be serialized as they are
+ * derived entirely from static data. */
+ return;
+ }
+ stream.defaultReadObject();
+ this.name = (String) stream.readObject();
+ this.sourceGlyphLists = (List<GlyphList>) stream.readObject();
+ this.codePoints = (char[]) stream.readObject();
+ this.codePointIndexes = (char[]) stream.readObject();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isPredefinedPs() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isPredefinedPdf() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canEncode(final int codePoint) {
+ return this.encodeCharacter(codePoint) != 0;
+ }
+
+ /**
+ * Finds the glyph name for a given Unicode code point by searching
+ * an array of GlyphList instances for it.
+ * @param glyphLists An array of GlyphList instances which should be
+ * tried.
+ * @param codePoint The Unicode code point for which a glyph name is sought.
+ * @return The glyph name which corresponds to codePoint, or null if there
+ * is none.
+ */
+ public String mapCodePointToGlyphName(final List<GlyphList> glyphLists, final int codePoint) {
+ if (glyphLists == null) {
+ return null;
+ }
+ for (int i = 0; i < glyphLists.size(); i++) {
+ final GlyphList list = glyphLists.get(i);
+ if (list == null) {
+ continue;
+ }
+ final String glyphName = list.mapCodePointToGlyphName(codePoint);
+ if (glyphName == null) {
+ continue;
+ }
+ /* Make sure it maps back. Otherwise it must have come from a
+ * different list. */
+ final char roundTripCodePoint = mapGlyphNameToCodePoint(glyphLists,
+ glyphName);
+ if (roundTripCodePoint == codePoint) {
+ return glyphName;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Finds the Unicode code for a glyphName by searching an array of
+ * GlyphList instances for it.
+ * @param glyphLists An array of GlyphList instances which should be
+ * tried.
+ * @param glyphName The glyph name for which a Unicode code point is sought.
+ * @return The Unicode code point which corresponds to glyphName, or
+ * {@link Encoding#INVALID_UNICODE_CHAR} if there is none.
+ */
+ public char mapGlyphNameToCodePoint(final List<GlyphList> glyphLists, final String glyphName) {
+ if (glyphLists == null) {
+ return Encoding.INVALID_UNICODE_CHAR;
+ }
+ for (int i = 0; i < glyphLists.size(); i++) {
+ final GlyphList list = glyphLists.get(i);
+ if (list == null) {
+ continue;
+ }
+ final char c = list.mapGlyphNameToCodePoint(glyphName);
+ if (c != Encoding.INVALID_UNICODE_CHAR) {
+ return c;
+ }
+ }
+ return Encoding.INVALID_UNICODE_CHAR;
+ }
+
+}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/PsServer4a.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/PsServer4a.java 2009-05-01 21:51:12 UTC (rev 10856)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/PsServer4a.java 2009-05-01 21:54:37 UTC (rev 10857)
@@ -28,6 +28,7 @@
package org.foray.ps;
+import org.foray.common.ps.EncodingVector4a;
import org.foray.ps.encode.CMap04;
import org.foray.ps.encode.CMap12;
import org.foray.ps.encode.CharSet4a;
@@ -45,7 +46,6 @@
import org.foray.ps.encode.EncodingParser;
import org.foray.ps.encode.EncodingStandard;
import org.foray.ps.encode.EncodingSymbol;
-import org.foray.ps.encode.EncodingVector4a;
import org.foray.ps.encode.EncodingWinAnsi;
import org.foray.ps.encode.EncodingZapfDingbats;
import org.foray.ps.encode.GlyphList4a;
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCE.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCE.java 2009-05-01 21:51:12 UTC (rev 10856)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCE.java 2009-05-01 21:54:37 UTC (rev 10857)
@@ -28,6 +28,8 @@
package org.foray.ps.encode;
+import org.foray.common.ps.EncodingVector4a;
+
import org.axsl.ps.EncodingVector;
import java.io.Serializable;
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCustom.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCustom.java 2009-05-01 21:51:12 UTC (rev 10856)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCustom.java 2009-05-01 21:54:37 UTC (rev 10857)
@@ -28,6 +28,8 @@
package org.foray.ps.encode;
+import org.foray.common.ps.EncodingVector4a;
+
import org.axsl.ps.EncodingVector;
import org.axsl.ps.GlyphList;
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpert.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpert.java 2009-05-01 21:51:12 UTC (rev 10856)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpert.java 2009-05-01 21:54:37 UTC (rev 10857)
@@ -28,6 +28,8 @@
package org.foray.ps.encode;
+import org.foray.common.ps.EncodingVector4a;
+
import org.axsl.ps.EncodingVector;
import java.io.Serializable;
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpertSubset.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpertSubset.java 2009-05-01 21:51:12 UTC (rev 10856)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpertSubset.java 2009-05-01 21:54:37 UTC (rev 10857)
@@ -28,6 +28,8 @@
package org.foray.ps.encode;
+import org.foray.common.ps.EncodingVector4a;
+
import org.axsl.ps.EncodingVector;
import java.io.Serializable;
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingFOrayLatinExtra.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingFOrayLatinExtra.java 2009-05-01 21:51:12 UTC (rev 10856)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingFOrayLatinExtra.java 2009-05-01 21:54:37 UTC (rev 10857)
@@ -28,6 +28,8 @@
package org.foray.ps.encode;
+import org.foray.common.ps.EncodingVector4a;
+
import org.axsl.ps.EncodingVector;
import java.io.Serializable;
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingISOLatin1.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingISOLatin1.java 2009-05-01 21:51:12 UTC (rev 10856)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingISOLatin1.java 2009-05-01 21:54:37 UTC (rev 10857)
@@ -28,6 +28,8 @@
package org.foray.ps.encode;
+import org.foray.common.ps.EncodingVector4a;
+
import org.axsl.ps.EncodingVector;
import java.io.Serializable;
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacExpert.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacExpert.java 2009-05-01 21:51:12 UTC (rev 10856)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacExpert.java 2009-05-01 21:54:37 UTC (rev 10857)
@@ -28,6 +28,8 @@
package org.foray.ps.encode;
+import org.foray.common.ps.EncodingVector4a;
+
import org.axsl.ps.EncodingVector;
import java.io.Serializable;
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacRoman.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacRoman.java 2009-05-01 21:51:12 UTC (rev 10856)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacRoman.java 2009-05-01 21:54:37 UTC (rev 10857)
@@ -28,6 +28,8 @@
package org.foray.ps.encode;
+import org.foray.common.ps.EncodingVector4a;
+
import org.axsl.ps.EncodingVector;
import java.io.Serializable;
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacStandard.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacStandard.java 2009-05-01 21:51:12 UTC (rev 10856)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacStandard.java 2009-05-01 21:54:37 UTC (rev 10857)
@@ -28,6 +28,8 @@
package org.foray.ps.encode;
+import org.foray.common.ps.EncodingVector4a;
+
import org.axsl.ps.EncodingVector;
import java.io.ObjectStreamException;
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingPDFDoc.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingPDFDoc.java 2009-05-01 21:51:12 UTC (rev 10856)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingPDFDoc.java 2009-05-01 21:54:37 UTC (rev 10857)
@@ -28,6 +28,8 @@
package org.foray.ps.encode;
+import org.foray.common.ps.EncodingVector4a;
+
import org.axsl.ps.EncodingVector;
import java.io.Serializable;
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java 2009-05-01 21:51:12 UTC (rev 10856)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java 2009-05-01 21:54:37 UTC (rev 10857)
@@ -32,6 +32,7 @@
import org.foray.common.Logging;
import org.foray.common.StringUtil;
import org.foray.common.WKConstants;
+import org.foray.common.ps.EncodingVector4a;
import org.foray.common.url.URLFactory;
import org.axsl.ps.GlyphList;
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingStandard.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingStandard.java 2009-05-01 21:51:12 UTC (rev 10856)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingStandard.java 2009-05-01 21:54:37 UTC (rev 10857)
@@ -28,6 +28,8 @@
package org.foray.ps.encode;
+import org.foray.common.ps.EncodingVector4a;
+
import org.axsl.ps.EncodingVector;
import java.io.Serializable;
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingSymbol.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingSymbol.java 2009-05-01 21:51:12 UTC (rev 10856)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingSymbol.java 2009-05-01 21:54:37 UTC (rev 10857)
@@ -28,6 +28,8 @@
package org.foray.ps.encode;
+import org.foray.common.ps.EncodingVector4a;
+
import org.axsl.ps.EncodingVector;
import java.io.Serializable;
Deleted: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingVector4a.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingVector4a.java 2009-05-01 21:51:12 UTC (rev 10856)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingVector4a.java 2009-05-01 21:54:37 UTC (rev 10857)
@@ -1,477 +0,0 @@
-/*
- * Copyright 2004 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.ps.encode;
-
-import org.axsl.ps.Encoding;
-import org.axsl.ps.EncodingVector;
-import org.axsl.ps.GlyphList;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * <p>Encoding instances provide some standard encoding resources for
- * PostScript.
- * When a PostScript file is parsed, the characters in a string are really
- * indices into an array of glyph names, which are in turn the keys to entries
- * in a glyph dictionary.
- * Input to a PostScript interpreter is not really characters, but rather
- * character indexes.
- * (The two might be the same, especially for ASCII characters).</p>
- *
- * <p>So the PostScript interpreter uses a two-step process, as follows:
- * 1. It conceptually maps character codes (integer values) to name objects
- * like /A or /Uacute. This map is known as an "encoding".
- * There are several standard encoding schemes defined in the PostScript
- * standard that each interpreter must know how to handle. Those are provided
- * as Encoding subclasses.
- * 2. The name objects created in step 1 are then used as the...
[truncated message content] |
|
From: <vic...@us...> - 2009-06-08 18:52:51
|
Revision: 10861
http://foray.svn.sourceforge.net/foray/?rev=10861&view=rev
Author: victormote
Date: 2009-06-08 18:51:13 +0000 (Mon, 08 Jun 2009)
Log Message:
-----------
Move some common-ish things to Common.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/XMLUtil.java
trunk/foray/foray-common/src/javatest/org/foray/common/TestFOrayCommon.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/GraphicServer4a.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/MathFactory.java
trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestGraphicServer4a.java
Added Paths:
-----------
trunk/foray/foray-common/src/javatest/org/foray/common/TestXMLUtil.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/XMLUtil.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/XMLUtil.java 2009-06-08 16:21:54 UTC (rev 10860)
+++ trunk/foray/foray-common/src/java/org/foray/common/XMLUtil.java 2009-06-08 18:51:13 UTC (rev 10861)
@@ -28,6 +28,17 @@
package org.foray.common;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSException;
+import org.w3c.dom.ls.LSParser;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+
/**
* Utility class containing methods useful in parsing or building XML.
*/
@@ -38,9 +49,11 @@
* in XML documents.
* @see "http://www.w3.org/2000/xmlns/"
*/
- public static final String XMLNS_NAMESPACE_URI =
- "http://www.w3.org/2000/xmlns/";
+ public static final String XMLNS_NAMESPACE_URI = "http://www.w3.org/2000/xmlns/";
+ /** The registry of DOM Implementations available. */
+ private static DOMImplementationRegistry domImplementationRegistry;
+
/**
* This class should never be instantiated.
*/
@@ -116,4 +129,68 @@
return changes + spacesToRemove;
}
+ /**
+ * Returns the DOM Implementation registry.
+ * @return The DOM Implementation registry.
+ * @throws IOException For errors obtaining an instance of the registry.
+ */
+ public static DOMImplementationRegistry getDOMRegistry() throws IOException {
+ if (XMLUtil.domImplementationRegistry == null) {
+ try {
+ XMLUtil.domImplementationRegistry = DOMImplementationRegistry.newInstance();
+ } catch (final ClassCastException e) {
+ throw new IOException(e.getMessage());
+ } catch (final ClassNotFoundException e) {
+ throw new IOException(e.getMessage());
+ } catch (final InstantiationException e) {
+ throw new IOException(e.getMessage());
+ } catch (final IllegalAccessException e) {
+ throw new IOException(e.getMessage());
+ }
+ }
+ return XMLUtil.domImplementationRegistry;
+ }
+
+ /**
+ * Returns the DOM Implementation.
+ * @return The DOM Implementation.
+ * @throws IOException For errors obtaining an instance of the DOM Implementation registry.
+ */
+ public static DOMImplementationLS getDOMImplementation() throws IOException {
+ final DOMImplementationRegistry registry = XMLUtil.getDOMRegistry();
+
+ final DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
+ return impl;
+ }
+
+ /**
+ * Converts a URL to a generic DOM Document.
+ * @param url The URL to be parsed to a DOM document.
+ * @return The DOM document.
+ * @throws IOException For errors parsing the document.
+ */
+ public static Document urlToDom(final URL url) throws IOException {
+ final DOMImplementationLS impl = XMLUtil.getDOMImplementation();
+
+ final LSParser builder = impl.createLSParser(
+ DOMImplementationLS.MODE_SYNCHRONOUS, null);
+
+ String uriString = null;
+ try {
+ uriString = url.toURI().toString();
+ } catch (final URISyntaxException e) {
+ throw new IOException(e.getMessage());
+ }
+
+ Document document = null;
+ try {
+ document = builder.parseURI(uriString);
+ } catch (final DOMException e) {
+ throw new IOException(e.getMessage());
+ } catch (final LSException e) {
+ throw new IOException(e.getMessage());
+ }
+ return document;
+ }
+
}
Modified: trunk/foray/foray-common/src/javatest/org/foray/common/TestFOrayCommon.java
===================================================================
--- trunk/foray/foray-common/src/javatest/org/foray/common/TestFOrayCommon.java 2009-06-08 16:21:54 UTC (rev 10860)
+++ trunk/foray/foray-common/src/javatest/org/foray/common/TestFOrayCommon.java 2009-06-08 18:51:13 UTC (rev 10861)
@@ -47,7 +47,8 @@
TestCharVector.class,
TestStringUtil.class,
TestTernaryTreeMap.class,
- TestUnicodeChar.class
+ TestUnicodeChar.class,
+ TestXMLUtil.class
})
public class TestFOrayCommon extends TestCase {
Added: trunk/foray/foray-common/src/javatest/org/foray/common/TestXMLUtil.java
===================================================================
--- trunk/foray/foray-common/src/javatest/org/foray/common/TestXMLUtil.java (rev 0)
+++ trunk/foray/foray-common/src/javatest/org/foray/common/TestXMLUtil.java 2009-06-08 18:51:13 UTC (rev 10861)
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2008 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.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+/**
+ * JUnit test class for the class {@link Bit}.
+ */
+public class TestXMLUtil extends TestCase {
+
+ /**
+ * Test the method {@link XMLUtil#urlToDom(java.net.URL)} by parsing
+ * a file and testing the results.
+ * @throws IOException For errors getting the local sandbox.
+ */
+ public void testUrlToDom() throws IOException {
+ final File sandbox = TestFOrayCommon.getSandbox();
+ final File graphicsDir = new File(sandbox, "resource/fo-examples/graphics");
+ final File testFile = new File(graphicsDir, "mathml-example-1.xml");
+ final URL url = testFile.toURL();
+ final Document document = XMLUtil.urlToDom(url);
+ assertNotNull(document);
+
+ /* The document itself has two children, the document type, and the
+ * root element. */
+ NodeList nodeList = document.getChildNodes();
+ assertEquals(2, nodeList.getLength());
+ /* The first node is the document type node. */
+ assertEquals(Node.DOCUMENT_TYPE_NODE, nodeList.item(0).getNodeType());
+
+ /* The second node is the root element. */
+ Node node = nodeList.item(1);
+ assertEquals(Node.ELEMENT_NODE, node.getNodeType());
+ assertEquals("math", node.getLocalName());
+
+ /* The root node has one child, an "mrow" element. */
+ nodeList = node.getChildNodes();
+ assertEquals(3, nodeList.getLength());
+ /* The first child is ignorable whitespace. */
+ assertEquals(Node.TEXT_NODE, nodeList.item(0).getNodeType());
+ /* The second child is the actual element. */
+ assertEquals(Node.ELEMENT_NODE, nodeList.item(1).getNodeType());
+ /* The third child is ignorable whitespace. */
+ assertEquals(Node.TEXT_NODE, nodeList.item(2).getNodeType());
+ node = nodeList.item(1);
+ assertEquals("mrow", node.getLocalName());
+
+ /* It is certainly possible to test this DOM document more extensively,
+ * but this is enough to show that it was parsed. */
+ }
+
+}
Property changes on: trunk/foray/foray-common/src/javatest/org/foray/common/TestXMLUtil.java
___________________________________________________________________
Added: svn:keywords
+ "Author Id Rev Date URL"
Added: svn:eol-style
+ native
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/GraphicServer4a.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/GraphicServer4a.java 2009-06-08 16:21:54 UTC (rev 10860)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/GraphicServer4a.java 2009-06-08 18:51:13 UTC (rev 10861)
@@ -67,14 +67,9 @@
import org.apache.batik.transcoder.svg2svg.SVGTranscoder;
import org.apache.commons.logging.Log;
-import org.w3c.dom.DOMException;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.bootstrap.DOMImplementationRegistry;
-import org.w3c.dom.ls.DOMImplementationLS;
-import org.w3c.dom.ls.LSException;
-import org.w3c.dom.ls.LSParser;
import org.w3c.dom.mathml.MathMLDocument;
import org.w3c.dom.svg.SVGDocument;
@@ -85,7 +80,6 @@
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
-import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
@@ -359,50 +353,6 @@
}
/**
- * Converts a URL to a generic DOM Document.
- * @param url The URL to be parsed to a DOM document.
- * @return The DOM document.
- * @throws IOException For errors parsing the document.
- */
- public Document urlToDom(final URL url) throws IOException {
- DOMImplementationRegistry registry = null;
- try {
- registry = DOMImplementationRegistry.newInstance();
- } catch (final ClassCastException e) {
- throw new IOException(e.getMessage());
- } catch (final ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- } catch (final InstantiationException e) {
- throw new IOException(e.getMessage());
- } catch (final IllegalAccessException e) {
- throw new IOException(e.getMessage());
- }
-
- final DOMImplementationLS impl =
- (DOMImplementationLS) registry.getDOMImplementation("LS");
-
- final LSParser builder = impl.createLSParser(
- DOMImplementationLS.MODE_SYNCHRONOUS, null);
-
- String uriString = null;
- try {
- uriString = url.toURI().toString();
- } catch (final URISyntaxException e) {
- throw new IOException(e.getMessage());
- }
-
- Document document = null;
- try {
- document = builder.parseURI(uriString);
- } catch (final DOMException e) {
- throw new IOException(e.getMessage());
- } catch (final LSException e) {
- throw new IOException(e.getMessage());
- }
- return document;
- }
-
- /**
* Registers a {@link GraphicOutputFactory} for use by this server.
* This method can be used both to support custom {@link GraphicOutput}
* types and to override standard types.
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/MathFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/MathFactory.java 2009-06-08 16:21:54 UTC (rev 10860)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/MathFactory.java 2009-06-08 18:51:13 UTC (rev 10861)
@@ -28,6 +28,7 @@
package org.foray.graphic.factory;
+import org.foray.common.XMLUtil;
import org.foray.graphic.GraphicServer4a;
import org.foray.graphic.SVGGraphic;
@@ -74,7 +75,7 @@
}
/* Convert the URL to a generic DOM document instance. */
- final Document dom = this.getServer().urlToDom(url);
+ final Document dom = XMLUtil.urlToDom(url);
/* Convert the generic DOM to an SVGDocument (DOM/SVG Document), using
* JEuclid. */
Modified: trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestGraphicServer4a.java
===================================================================
--- trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestGraphicServer4a.java 2009-06-08 16:21:54 UTC (rev 10860)
+++ trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestGraphicServer4a.java 2009-06-08 18:51:13 UTC (rev 10861)
@@ -35,13 +35,8 @@
import org.apache.commons.logging.Log;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
import java.io.File;
import java.io.IOException;
-import java.net.URL;
import junit.framework.TestCase;
@@ -74,8 +69,7 @@
*/
public static File getTestGraphicsDir() throws IOException {
final File sandbox = TestFOrayCommon.getSandbox();
- final File graphicsDir = new File(sandbox,
- "resource/fo-examples/graphics");
+ final File graphicsDir = new File(sandbox, "resource/fo-examples/graphics");
return graphicsDir;
}
@@ -93,45 +87,10 @@
}
/**
- * Test the method {@link GraphicServer4a#urlToDom(java.net.URL)} by parsing
- * a file and testing the results.
- * @throws IOException For errors getting the local sandbox.
- * @throws GraphicException For error obtaining a server instance.
+ * Stub test to ensure at least one "test" in this class.
+ * TODO: Remove this method when we get some real tests in this class.
*/
- public void testUrlToDom() throws IOException, GraphicException {
- final File testFile = TestGraphicServer4a.getTestGraphicsFile(
- "mathml-example-1.xml");
- final URL url = testFile.toURL();
- final GraphicServer4a server = TestGraphicServer4a.getServer();
- final Document document = server.urlToDom(url);
- assertNotNull(document);
-
- /* The document itself has two children, the document type, and the
- * root element. */
- NodeList nodeList = document.getChildNodes();
- assertEquals(2, nodeList.getLength());
- /* The first node is the document type node. */
- assertEquals(Node.DOCUMENT_TYPE_NODE, nodeList.item(0).getNodeType());
-
- /* The second node is the root element. */
- Node node = nodeList.item(1);
- assertEquals(Node.ELEMENT_NODE, node.getNodeType());
- assertEquals("math", node.getLocalName());
-
- /* The root node has one child, an "mrow" element. */
- nodeList = node.getChildNodes();
- assertEquals(3, nodeList.getLength());
- /* The first child is ignorable whitespace. */
- assertEquals(Node.TEXT_NODE, nodeList.item(0).getNodeType());
- /* The second child is the actual element. */
- assertEquals(Node.ELEMENT_NODE, nodeList.item(1).getNodeType());
- /* The third child is ignorable whitespace. */
- assertEquals(Node.TEXT_NODE, nodeList.item(2).getNodeType());
- node = nodeList.item(1);
- assertEquals("mrow", node.getLocalName());
-
- /* It is certainly possible to test this DOM document more extensively,
- * but this is enough to show that it was parsed. */
+ public void testDummy() {
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-06-08 19:44:31
|
Revision: 10863
http://foray.svn.sourceforge.net/foray/?rev=10863&view=rev
Author: victormote
Date: 2009-06-08 19:44:24 +0000 (Mon, 08 Jun 2009)
Log Message:
-----------
Move some common-ish things related to MathML to a new class in Common, so they can be reused.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/java/org/foray/graphic/math/MathMLDocument4a.java
Added Paths:
-----------
trunk/foray/foray-common/src/java/org/foray/common/MathMLUtil.java
Added: trunk/foray/foray-common/src/java/org/foray/common/MathMLUtil.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/MathMLUtil.java (rev 0)
+++ trunk/foray/foray-common/src/java/org/foray/common/MathMLUtil.java 2009-06-08 19:44:24 UTC (rev 10863)
@@ -0,0 +1,56 @@
+/*
+ * 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;
+
+/**
+ * Utilities related to the Math Markup Language (MathML).
+ */
+public final class MathMLUtil {
+
+ /** The namespace URI for MathML. */
+ public static final String MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
+
+ /** The typical abbreviation used to designate an element as being in the MathML namespace. */
+ public static final String MATHML_NAMESPACE_SHORT = "m";
+
+ /** The name of the root element in a MathML document. */
+ public static final String MATHML_ROOT_ELEMENT_NAME = "math";
+
+ /** The public id of the DTD for a MathML document. */
+ public static final String MATHML_PUBLIC_ID = "-//W3C//DTD MathML 2.0//EN";
+
+ /** The system id of the DTD for a MathML document. */
+ public static final String MATHML_SYSTEM_ID = "http://www.w3.org/TR/MathML2/dtd/mathml2.dtd";
+
+ /**
+ * Private Constructor. This is a utility class and should never be instantiated.
+ */
+ private MathMLUtil() { }
+
+}
Property changes on: trunk/foray/foray-common/src/java/org/foray/common/MathMLUtil.java
___________________________________________________________________
Added: svn:keywords
+ "Author Id Rev Date URL"
Added: svn:eol-style
+ native
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/math/MathMLDocument4a.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/math/MathMLDocument4a.java 2009-06-08 19:11:18 UTC (rev 10862)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/math/MathMLDocument4a.java 2009-06-08 19:44:24 UTC (rev 10863)
@@ -28,6 +28,8 @@
package org.foray.graphic.math;
+import org.foray.common.MathMLUtil;
+
import org.apache.xerces.dom.CoreDocumentImpl;
import org.w3c.dom.DOMImplementation;
@@ -42,20 +44,8 @@
/**
* An implementation of the DOM MathMLDocument interface.
*/
-public final class MathMLDocument4a extends CoreDocumentImpl
- implements MathMLDocument {
+public final class MathMLDocument4a extends CoreDocumentImpl implements MathMLDocument {
- /** The namespace URI for MathML. */
- public static final String MATHML_NAMESPACE =
- "http://www.w3.org/1998/Math/MathML";
-
- /** The typical abbreviation used to designate an element as being in the
- * MathML namespace. */
- public static final String MATHML_NAMESPACE_SHORT = "m";
-
- /** The name of the root element in a MathML document. */
- public static final String MATHML_ROOT_ELEMENT_NAME = "math";
-
/** Constant needed for serialization. */
private static final long serialVersionUID = 8923397852693491757L;
@@ -92,9 +82,7 @@
this.referrer = referrer;
this.domain = domain;
this.uri = uri;
- final Element root = this.createElementNS(
- MathMLDocument4a.MATHML_NAMESPACE,
- MathMLDocument4a.MATHML_ROOT_ELEMENT_NAME);
+ final Element root = this.createElementNS(MathMLUtil.MATHML_NAMESPACE, MathMLUtil.MATHML_ROOT_ELEMENT_NAME);
this.appendChild(root);
}
@@ -135,10 +123,8 @@
DocumentBuilder builder = null;
builder = factory.newDocumentBuilder();
final DOMImplementation impl = builder.getDOMImplementation();
- MathMLDocument4a.mathmlDocumentType = impl.createDocumentType(
- MathMLDocument4a.MATHML_ROOT_ELEMENT_NAME,
- "-//W3C//DTD MathML 2.0//EN",
- "http://www.w3.org/TR/MathML2/dtd/mathml2.dtd");
+ MathMLDocument4a.mathmlDocumentType = impl.createDocumentType(MathMLUtil.MATHML_ROOT_ELEMENT_NAME,
+ MathMLUtil.MATHML_PUBLIC_ID, MathMLUtil.MATHML_SYSTEM_ID);
return MathMLDocument4a.mathmlDocumentType;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-06-08 20:03:27
|
Revision: 10864
http://foray.svn.sourceforge.net/foray/?rev=10864&view=rev
Author: victormote
Date: 2009-06-08 19:59:06 +0000 (Mon, 08 Jun 2009)
Log Message:
-----------
Add optional LSResourceResolver when converting to a DOM.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/XMLUtil.java
trunk/foray/foray-common/src/javatest/org/foray/common/TestXMLUtil.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/MathFactory.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/XMLUtil.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/XMLUtil.java 2009-06-08 19:44:24 UTC (rev 10863)
+++ trunk/foray/foray-common/src/java/org/foray/common/XMLUtil.java 2009-06-08 19:59:06 UTC (rev 10864)
@@ -28,12 +28,14 @@
package org.foray.common;
+import org.w3c.dom.DOMConfiguration;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.bootstrap.DOMImplementationRegistry;
import org.w3c.dom.ls.DOMImplementationLS;
import org.w3c.dom.ls.LSException;
import org.w3c.dom.ls.LSParser;
+import org.w3c.dom.ls.LSResourceResolver;
import java.io.IOException;
import java.net.URISyntaxException;
@@ -166,15 +168,20 @@
/**
* Converts a URL to a generic DOM Document.
* @param url The URL to be parsed to a DOM document.
+ * @param resourceResolver The resource resolver to use, which can be null.
+ * This is useful for cases where we want (for example) to find a DTD locally instead of on the internet.
* @return The DOM document.
* @throws IOException For errors parsing the document.
*/
- public static Document urlToDom(final URL url) throws IOException {
+ public static Document urlToDom(final URL url, final LSResourceResolver resourceResolver) throws IOException {
final DOMImplementationLS impl = XMLUtil.getDOMImplementation();
+ final LSParser builder = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);
+ final DOMConfiguration domConfiguration = builder.getDomConfig();
+ if (resourceResolver != null
+ && domConfiguration.canSetParameter("resource-resolver", resourceResolver)) {
+ domConfiguration.setParameter("resource-resolver", resourceResolver);
+ }
- final LSParser builder = impl.createLSParser(
- DOMImplementationLS.MODE_SYNCHRONOUS, null);
-
String uriString = null;
try {
uriString = url.toURI().toString();
Modified: trunk/foray/foray-common/src/javatest/org/foray/common/TestXMLUtil.java
===================================================================
--- trunk/foray/foray-common/src/javatest/org/foray/common/TestXMLUtil.java 2009-06-08 19:44:24 UTC (rev 10863)
+++ trunk/foray/foray-common/src/javatest/org/foray/common/TestXMLUtil.java 2009-06-08 19:59:06 UTC (rev 10864)
@@ -31,6 +31,7 @@
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.w3c.dom.ls.LSResourceResolver;
import java.io.File;
import java.io.IOException;
@@ -44,7 +45,7 @@
public class TestXMLUtil extends TestCase {
/**
- * Test the method {@link XMLUtil#urlToDom(java.net.URL)} by parsing
+ * Test the method {@link XMLUtil#urlToDom(java.net.URL, org.w3c.dom.ls.LSResourceResolver)} by parsing
* a file and testing the results.
* @throws IOException For errors getting the local sandbox.
*/
@@ -53,7 +54,8 @@
final File graphicsDir = new File(sandbox, "resource/fo-examples/graphics");
final File testFile = new File(graphicsDir, "mathml-example-1.xml");
final URL url = testFile.toURL();
- final Document document = XMLUtil.urlToDom(url);
+ final LSResourceResolver resourceResolver = null;
+ final Document document = XMLUtil.urlToDom(url, resourceResolver);
assertNotNull(document);
/* The document itself has two children, the document type, and the
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/MathFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/MathFactory.java 2009-06-08 19:44:24 UTC (rev 10863)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/MathFactory.java 2009-06-08 19:59:06 UTC (rev 10864)
@@ -35,6 +35,7 @@
import org.axsl.graphic.GraphicException;
import org.w3c.dom.Document;
+import org.w3c.dom.ls.LSResourceResolver;
import org.w3c.dom.svg.SVGDocument;
import java.io.BufferedInputStream;
@@ -75,7 +76,8 @@
}
/* Convert the URL to a generic DOM document instance. */
- final Document dom = XMLUtil.urlToDom(url);
+ final LSResourceResolver resourceResolver = null;
+ final Document dom = XMLUtil.urlToDom(url, resourceResolver);
/* Convert the generic DOM to an SVGDocument (DOM/SVG Document), using
* JEuclid. */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-06-09 18:06:11
|
Revision: 10877
http://foray.svn.sourceforge.net/foray/?rev=10877&view=rev
Author: victormote
Date: 2009-06-09 18:06:09 +0000 (Tue, 09 Jun 2009)
Log Message:
-----------
Use Execution Environments to protect the JVM that is being used from the workspace JVM, but to still allow flexibility in which specific version is being used.
Modified Paths:
--------------
trunk/foray/foray-app/.classpath
trunk/foray/foray-areatree/.classpath
trunk/foray/foray-common/.classpath
trunk/foray/foray-core/.classpath
trunk/foray/foray-font/.classpath
trunk/foray/foray-fotree/.classpath
trunk/foray/foray-graphic/.classpath
trunk/foray/foray-hyphen/.classpath
trunk/foray/foray-layout/.classpath
trunk/foray/foray-mif/.classpath
trunk/foray/foray-output/.classpath
trunk/foray/foray-pdf/.classpath
trunk/foray/foray-pioneer/.classpath
trunk/foray/foray-pretty/.classpath
trunk/foray/foray-ps/.classpath
trunk/foray/foray-render/.classpath
trunk/foray/foray-speech/.classpath
trunk/foray/foray-text/.classpath
Modified: trunk/foray/foray-app/.classpath
===================================================================
--- trunk/foray/foray-app/.classpath 2009-06-09 16:43:04 UTC (rev 10876)
+++ trunk/foray/foray-app/.classpath 2009-06-09 18:06:09 UTC (rev 10877)
@@ -2,7 +2,6 @@
<classpath>
<classpathentry excluding=".#*" kind="src" path="src/java"/>
<classpathentry kind="src" path="src/javatest"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/FOrayCommon"/>
<classpathentry kind="src" path="/FOrayFont"/>
<classpathentry kind="src" path="/FOrayGraphic"/>
@@ -41,5 +40,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/axslMif"/>
<classpathentry combineaccessrules="false" kind="src" path="/FOrayMIF"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslPs"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-areatree/.classpath
===================================================================
--- trunk/foray/foray-areatree/.classpath 2009-06-09 16:43:04 UTC (rev 10876)
+++ trunk/foray/foray-areatree/.classpath 2009-06-09 18:06:09 UTC (rev 10877)
@@ -2,7 +2,6 @@
<classpath>
<classpathentry excluding=".#*" kind="src" path="src/java"/>
<classpathentry kind="src" path="src/javatest"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/FOrayCommon"/>
<classpathentry kind="src" path="/axslFont"/>
<classpathentry kind="src" path="/axslGraphic"/>
@@ -14,5 +13,6 @@
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/svg-1.1.jar" sourcepath="/FOray Lib-Build/svg/svg-1.1-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib-Build/junit/junit-4.4.jar" sourcepath="/FOray Lib-Build/junit/junit-4.4-src.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-common/.classpath
===================================================================
--- trunk/foray/foray-common/.classpath 2009-06-09 16:43:04 UTC (rev 10876)
+++ trunk/foray/foray-common/.classpath 2009-06-09 18:06:09 UTC (rev 10877)
@@ -2,7 +2,6 @@
<classpath>
<classpathentry excluding=".#*" kind="src" path="src/java"/>
<classpathentry kind="src" path="src/javatest"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/axslCommon"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib-Build/junit/junit-4.4.jar" sourcepath="/FOray Lib-Build/junit/junit-4.4-src.jar"/>
@@ -10,5 +9,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/axslPs"/>
<classpathentry kind="lib" path="/aXSL Lib/mathml-2.0.jar" sourcepath="/aXSL Lib-Build/mathml/mathml-2.0-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/axsl-all-0.3.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-core/.classpath
===================================================================
--- trunk/foray/foray-core/.classpath 2009-06-09 16:43:04 UTC (rev 10876)
+++ trunk/foray/foray-core/.classpath 2009-06-09 18:06:09 UTC (rev 10877)
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/FOrayCommon"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslAreaTree"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslFont"/>
@@ -17,5 +16,6 @@
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslSpeech"/>
<classpathentry kind="lib" path="/FOray Lib/foray-common-0.4-dev-rsrc.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-font/.classpath
===================================================================
--- trunk/foray/foray-font/.classpath 2009-06-09 16:43:04 UTC (rev 10876)
+++ trunk/foray/foray-font/.classpath 2009-06-09 18:06:09 UTC (rev 10877)
@@ -2,7 +2,6 @@
<classpath>
<classpathentry excluding=".#*" kind="src" path="src/java"/>
<classpathentry kind="src" path="src/javatest"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/axslFont"/>
<classpathentry kind="src" path="/FOrayCommon"/>
<classpathentry kind="src" path="/axslPs"/>
@@ -15,5 +14,6 @@
<classpathentry kind="lib" path="/FOray Lib/commons-io-1.4.jar" sourcepath="/FOray Lib-Build/commons-io/commons-io-1.4-sources.jar"/>
<classpathentry kind="lib" path="/FOray Lib/commons-discovery-0.4.jar" sourcepath="/FOray Lib-Build/commons-discovery"/>
<classpathentry kind="lib" path="/FOray Lib/foray-font-0.4-rsrc.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-fotree/.classpath
===================================================================
--- trunk/foray/foray-fotree/.classpath 2009-06-09 16:43:04 UTC (rev 10876)
+++ trunk/foray/foray-fotree/.classpath 2009-06-09 18:06:09 UTC (rev 10877)
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/FOrayCommon"/>
<classpathentry excluding=".#*" kind="src" path="src/java"/>
<classpathentry kind="src" path="src/javatest"/>
@@ -14,5 +13,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/axslSpeech"/>
<classpathentry kind="lib" path="/FOray Lib/mathml-2.0.jar" sourcepath="/FOray Lib-Build/mathml/mathml-2.0-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib-Build/junit/junit-4.4.jar" sourcepath="/FOray Lib-Build/junit/junit-4.4-src.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-graphic/.classpath
===================================================================
--- trunk/foray/foray-graphic/.classpath 2009-06-09 16:43:04 UTC (rev 10876)
+++ trunk/foray/foray-graphic/.classpath 2009-06-09 18:06:09 UTC (rev 10877)
@@ -2,7 +2,6 @@
<classpath>
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="src" path="src/javatest"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/FOrayCommon"/>
<classpathentry kind="src" path="/axslGraphic"/>
<classpathentry kind="src" path="/axslCommon"/>
@@ -30,5 +29,6 @@
<classpathentry kind="lib" path="/FOray Lib-Build/junit/junit-4.4.jar" sourcepath="/FOray Lib-Build/junit/junit-4.4-src.jar"/>
<classpathentry kind="lib" path="/FOray Lib/commons-io-1.4.jar" sourcepath="/FOray Lib-Build/commons-io/commons-io-1.4-sources.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslPdf"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-hyphen/.classpath
===================================================================
--- trunk/foray/foray-hyphen/.classpath 2009-06-09 16:43:04 UTC (rev 10876)
+++ trunk/foray/foray-hyphen/.classpath 2009-06-09 18:06:09 UTC (rev 10877)
@@ -2,7 +2,6 @@
<classpath>
<classpathentry excluding=".#*" kind="src" path="src/java"/>
<classpathentry kind="src" path="src/javatest"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/FOrayCommon"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslHyphen"/>
<classpathentry kind="lib" path="/FOray Lib/xercesImpl-2.7.1.jar" sourcepath="/FOray Lib-Build/xerces/Xerces-J-src.2.7.1.zip"/>
@@ -12,5 +11,6 @@
<classpathentry kind="lib" path="/FOray Lib-Build/ant/ant.jar"/>
<classpathentry kind="lib" path="/FOray Lib-Build/junit/junit-4.4.jar" sourcepath="/FOray Lib-Build/junit/junit-4.4-src.jar"/>
<classpathentry kind="lib" path="/FOray Lib/foray-hyphen-0.4-rsrc.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-layout/.classpath
===================================================================
--- trunk/foray/foray-layout/.classpath 2009-06-09 16:43:04 UTC (rev 10876)
+++ trunk/foray/foray-layout/.classpath 2009-06-09 18:06:09 UTC (rev 10877)
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/FOrayCommon"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslFoTree"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslText"/>
@@ -11,5 +10,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/axslCommon"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslLayout"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-mif/.classpath
===================================================================
--- trunk/foray/foray-mif/.classpath 2009-06-09 16:43:04 UTC (rev 10876)
+++ trunk/foray/foray-mif/.classpath 2009-06-09 18:06:09 UTC (rev 10877)
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding=".#*" kind="src" path="src/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/axslCommon"/>
<classpathentry combineaccessrules="false" kind="src" path="/FOrayCommon"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslOutput"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslMif"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-output/.classpath
===================================================================
--- trunk/foray/foray-output/.classpath 2009-06-09 16:43:04 UTC (rev 10876)
+++ trunk/foray/foray-output/.classpath 2009-06-09 18:06:09 UTC (rev 10877)
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/axslGraphic"/>
<classpathentry kind="src" path="/FOrayCommon"/>
<classpathentry kind="src" path="/axslFont"/>
@@ -10,5 +9,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/axslOutput"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslMif"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-pdf/.classpath
===================================================================
--- trunk/foray/foray-pdf/.classpath 2009-06-09 16:43:04 UTC (rev 10876)
+++ trunk/foray/foray-pdf/.classpath 2009-06-09 18:06:09 UTC (rev 10877)
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding=".#*" kind="src" path="src/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/axslFont"/>
<classpathentry kind="src" path="/axslGraphic"/>
<classpathentry kind="src" path="/FOrayCommon"/>
@@ -10,5 +9,6 @@
<classpathentry kind="src" path="/axslPdf"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/svg-1.1.jar" sourcepath="/FOray Lib-Build/svg/svg-1.1-src.zip"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-pioneer/.classpath
===================================================================
--- trunk/foray/foray-pioneer/.classpath 2009-06-09 16:43:04 UTC (rev 10876)
+++ trunk/foray/foray-pioneer/.classpath 2009-06-09 18:06:09 UTC (rev 10877)
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding=".#*" kind="src" path="src/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/axslFont"/>
<classpathentry kind="src" path="/axslGraphic"/>
<classpathentry kind="src" path="/axslAreaTree"/>
@@ -12,5 +11,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/FOrayLayout"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslLayout"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-pretty/.classpath
===================================================================
--- trunk/foray/foray-pretty/.classpath 2009-06-09 16:43:04 UTC (rev 10876)
+++ trunk/foray/foray-pretty/.classpath 2009-06-09 18:06:09 UTC (rev 10877)
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/FOrayCommon"/>
<classpathentry kind="lib" path="/FOray Lib/resolver.jar"/>
<classpathentry kind="lib" path="/FOray Lib/stax-api-1.0.1.jar" sourcepath="/FOray Lib-Build/stax/stax-src-1.2.0.zip"/>
<classpathentry kind="lib" path="/FOray Lib/xercesImpl-2.7.1.jar" sourcepath="/FOray Lib-Build/xerces/Xerces-J-src.2.7.1.zip"/>
<classpathentry kind="lib" path="/FOray Lib/stax-1.2.0.jar" sourcepath="/FOray Lib-Build/stax/stax-src-1.2.0.zip"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-ps/.classpath
===================================================================
--- trunk/foray/foray-ps/.classpath 2009-06-09 16:43:04 UTC (rev 10876)
+++ trunk/foray/foray-ps/.classpath 2009-06-09 18:06:09 UTC (rev 10877)
@@ -2,11 +2,11 @@
<classpath>
<classpathentry excluding=".#*" kind="src" path="src/java"/>
<classpathentry kind="src" path="src/javatest"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/FOrayCommon"/>
<classpathentry kind="src" path="/axslPs"/>
<classpathentry kind="src" path="/axslCommon"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib-Build/junit/junit-4.4.jar" sourcepath="/FOray Lib-Build/junit/junit-4.4-src.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-render/.classpath
===================================================================
--- trunk/foray/foray-render/.classpath 2009-06-09 16:43:04 UTC (rev 10876)
+++ trunk/foray/foray-render/.classpath 2009-06-09 18:06:09 UTC (rev 10877)
@@ -2,7 +2,6 @@
<classpath>
<classpathentry excluding=".#*" kind="src" path="src/java"/>
<classpathentry kind="src" path="src/javatest"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/FOrayCommon"/>
<classpathentry kind="src" path="/axslFont"/>
<classpathentry kind="src" path="/axslGraphic"/>
@@ -16,5 +15,6 @@
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/svg-1.1.jar" sourcepath="/FOray Lib-Build/svg/svg-1.1-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib-Build/junit/junit-4.4.jar" sourcepath="/FOray Lib-Build/junit/junit-4.4-src.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-speech/.classpath
===================================================================
--- trunk/foray/foray-speech/.classpath 2009-06-09 16:43:04 UTC (rev 10876)
+++ trunk/foray/foray-speech/.classpath 2009-06-09 18:06:09 UTC (rev 10877)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslSpeech"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-text/.classpath
===================================================================
--- trunk/foray/foray-text/.classpath 2009-06-09 16:43:04 UTC (rev 10876)
+++ trunk/foray/foray-text/.classpath 2009-06-09 18:06:09 UTC (rev 10877)
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding=".#*" kind="src" path="src/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/axslFont"/>
<classpathentry kind="src" path="/axslText"/>
<classpathentry kind="src" path="/axslCommon"/>
<classpathentry kind="src" path="/FOrayCommon"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslHyphen"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-06-18 01:23:00
|
Revision: 10882
http://foray.svn.sourceforge.net/foray/?rev=10882&view=rev
Author: victormote
Date: 2009-06-18 00:44:35 +0000 (Thu, 18 Jun 2009)
Log Message:
-----------
Move method and related dependencies to Common where they can be reused.
Modified Paths:
--------------
trunk/foray/foray-common/.classpath
trunk/foray/foray-common/scripts/build.xml
trunk/foray/foray-common/src/java/org/foray/common/XMLUtil.java
trunk/foray/foray-pretty/.classpath
trunk/foray/foray-pretty/scripts/build.xml
trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java
Modified: trunk/foray/foray-common/.classpath
===================================================================
--- trunk/foray/foray-common/.classpath 2009-06-12 22:59:00 UTC (rev 10881)
+++ trunk/foray/foray-common/.classpath 2009-06-18 00:44:35 UTC (rev 10882)
@@ -10,5 +10,6 @@
<classpathentry kind="lib" path="/aXSL Lib/mathml-2.0.jar" sourcepath="/aXSL Lib-Build/mathml/mathml-2.0-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/axsl-all-0.3.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="lib" path="/FOray Lib/xercesImpl-2.7.1.jar" sourcepath="/FOray Lib-Build/xerces/Xerces-J-src.2.7.1.zip"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-common/scripts/build.xml
===================================================================
--- trunk/foray/foray-common/scripts/build.xml 2009-06-12 22:59:00 UTC (rev 10881)
+++ trunk/foray/foray-common/scripts/build.xml 2009-06-18 00:44:35 UTC (rev 10882)
@@ -35,6 +35,7 @@
<include name="axsl*.jar"/>
<include name="commons-logging-*.jar"/>
<include name="commons-io-*.jar"/>
+ <include name="xercesImpl*.jar"/>
</fileset>
</path>
Modified: trunk/foray/foray-common/src/java/org/foray/common/XMLUtil.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/XMLUtil.java 2009-06-12 22:59:00 UTC (rev 10881)
+++ trunk/foray/foray-common/src/java/org/foray/common/XMLUtil.java 2009-06-18 00:44:35 UTC (rev 10882)
@@ -28,6 +28,8 @@
package org.foray.common;
+import org.apache.xerces.util.XMLCatalogResolver;
+
import org.w3c.dom.DOMConfiguration;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
@@ -36,6 +38,7 @@
import org.w3c.dom.ls.LSException;
import org.w3c.dom.ls.LSParser;
import org.w3c.dom.ls.LSResourceResolver;
+import org.xml.sax.EntityResolver;
import java.io.IOException;
import java.net.URISyntaxException;
@@ -200,4 +203,19 @@
return document;
}
+ /**
+ * Creates an EntityResolver for one or more XML catalogs.
+ * @param catalogs The array of URIs indicating where an XML catalogs are located.
+ * @return The created EntityResolver.
+ */
+ public static EntityResolver getEntityResolver(final String[] catalogs) {
+ if (catalogs == null) {
+ return null;
+ }
+ final XMLCatalogResolver resolver = new XMLCatalogResolver();
+ resolver.setPreferPublic(true);
+ resolver.setCatalogList(catalogs);
+ return resolver;
+ }
+
}
Modified: trunk/foray/foray-pretty/.classpath
===================================================================
--- trunk/foray/foray-pretty/.classpath 2009-06-12 22:59:00 UTC (rev 10881)
+++ trunk/foray/foray-pretty/.classpath 2009-06-18 00:44:35 UTC (rev 10882)
@@ -4,7 +4,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/FOrayCommon"/>
<classpathentry kind="lib" path="/FOray Lib/resolver.jar"/>
<classpathentry kind="lib" path="/FOray Lib/stax-api-1.0.1.jar" sourcepath="/FOray Lib-Build/stax/stax-src-1.2.0.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/xercesImpl-2.7.1.jar" sourcepath="/FOray Lib-Build/xerces/Xerces-J-src.2.7.1.zip"/>
<classpathentry kind="lib" path="/FOray Lib/stax-1.2.0.jar" sourcepath="/FOray Lib-Build/stax/stax-src-1.2.0.zip"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
Modified: trunk/foray/foray-pretty/scripts/build.xml
===================================================================
--- trunk/foray/foray-pretty/scripts/build.xml 2009-06-12 22:59:00 UTC (rev 10881)
+++ trunk/foray/foray-pretty/scripts/build.xml 2009-06-18 00:44:35 UTC (rev 10882)
@@ -25,7 +25,6 @@
<include name="xml-apis*.jar"/>
<include name="stax*.jar"/>
<include name="resolver*.jar"/>
- <include name="xercesImpl*.jar"/>
<include name="commons-logging-*.jar"/>
</fileset>
<fileset dir="${foray.sandbox}/foray-common/build/ant">
Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java
===================================================================
--- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2009-06-12 22:59:00 UTC (rev 10881)
+++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2009-06-18 00:44:35 UTC (rev 10882)
@@ -35,7 +35,6 @@
import org.foray.pretty.dtd.ElementStack;
import org.apache.commons.logging.Log;
-import org.apache.xerces.util.XMLCatalogResolver;
import org.xml.sax.Attributes;
import org.xml.sax.EntityResolver;
@@ -200,7 +199,8 @@
final String catalog) {
this.input = input;
this.output = output;
- this.entityResolver = getEntityResolver(catalog);
+ final String [] catalogs = {catalog};
+ this.entityResolver = XMLUtil.getEntityResolver(catalogs);
/* Set the line terminator to the default for this operating system. */
this.lineTerminator = System.getProperty("line.separator");
@@ -726,23 +726,6 @@
}
/**
- * Creates an EntityResolver.
- * @param catalog The catalog which should be encapsulated in an
- * EntityResolver.
- * @return The created EntityResolver.
- */
- private EntityResolver getEntityResolver(final String catalog) {
- if (catalog == null) {
- return null;
- }
- final String [] catalogs = {catalog};
- final XMLCatalogResolver resolver = new XMLCatalogResolver();
- resolver.setPreferPublic(true);
- resolver.setCatalogList(catalogs);
- return resolver;
- }
-
- /**
* Returns the logger.
* @return The logger.
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-10-11 18:18:54
|
Revision: 10893
http://foray.svn.sourceforge.net/foray/?rev=10893&view=rev
Author: victormote
Date: 2009-10-11 18:18:24 +0000 (Sun, 11 Oct 2009)
Log Message:
-----------
Clean up some compiler warnings about dead code, bad javadoc. Fixed one bug in FOrayXDiff resulting from flagged dead code.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java
trunk/foray/foray-common/src/java/org/foray/common/Configuration.java
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/PatternGenerator.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFAnnotation.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFBorderStyle.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPage.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPages.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPattern.java
trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java
trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java 2009-08-27 19:53:43 UTC (rev 10892)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java 2009-10-11 18:18:24 UTC (rev 10893)
@@ -933,14 +933,6 @@
}
/**
- * Indicates whether this character sequence has a discretionary hyphen.
- * @return True iff this character sequence has a discretionary hyphen.
- */
- public boolean hasDiscretionaryHyphen() {
- return this.hasDiscretionaryHyphen;
- }
-
- /**
* Indicates whether this character sequence has faux small caps.
* @return True iff this character sequence has faux small caps.
*/
Modified: trunk/foray/foray-common/src/java/org/foray/common/Configuration.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/Configuration.java 2009-08-27 19:53:43 UTC (rev 10892)
+++ trunk/foray/foray-common/src/java/org/foray/common/Configuration.java 2009-10-11 18:18:24 UTC (rev 10893)
@@ -167,7 +167,7 @@
*/
protected List<?> getListValue(final String key) {
final Object obj = getValue(key);
- if (obj instanceof List) {
+ if (obj instanceof List<?>) {
return (List<?>) obj;
}
return null;
@@ -356,7 +356,7 @@
final Object value = this.options.get(key);
if (value instanceof String) {
this.logger.info(" value: " + value);
- } else if (value instanceof List) {
+ } else if (value instanceof List<?>) {
final StringBuilder valueString = new StringBuilder();
final List<?> list = (List<?>) value;
valueString.append(" value: ");
Modified: trunk/foray/foray-hyphen/src/java/org/foray/hyphen/PatternGenerator.java
===================================================================
--- trunk/foray/foray-hyphen/src/java/org/foray/hyphen/PatternGenerator.java 2009-08-27 19:53:43 UTC (rev 10892)
+++ trunk/foray/foray-hyphen/src/java/org/foray/hyphen/PatternGenerator.java 2009-10-11 18:18:24 UTC (rev 10893)
@@ -125,7 +125,7 @@
* variables private. */
/** Maximum number of levels + 1. Also used to denote bad patterns. */
- private static final byte MAX_VAL = 10;
+ private static final byte DEFAULT_MAX_VAL = 10;
/** Ordinal number of the smallest element of text_char. */
private static final byte FIRST_TEXT_CHAR = 0;
@@ -196,10 +196,10 @@
/** Space for pattern count trie, must be less than {@link #TRIE_SIZE} and
* greater than the number of occurrences of any pattern in the
* dictionary. */
- private static final int TRIEC_SIZE = 26000;
+ private static final int DEFAULT_TRIEC_SIZE = 26000;
/** Size of output hash table, should be a multiple of 510. */
- private static final short MAX_OPS = 4080;
+ private static final short DEFAULT_MAX_OPS = 4080;
/** Maximum pattern length. Also maximum length of external representation
* of a "letter". */
@@ -209,10 +209,19 @@
private static final byte MAX_LEN = 50;
/** Maximum length of input lines, must be at least {@link #MAX_LEN}. */
- private static final short MAX_BUF_LEN = 3000;
+ private static final short DEFAULT_MAX_BUF_LEN = 3000;
/* End of Constants from TeX code. */
+ /* Start of constant-like variables. (These were constants in the original code, but can now be expanded if wished,
+ * as we are free of some limitations that existed when this code was first written. */
+ private int triecSize = DEFAULT_TRIEC_SIZE;
+ private short maxOps = DEFAULT_MAX_OPS;
+ private byte maxVal = DEFAULT_MAX_VAL;
+ private short maxBufLen = DEFAULT_MAX_BUF_LEN;
+
+ /* End of constant-like variables. */
+
/* Start of struct definitions from TeX code. */
private final class Opword {
private int dot;
@@ -247,12 +256,12 @@
private int[] triel = new int[PatternGenerator.TRIE_SIZE + 1];
private int[] trier = new int[PatternGenerator.TRIE_SIZE + 1];
private boolean[] trietaken = new boolean[PatternGenerator.TRIE_SIZE + 1];
- private char[] triecc = new char[PatternGenerator.TRIEC_SIZE + 1];
- private int[] triecl = new int[PatternGenerator.TRIEC_SIZE + 1];
- private int[] triecr = new int[PatternGenerator.TRIEC_SIZE + 1];
- private boolean[] triectaken = new boolean[PatternGenerator.TRIEC_SIZE + 1];
+ private char[] triecc = new char[this.triecSize + 1];
+ private int[] triecl = new int[this.triecSize + 1];
+ private int[] triecr = new int[this.triecSize + 1];
+ private boolean[] triectaken = new boolean[this.triecSize + 1];
private PatternGenerator.Opword[] ops =
- new PatternGenerator.Opword[PatternGenerator.MAX_OPS + 1];
+ new PatternGenerator.Opword[this.maxOps + 1];
{
for (int i = 0; i < this.ops.length; i++) {
this.ops[i] = new Opword();
@@ -284,7 +293,7 @@
// private float badfrac;
// private float denom;
// private float eff;
- private char[] buf = new char[PatternGenerator.MAX_BUF_LEN + 1];
+ private char[] buf = new char[this.maxBufLen + 1];
private int bufptr;
private char imax;
private int lefthyphenmin;
@@ -374,24 +383,24 @@
* prevent range check and array bound violations. */
int bad = 0;
- if (PatternGenerator.LAST_ASCII_CODE < WKConstants.MAX_7_BIT_UNSIGNED_VALUES - 1) {
- bad = 1;
- }
+// if (PatternGenerator.LAST_ASCII_CODE < WKConstants.MAX_7_BIT_UNSIGNED_VALUES - 1) {
+// bad = 1;
+// }
if ((si((char) 0) != PatternGenerator.MIN_PACKED)
|| (so((char) PatternGenerator.MIN_PACKED) != 0)) {
bad = 2;
}
- if ((PatternGenerator.TRIEC_SIZE < 4096)
- || (PatternGenerator.TRIE_SIZE < PatternGenerator.TRIEC_SIZE)) {
+ if ((this.triecSize < 4096)
+ || (PatternGenerator.TRIE_SIZE < this.triecSize)) {
bad = 3;
}
- if (PatternGenerator.MAX_OPS > PatternGenerator.TRIE_SIZE) {
+ if (this.maxOps > PatternGenerator.TRIE_SIZE) {
bad = 4;
}
- if (PatternGenerator.MAX_VAL > 10) {
+ if (this.maxVal > 10) {
bad = 5;
}
- if (PatternGenerator.MAX_BUF_LEN < PatternGenerator.MAX_LEN) {
+ if (this.maxBufLen < PatternGenerator.MAX_LEN) {
bad = 6;
}
if (bad > 0) {
@@ -600,7 +609,7 @@
this.trier[this.triemax + 1] = 0;
int forEnd2;
h = 1;
- forEnd2 = PatternGenerator.MAX_OPS;
+ forEnd2 = this.maxOps;
if (h <= forEnd2) {
do {
this.ops[h].val = 0;
@@ -720,13 +729,13 @@
}
private int znewtrieop(final int v, final int d, final int n) throws HyphenationException {
- int h = ((n + 313 * d + 361 * v) % PatternGenerator.MAX_OPS) + 1;
+ int h = ((n + 313 * d + 361 * v) % this.maxOps) + 1;
while (true) {
if (this.ops[h].val == 0) {
this.opcount = this.opcount + 1;
- if (this.opcount == PatternGenerator.MAX_OPS) {
+ if (this.opcount == this.maxOps) {
throw new HyphenationException("PATGEN capacity exceeded, sorry ["
- + PatternGenerator.MAX_OPS + " outputs].");
+ + this.maxOps + " outputs].");
}
this.ops[h].val = v;
this.ops[h].dot = d;
@@ -741,7 +750,7 @@
if (h > 1) {
h--;
} else {
- h = PatternGenerator.MAX_OPS;
+ h = this.maxOps;
}
}
}
@@ -830,13 +839,13 @@
a = this.triecl[a];
b = a - this.trieqc[1];
if (b > this.trieckmax - 256) {
- if (this.trieckmax == PatternGenerator.TRIEC_SIZE) {
+ if (this.trieckmax == this.triecSize) {
throw new HyphenationException("PATGEN capacity exceeded, sorry ["
- + PatternGenerator.TRIEC_SIZE + " count trie nodes].");
+ + this.triecSize + " count trie nodes].");
}
getLogger().info(this.trieckmax / 1024 + "K ");
- if (this.trieckmax > PatternGenerator.TRIEC_SIZE - 4096) {
- this.trieckmax = PatternGenerator.TRIEC_SIZE;
+ if (this.trieckmax > this.triecSize - 4096) {
+ this.trieckmax = this.triecSize;
} else {
this.trieckmax = this.trieckmax + 4096;
}
@@ -1052,12 +1061,12 @@
} else {
this.bufptr = 0;
while (! eoln(this.translate)) {
- if (this.bufptr >= PatternGenerator.MAX_BUF_LEN) {
+ if (this.bufptr >= this.maxBufLen) {
this.bufptr = 0;
do {
this.bufptr = this.bufptr + 1;
this.output.print(this.buf[this.bufptr]);
- } while (! (this.bufptr == PatternGenerator.MAX_BUF_LEN));
+ } while (! (this.bufptr == this.maxBufLen));
this.output.printf("%c\n", ' ');
throw new HyphenationException("Line too long");
}
@@ -1065,7 +1074,7 @@
this.buf[this.bufptr] = (char) this.translate.read();
}
readln(this.translate);
- while (this.bufptr < PatternGenerator.MAX_BUF_LEN) {
+ while (this.bufptr < this.maxBufLen) {
this.bufptr = this.bufptr + 1;
this.buf[this.bufptr] = ' ';
}
@@ -1146,7 +1155,7 @@
do {
this.bufptr = this.bufptr + 1;
this.output.print(this.buf[this.bufptr]);
- } while (! (this.bufptr == PatternGenerator.MAX_BUF_LEN));
+ } while (! (this.bufptr == this.maxBufLen));
this.output.printf("%c\n", ' ');
throw new HyphenationException("Bad hyphenation data");
}
@@ -1154,12 +1163,12 @@
while (! eof(this.translate)) {
this.bufptr = 0;
while (! eoln(this.translate)) {
- if (this.bufptr >= PatternGenerator.MAX_BUF_LEN) {
+ if (this.bufptr >= this.maxBufLen) {
this.bufptr = 0;
do {
this.bufptr = this.bufptr + 1;
this.output.print(this.buf[this.bufptr]);
- } while (! (this.bufptr == PatternGenerator.MAX_BUF_LEN));
+ } while (! (this.bufptr == this.maxBufLen));
this.output.printf("%c\n", ' ');
throw new HyphenationException("Line too long");
}
@@ -1167,7 +1176,7 @@
this.buf[this.bufptr] = (char) this.translate.read();
}
readln(this.translate);
- while (this.bufptr < PatternGenerator.MAX_BUF_LEN) {
+ while (this.bufptr < this.maxBufLen) {
this.bufptr = this.bufptr + 1;
this.buf[this.bufptr] = ' ';
}
@@ -1176,7 +1185,7 @@
lab30: while (! bad) {
this.patlen = 0;
do {
- if (this.bufptr < PatternGenerator.MAX_BUF_LEN) {
+ if (this.bufptr < this.maxBufLen) {
this.bufptr = this.bufptr + 1;
} else {
bad = true;
@@ -1191,7 +1200,7 @@
do {
this.bufptr = this.bufptr + 1;
this.output.print(this.buf[this.bufptr]);
- } while (! (this.bufptr == PatternGenerator.MAX_BUF_LEN));
+ } while (! (this.bufptr == this.maxBufLen));
this.output.printf("%c\n", ' ');
throw new HyphenationException(
"PATGEN capacity exceeded, sorry [" + 256
@@ -1281,7 +1290,7 @@
do {
this.bufptr = this.bufptr + 1;
this.output.print(this.buf[this.bufptr]);
- } while (! (this.bufptr == PatternGenerator.MAX_BUF_LEN));
+ } while (! (this.bufptr == this.maxBufLen));
this.output.printf("%c\n", ' ');
throw new HyphenationException("Bad representation");
}
@@ -1320,10 +1329,10 @@
forEnd2 = i - 1;
if (j <= forEnd2) {
do {
- if (this.triecmax == PatternGenerator.TRIEC_SIZE) {
+ if (this.triecmax == this.triecSize) {
throw new HyphenationException(
"PATGEN capacity exceeded, sorry ["
- + PatternGenerator.TRIEC_SIZE + " count trie nodes].");
+ + this.triecSize + " count trie nodes].");
}
this.triecmax = this.triecmax + 1;
this.triecl[l] = this.triecmax;
@@ -1352,7 +1361,7 @@
if (i < this.patlen) {
traversecounttrie(this.triecl[a], i + 1);
} else if (this.goodwt * this.triecl[a] < this.thresh) {
- insertpattern(PatternGenerator.MAX_VAL, this.patdot);
+ insertpattern(this.maxVal, this.patdot);
this.badpatcount = this.badpatcount + 1;
} else if (this.goodwt * this.triecl[a] - this.badwt * this.triecr[a]
>= this.thresh) {
@@ -1414,7 +1423,7 @@
this.ops[0].op = this.trier[t];
n = this.ops[0].op;
while (n > 0) {
- if (this.ops[n].val == PatternGenerator.MAX_VAL) {
+ if (this.ops[n].val == this.maxVal) {
this.ops[h].op = this.ops[n].op;
} else {
h = n;
@@ -1456,10 +1465,10 @@
deletepatterns(1);
int forEnd;
h = 1;
- forEnd = PatternGenerator.MAX_OPS;
+ forEnd = this.maxOps;
if (h <= forEnd) {
do {
- if (this.ops[h].val == PatternGenerator.MAX_VAL) {
+ if (this.ops[h].val == this.maxVal) {
this.ops[h].val = 0;
this.opcount = this.opcount - 1;
}
@@ -1538,12 +1547,12 @@
{
this.bufptr = 0;
while (! eoln(this.dictionary)) {
- if (this.bufptr >= PatternGenerator.MAX_BUF_LEN) {
+ if (this.bufptr >= this.maxBufLen) {
this.bufptr = 0;
do {
this.bufptr = this.bufptr + 1;
this.output.print(this.buf[this.bufptr]);
- } while (! (this.bufptr == PatternGenerator.MAX_BUF_LEN));
+ } while (! (this.bufptr == this.maxBufLen));
this.output.printf("%c\n", ' ');
throw new HyphenationException("Line too long");
}
@@ -1552,7 +1561,7 @@
this.buf[this.bufptr] = (char) byteRead;
}
readln(this.dictionary);
- while (this.bufptr < PatternGenerator.MAX_BUF_LEN) {
+ while (this.bufptr < this.maxBufLen) {
this.bufptr = this.bufptr + 1;
this.buf[this.bufptr] = ' ';
}
@@ -1586,7 +1595,7 @@
do {
this.bufptr = this.bufptr + 1;
this.output.print(this.buf[this.bufptr]);
- } while (! (this.bufptr == PatternGenerator.MAX_BUF_LEN));
+ } while (! (this.bufptr == this.maxBufLen));
this.output.printf("%c\n", ' ');
throw new HyphenationException("PATGEN capacity exceeded, sorry ["
+ "word length=" + PatternGenerator.MAX_LEN + "].");
@@ -1603,7 +1612,7 @@
do {
this.bufptr = this.bufptr + 1;
this.output.print(this.buf[this.bufptr]);
- } while (! (this.bufptr == PatternGenerator.MAX_BUF_LEN));
+ } while (! (this.bufptr == this.maxBufLen));
this.output.printf("%c\n", ' ');
throw new HyphenationException("PATGEN capacity exceeded, sorry ["
+ "word length=" + PatternGenerator.MAX_LEN + "].");
@@ -1616,7 +1625,7 @@
do {
this.bufptr = this.bufptr + 1;
this.output.print(this.buf[this.bufptr]);
- } while (! (this.bufptr == PatternGenerator.MAX_BUF_LEN));
+ } while (! (this.bufptr == this.maxBufLen));
this.output.printf("%c\n", ' ');
throw new HyphenationException("Bad representation");
}
@@ -1624,7 +1633,7 @@
this.word[this.wlen] = (char) this.trier[t];
break lab30;
}
- if (this.bufptr == PatternGenerator.MAX_BUF_LEN) {
+ if (this.bufptr == this.maxBufLen) {
c = ' ';
} else {
this.bufptr = this.bufptr + 1;
@@ -1640,12 +1649,12 @@
do {
this.bufptr = this.bufptr + 1;
this.output.print(this.buf[this.bufptr]);
- } while (! (this.bufptr == PatternGenerator.MAX_BUF_LEN));
+ } while (! (this.bufptr == this.maxBufLen));
this.output.printf("%c\n", ' ');
throw new HyphenationException("Bad character");
}
}
- } while (! (this.bufptr == PatternGenerator.MAX_BUF_LEN));
+ } while (! (this.bufptr == this.maxBufLen));
this.wlen = this.wlen + 1;
this.word[this.wlen] = 1;
}
@@ -1671,7 +1680,7 @@
while (h > 0) {
dpos = spos + this.ops[h].dot;
v = this.ops[h].val;
- if ((v < PatternGenerator.MAX_VAL)
+ if ((v < this.maxVal)
&& (this.hval[dpos] < v)) {
this.hval[dpos] = v;
}
@@ -1894,12 +1903,12 @@
while (! eof(this.patterns)) {
this.bufptr = 0;
while (! eoln(this.patterns)) {
- if (this.bufptr >= PatternGenerator.MAX_BUF_LEN) {
+ if (this.bufptr >= this.maxBufLen) {
this.bufptr = 0;
do {
this.bufptr = this.bufptr + 1;
this.output.print(this.buf[this.bufptr]);
- } while (! (this.bufptr == PatternGenerator.MAX_BUF_LEN));
+ } while (! (this.bufptr == this.maxBufLen));
this.output.printf("%c\n", ' ');
throw new HyphenationException("Line too long");
}
@@ -1908,7 +1917,7 @@
this.buf[this.bufptr] = (char) readChar;
}
readln(this.patterns);
- while (this.bufptr < PatternGenerator.MAX_BUF_LEN) {
+ while (this.bufptr < this.maxBufLen) {
this.bufptr = this.bufptr + 1;
this.buf[this.bufptr] = ' ';
}
@@ -1924,12 +1933,12 @@
break lab40;
case 1: {
d = this.xint[c];
- if (d >= PatternGenerator.MAX_VAL) {
+ if (d >= this.maxVal) {
this.bufptr = 0;
do {
this.bufptr = this.bufptr + 1;
this.output.print(this.buf[this.bufptr]);
- } while (! (this.bufptr == PatternGenerator.MAX_BUF_LEN));
+ } while (! (this.bufptr == this.maxBufLen));
this.output.printf("%c\n", ' ');
throw new HyphenationException("Bad hyphenation value");
}
@@ -1956,7 +1965,7 @@
do {
this.bufptr = this.bufptr + 1;
this.output.print(this.buf[this.bufptr]);
- } while (! (this.bufptr == PatternGenerator.MAX_BUF_LEN));
+ } while (! (this.bufptr == this.maxBufLen));
this.output.printf("%c\n", ' ');
throw new HyphenationException("Bad representation");
}
@@ -1964,7 +1973,7 @@
this.pat[this.patlen] = (char) this.trier[t];
break lab30;
}
- if (this.bufptr == PatternGenerator.MAX_BUF_LEN) {
+ if (this.bufptr == this.maxBufLen) {
c = ' ';
} else {
this.bufptr = this.bufptr + 1;
@@ -1979,12 +1988,12 @@
do {
this.bufptr = this.bufptr + 1;
this.output.print(this.buf[this.bufptr]);
- } while (! (this.bufptr == PatternGenerator.MAX_BUF_LEN));
+ } while (! (this.bufptr == this.maxBufLen));
this.output.printf("%c\n", ' ');
throw new HyphenationException("Bad character");
}
}
- } while (! (this.bufptr == PatternGenerator.MAX_BUF_LEN));
+ } while (! (this.bufptr == this.maxBufLen));
if (this.patlen > 0) {
int forEnd;
i = 0;
@@ -2001,7 +2010,7 @@
do {
this.bufptr = this.bufptr + 1;
this.output.print(this.buf[this.bufptr]);
- } while (! (this.bufptr == PatternGenerator.MAX_BUF_LEN));
+ } while (! (this.bufptr == this.maxBufLen));
this.output.printf("%c\n", ' ');
throw new HyphenationException("Bad edge_of_word");
}
@@ -2037,15 +2046,15 @@
this.output.print("hyph_start, hyph_finish: ");
input2ints();
if ((this.n1 >= 1)
- && (this.n1 < PatternGenerator.MAX_VAL)
+ && (this.n1 < this.maxVal)
&& (this.n2 >= 1)
- && (this.n2 < PatternGenerator.MAX_VAL)) {
+ && (this.n2 < this.maxVal)) {
this.hyphstart = this.n1;
this.hyphfinish = this.n2;
} else {
this.n1 = 0;
this.output.printf("%s%ld%s\n", "Specify 1<=hyph_start,hyph_finish<=",
- (long) PatternGenerator.MAX_VAL - 1, " !");
+ (long) this.maxVal - 1, " !");
}
} while (! (this.n1 > 0));
this.hyphlevel = this.maxpat;
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFAnnotation.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFAnnotation.java 2009-08-27 19:53:43 UTC (rev 10892)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFAnnotation.java 2009-10-11 18:18:24 UTC (rev 10893)
@@ -41,7 +41,7 @@
/**
* Create objects associated with a link annotation (GoToR).
*
- * @param doc {@inheritDoc}
+ * @param doc The PDF document being built.
* @param r The rectangle which outlines the link.
*/
public PDFAnnotation(final PDFDocument doc, final Rectangle2D r) {
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFBorderStyle.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFBorderStyle.java 2009-08-27 19:53:43 UTC (rev 10892)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFBorderStyle.java 2009-10-11 18:18:24 UTC (rev 10893)
@@ -85,7 +85,7 @@
/**
* Create a PDFBorderStyle object.
- * @param doc {@inheritDoc}
+ * @param doc The PDF document being built.
* @param width The width, in points, of the border to be drawn. A width
* of 0 disables border drawing.
* @param style The border style to be applied.
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPage.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPage.java 2009-08-27 19:53:43 UTC (rev 10892)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPage.java 2009-10-11 18:18:24 UTC (rev 10893)
@@ -72,7 +72,7 @@
/**
* Create a /Page object.
- * @param doc {@inheritDoc}
+ * @param doc The PDF document being built.
* @param resources the /Resources object
* @param pagewidth the page's width in points
* @param pageheight the page's height in points
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPages.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPages.java 2009-08-27 19:53:43 UTC (rev 10892)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPages.java 2009-10-11 18:18:24 UTC (rev 10893)
@@ -56,7 +56,7 @@
* can refer to the parent) so that the XRef table needs to
* be updated before this object is written.
*
- * @param doc {@inheritDoc}
+ * @param doc The PDF document being built.
*/
public PDFPages(final PDFDocument doc) {
super(doc);
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPattern.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPattern.java 2009-08-27 19:53:43 UTC (rev 10892)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPattern.java 2009-10-11 18:18:24 UTC (rev 10893)
@@ -93,7 +93,7 @@
/**
* Create a tiling pattern (type 1).
*
- * @param doc {@inheritDoc}
+ * @param doc The PDF document being built.
* @param theResources the resources associated with this pattern
* @param thePatternType the type of pattern, which is 1 for tiling.
* @param thePaintType 1 or 2, colored or uncolored.
@@ -133,7 +133,7 @@
/**
* Create a type 2 pattern (smooth shading).
- * @param doc {@inheritDoc}
+ * @param doc The PDF document being built.
* @param thePatternType the type of the pattern, which is 2, smooth shading
* @param theShading the PDF Shading object that comprises this pattern
* @param theXUID optional:the extended unique Identifier if used.
Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java
===================================================================
--- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2009-08-27 19:53:43 UTC (rev 10892)
+++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2009-10-11 18:18:24 UTC (rev 10893)
@@ -864,14 +864,6 @@
}
/**
- * Returns the number of items in the queue.
- * @return The number of items in the queue.
- */
- protected int size() {
- return this.toWriteQueue.size();
- }
-
- /**
* Adds ...
[truncated message content] |
|
From: <vic...@us...> - 2010-01-05 14:49:32
|
Revision: 10895
http://foray.svn.sourceforge.net/foray/?rev=10895&view=rev
Author: victormote
Date: 2010-01-05 14:49:09 +0000 (Tue, 05 Jan 2010)
Log Message:
-----------
Fix some scripting bugs related to error handling.
Modified Paths:
--------------
trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java
trunk/foray/scripts/foray-pretty.bat
Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java
===================================================================
--- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2010-01-05 06:22:32 UTC (rev 10894)
+++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2010-01-05 14:49:09 UTC (rev 10895)
@@ -1184,15 +1184,14 @@
try {
processor.start();
} catch (final IOException e) {
- System.out.print("Error parsing input.");
- e.printStackTrace();
+ System.out.println("Error parsing " + input + ": " + e.getClass().getName() + ": " + e.getMessage());
System.exit(FOrayPretty.STATUS_PARSING_ERROR);
} catch (final ParserConfigurationException e) {
- System.out.print("Error parsing input.");
+ System.out.println("Error parsing input.");
e.printStackTrace();
System.exit(FOrayPretty.STATUS_PARSING_ERROR);
} catch (final SAXException e) {
- System.out.print("Error parsing input.");
+ System.out.println("Error parsing input.");
e.printStackTrace();
System.exit(FOrayPretty.STATUS_PARSING_ERROR);
}
Modified: trunk/foray/scripts/foray-pretty.bat
===================================================================
--- trunk/foray/scripts/foray-pretty.bat 2010-01-05 06:22:32 UTC (rev 10894)
+++ trunk/foray/scripts/foray-pretty.bat 2010-01-05 14:49:09 UTC (rev 10895)
@@ -5,6 +5,7 @@
rem The purpose of this script is to run the FOray pretty-printer on a given
rem file, put the output into a temp file, then copy the temp file to the
rem original file.
+rem The three parameters to this script are as follows:
set FORAY_HOME=%1
set INPUT_NAME=%2
@@ -22,7 +23,8 @@
rem Run the pretty-printer.
set COMMAND=java -cp %FORAY_CP% %CLASS% %INPUT_NAME% %TEMP_NAME% %CATALOG%
%COMMAND%
-if errorlevel 0 goto :verify
+rem echo Error Level is %errorlevel%
+if %errorlevel% 0 goto :verify
echo Pretty-print failed with exit code %errorlevel%.
exit errorlevel
@@ -32,7 +34,7 @@
set CLASS=org.foray.pretty.FOrayXDiff
set COMMAND=java -cp %FORAY_CP% %CLASS% %INPUT_NAME% %TEMP_NAME%
%COMMAND%
-if errorlevel 0 goto :copy
+if %errorlevel% 0 goto :copy
echo Unintended changes detected, pretty-print failed with exit code %errorlevel%.
exit errorlevel
@@ -40,7 +42,7 @@
rem Copy the pretty version over the original.
echo Replacing %INPUT_NAME% with pretty-printed version.
copy %TEMP_NAME% %INPUT_NAME%
-if errorlevel 0 goto :delete
+if %errorlevel% 0 goto :delete
echo Copy failed. The temporary file will not be deleted. Exit code %errorlevel%.
exit errorlevel
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2010-01-30 01:05:55
|
Revision: 10898
http://foray.svn.sourceforge.net/foray/?rev=10898&view=rev
Author: victormote
Date: 2010-01-30 01:05:48 +0000 (Sat, 30 Jan 2010)
Log Message:
-----------
Upgrade to checkstyle 5.0.
Modified Paths:
--------------
trunk/foray/foray-app/.project
trunk/foray/foray-areatree/.project
trunk/foray/foray-common/.project
trunk/foray/foray-core/.project
trunk/foray/foray-font/.project
trunk/foray/foray-fotree/.project
trunk/foray/foray-graphic/.project
trunk/foray/foray-hyphen/.project
trunk/foray/foray-layout/.project
trunk/foray/foray-mif/.project
trunk/foray/foray-output/.project
trunk/foray/foray-pdf/.project
trunk/foray/foray-pioneer/.project
trunk/foray/foray-pretty/.project
trunk/foray/foray-ps/.project
trunk/foray/foray-render/.project
trunk/foray/foray-speech/.project
trunk/foray/foray-text/.project
trunk/foray/scripts/checkstyle-config.xml
Modified: trunk/foray/foray-app/.project
===================================================================
--- trunk/foray/foray-app/.project 2010-01-29 23:03:44 UTC (rev 10897)
+++ trunk/foray/foray-app/.project 2010-01-30 01:05:48 UTC (rev 10898)
@@ -17,13 +17,13 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
Modified: trunk/foray/foray-areatree/.project
===================================================================
--- trunk/foray/foray-areatree/.project 2010-01-29 23:03:44 UTC (rev 10897)
+++ trunk/foray/foray-areatree/.project 2010-01-30 01:05:48 UTC (rev 10898)
@@ -11,13 +11,13 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
Modified: trunk/foray/foray-common/.project
===================================================================
--- trunk/foray/foray-common/.project 2010-01-29 23:03:44 UTC (rev 10897)
+++ trunk/foray/foray-common/.project 2010-01-30 01:05:48 UTC (rev 10898)
@@ -11,13 +11,13 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
Modified: trunk/foray/foray-core/.project
===================================================================
--- trunk/foray/foray-core/.project 2010-01-29 23:03:44 UTC (rev 10897)
+++ trunk/foray/foray-core/.project 2010-01-30 01:05:48 UTC (rev 10898)
@@ -11,13 +11,13 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
Modified: trunk/foray/foray-font/.project
===================================================================
--- trunk/foray/foray-font/.project 2010-01-29 23:03:44 UTC (rev 10897)
+++ trunk/foray/foray-font/.project 2010-01-30 01:05:48 UTC (rev 10898)
@@ -13,13 +13,13 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
Modified: trunk/foray/foray-fotree/.project
===================================================================
--- trunk/foray/foray-fotree/.project 2010-01-29 23:03:44 UTC (rev 10897)
+++ trunk/foray/foray-fotree/.project 2010-01-30 01:05:48 UTC (rev 10898)
@@ -11,13 +11,13 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
Modified: trunk/foray/foray-graphic/.project
===================================================================
--- trunk/foray/foray-graphic/.project 2010-01-29 23:03:44 UTC (rev 10897)
+++ trunk/foray/foray-graphic/.project 2010-01-30 01:05:48 UTC (rev 10898)
@@ -12,13 +12,13 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
Modified: trunk/foray/foray-hyphen/.project
===================================================================
--- trunk/foray/foray-hyphen/.project 2010-01-29 23:03:44 UTC (rev 10897)
+++ trunk/foray/foray-hyphen/.project 2010-01-30 01:05:48 UTC (rev 10898)
@@ -11,13 +11,13 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
Modified: trunk/foray/foray-layout/.project
===================================================================
--- trunk/foray/foray-layout/.project 2010-01-29 23:03:44 UTC (rev 10897)
+++ trunk/foray/foray-layout/.project 2010-01-30 01:05:48 UTC (rev 10898)
@@ -11,13 +11,13 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
Modified: trunk/foray/foray-mif/.project
===================================================================
--- trunk/foray/foray-mif/.project 2010-01-29 23:03:44 UTC (rev 10897)
+++ trunk/foray/foray-mif/.project 2010-01-30 01:05:48 UTC (rev 10898)
@@ -11,13 +11,13 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
Modified: trunk/foray/foray-output/.project
===================================================================
--- trunk/foray/foray-output/.project 2010-01-29 23:03:44 UTC (rev 10897)
+++ trunk/foray/foray-output/.project 2010-01-30 01:05:48 UTC (rev 10898)
@@ -11,13 +11,13 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
Modified: trunk/foray/foray-pdf/.project
===================================================================
--- trunk/foray/foray-pdf/.project 2010-01-29 23:03:44 UTC (rev 10897)
+++ trunk/foray/foray-pdf/.project 2010-01-30 01:05:48 UTC (rev 10898)
@@ -15,13 +15,13 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
Modified: trunk/foray/foray-pioneer/.project
===================================================================
--- trunk/foray/foray-pioneer/.project 2010-01-29 23:03:44 UTC (rev 10897)
+++ trunk/foray/foray-pioneer/.project 2010-01-30 01:05:48 UTC (rev 10898)
@@ -11,13 +11,13 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
Modified: trunk/foray/foray-pretty/.project
===================================================================
--- trunk/foray/foray-pretty/.project 2010-01-29 23:03:44 UTC (rev 10897)
+++ trunk/foray/foray-pretty/.project 2010-01-30 01:05:48 UTC (rev 10898)
@@ -11,13 +11,13 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
Modified: trunk/foray/foray-ps/.project
===================================================================
--- trunk/foray/foray-ps/.project 2010-01-29 23:03:44 UTC (rev 10897)
+++ trunk/foray/foray-ps/.project 2010-01-30 01:05:48 UTC (rev 10898)
@@ -12,13 +12,13 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
Modified: trunk/foray/foray-render/.project
===================================================================
--- trunk/foray/foray-render/.project 2010-01-29 23:03:44 UTC (rev 10897)
+++ trunk/foray/foray-render/.project 2010-01-30 01:05:48 UTC (rev 10898)
@@ -11,13 +11,13 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
Modified: trunk/foray/foray-speech/.project
===================================================================
--- trunk/foray/foray-speech/.project 2010-01-29 23:03:44 UTC (rev 10897)
+++ trunk/foray/foray-speech/.project 2010-01-30 01:05:48 UTC (rev 10898)
@@ -11,13 +11,13 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
Modified: trunk/foray/foray-text/.project
===================================================================
--- trunk/foray/foray-text/.project 2010-01-29 23:03:44 UTC (rev 10897)
+++ trunk/foray/foray-text/.project 2010-01-30 01:05:48 UTC (rev 10898)
@@ -11,13 +11,13 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
Modified: trunk/foray/scripts/checkstyle-config.xml
===================================================================
--- trunk/foray/scripts/checkstyle-config.xml 2010-01-29 23:03:44 UTC (rev 10897)
+++ trunk/foray/scripts/checkstyle-config.xml 2010-01-30 01:05:48 UTC (rev 10898)
@@ -16,6 +16,17 @@
<property name="file" value="${foray.sandbox}/scripts/checkstyle-suppressions.xml"/>
</module>
+ <module name="FileTabCharacter">
+ <property name="severity" value="warning"/>
+ </module>
+
+ <module name="RegexpHeader">
+ <property name="headerFile" value="${foray.sandbox}/scripts/checkstyle-header-java.txt"/>
+ </module>
+
+ <!-- Make sure each package has javadoc package.html -->
+ <module name="JavadocPackage"/>
+
<!-- Allow otherwise Illegal Types to be used in certain circumstances. -->
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="Checkstyle-IllegalType-Off"/>
@@ -29,7 +40,7 @@
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="Checkstyle-GenericIllegalRegexp-Off"/>
<property name="onCommentFormat" value="Checkstyle-GenericIllegalRegexp-On"/>
- <property name="checkFormat" value="GenericIllegalRegexp"/>
+ <property name="checkFormat" value="RegexpSinglelineJava"/>
</module>
<!-- Allow test methods to use magic numbers. -->
@@ -86,9 +97,6 @@
<property name="tokens" value="CTOR_CALL, LPAREN, METHOD_CALL, RPAREN,
SUPER_CTOR_CALL"/>
</module>
- <module name="TabCharacter">
- <property name="severity" value="warning"/>
- </module>
<module name="FinalLocalVariable">
<property name="tokens" value="VARIABLE_DEF,PARAMETER_DEF"/>
</module>
@@ -149,10 +157,6 @@
<!-- Skip for now. The Ant build chokes on this. -->
<!--<module name="j2ee.FinalStatic"/>-->
- <module name="RegexpHeader">
- <property name="headerFile" value="${foray.sandbox}/scripts/checkstyle-header-java.txt"/>
- </module>
-
<!-- Leave this one off. We use "RequireThis" to distinguish local variables
and parameters from instance variables. -->
<!--<module name="HiddenField"/>-->
@@ -219,46 +223,46 @@
<property name="severity" value="ignore"/>
</module>
- <module name="GenericIllegalRegexp">
+ <module name="RegexpSinglelineJava">
<property name="ignoreComments" value="false"/>
<property name="format" value="\s+$"/>
<property name="message" value="Line has trailing spaces."/>
</module>
- <module name="GenericIllegalRegexp">
+ <module name="RegexpSinglelineJava">
<property name="ignoreComments" value="true"/>
<!-- . matches any character, so we need to escape it and use \. to match dots. -->
<property name="format" value="System\.exit"/>
<property name="message" value="Never exit the jvm, except in void main(String[])."/>
</module>
- <module name="GenericIllegalRegexp">
+ <module name="RegexpSinglelineJava">
<property name="ignoreComments" value="true"/>
<property name="format" value="printStackTrace"/>
<property name="message" value="Do not dump a stacktrace, except in void main(String[])."/>
</module>
- <module name="GenericIllegalRegexp">
+ <module name="RegexpSinglelineJava">
<property name="ignoreComments" value="true"/>
<property name="format" value=" System.out.print"/>
<property name="message" value="Use logging instead of System.out, except in void
main(String[])."/>
</module>
- <module name="GenericIllegalRegexp">
+ <module name="RegexpSinglelineJava">
<property name="ignoreComments" value="true"/>
<property name="format" value=" System.err.print"/>
<property name="message" value="Use logging instead of System.err, except in void
main(String[])."/>
</module>
- <module name="GenericIllegalRegexp">
+ <module name="RegexpSinglelineJava">
<property name="ignoreComments" value="true"/>
<property name="format" value="(FOP|fop|Fop)"/>
<property name="message" value="Avoid legacy references to FOP."/>
</module>
- <module name="GenericIllegalRegexp">
+ <module name="RegexpSinglelineJava">
<property name="ignoreComments" value="false"/>
<property name="format" value="Object clone()"/>
<property name="message" value="Return a more specific type when cloning."/>
@@ -266,9 +270,6 @@
</module>
- <!-- Make sure each package has javadoc package.html -->
- <module name="PackageHtml"/>
-
<!-- Make sure each file ends with a newline. -->
<module name="NewlineAtEndOfFile"/>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2010-01-30 17:38:12
|
Revision: 10899
http://foray.svn.sourceforge.net/foray/?rev=10899&view=rev
Author: victormote
Date: 2010-01-30 17:37:15 +0000 (Sat, 30 Jan 2010)
Log Message:
-----------
Remove deprecated package.html javadoc files in favor of new package-info.java files.
Modified Paths:
--------------
trunk/foray/scripts/checkstyle-suppressions.xml
Added Paths:
-----------
trunk/foray/foray-app/src/java/org/foray/app/ant/package-info.java
trunk/foray/foray-app/src/java/org/foray/app/package-info.java
trunk/foray/foray-app/src/java/org/foray/app/test/package-info.java
trunk/foray/foray-app/src/java/org/foray/demo/embed/model/package-info.java
trunk/foray/foray-app/src/java/org/foray/demo/embed/package-info.java
trunk/foray/foray-app/src/java/org/foray/demo/embed/tools/package-info.java
trunk/foray/foray-app/src/java/org/foray/demo/package-info.java
trunk/foray/foray-app/src/java/org/foray/demo/servlet/package-info.java
trunk/foray/foray-areatree/src/java/org/foray/area/package-info.java
trunk/foray/foray-common/src/java/org/foray/common/package-info.java
trunk/foray/foray-common/src/java/org/foray/common/ps/package-info.java
trunk/foray/foray-common/src/java/org/foray/common/sax/package-info.java
trunk/foray/foray-common/src/java/org/foray/common/url/classpath/package-info.java
trunk/foray/foray-common/src/java/org/foray/common/url/package-info.java
trunk/foray/foray-core/src/java/org/foray/core/package-info.java
trunk/foray/foray-font/src/java/org/foray/font/format/package-info.java
trunk/foray/foray-font/src/java/org/foray/font/output/package-info.java
trunk/foray/foray-font/src/java/org/foray/font/package-info.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/axsl/obj/package-info.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/axsl/package-info.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/axsl/prop/package-info.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/enums/package-info.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/package-info.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/package-info.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/package-info.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/foray/package-info.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/math/obj/package-info.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/math/package-info.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/package-info.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/parse/package-info.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/obj/package-info.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/package-info.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/package-info.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/xml/package-info.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/xml/prop/package-info.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/package-info.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/package-info.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/math/package-info.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/output/package-info.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/package-info.java
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/package-info.java
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/util/package-info.java
trunk/foray/foray-layout/src/java/org/foray/layout/package-info.java
trunk/foray/foray-mif/src/java/org/foray/mif/package-info.java
trunk/foray/foray-output/src/java/org/foray/output/package-info.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/package-info.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/package-info.java
trunk/foray/foray-pioneer/src/java/org/foray/pioneer/package-info.java
trunk/foray/foray-pretty/src/java/org/foray/pretty/dtd/package-info.java
trunk/foray/foray-pretty/src/java/org/foray/pretty/package-info.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/package-info.java
trunk/foray/foray-ps/src/java/org/foray/ps/filter/package-info.java
trunk/foray/foray-ps/src/java/org/foray/ps/java2d/demo/package-info.java
trunk/foray/foray-ps/src/java/org/foray/ps/java2d/package-info.java
trunk/foray/foray-ps/src/java/org/foray/ps/package-info.java
trunk/foray/foray-ps/src/java/org/foray/ps/pdf/package-info.java
trunk/foray/foray-ps/src/java/org/foray/ps/readonly/package-info.java
trunk/foray/foray-ps/src/java/org/foray/ps/type1/package-info.java
trunk/foray/foray-render/src/java/org/foray/render/awt/package-info.java
trunk/foray/foray-render/src/java/org/foray/render/awt/viewer/package-info.java
trunk/foray/foray-render/src/java/org/foray/render/package-info.java
trunk/foray/foray-render/src/java/org/foray/render/pcl/package-info.java
trunk/foray/foray-render/src/java/org/foray/render/pdf/package-info.java
trunk/foray/foray-render/src/java/org/foray/render/ps/package-info.java
trunk/foray/foray-render/src/java/org/foray/render/svg/package-info.java
trunk/foray/foray-render/src/java/org/foray/render/txt/package-info.java
trunk/foray/foray-render/src/java/org/foray/render/xml/package-info.java
trunk/foray/foray-speech/src/java/org/foray/speech/package-info.java
trunk/foray/foray-text/src/java/org/foray/text/line/package-info.java
trunk/foray/foray-text/src/java/org/foray/text/line/solitary/package-info.java
trunk/foray/foray-text/src/java/org/foray/text/package-info.java
Removed Paths:
-------------
trunk/foray/foray-app/src/java/org/foray/app/ant/package.html
trunk/foray/foray-app/src/java/org/foray/app/package.html
trunk/foray/foray-app/src/java/org/foray/app/test/package.html
trunk/foray/foray-app/src/java/org/foray/demo/embed/model/package.html
trunk/foray/foray-app/src/java/org/foray/demo/embed/package.html
trunk/foray/foray-app/src/java/org/foray/demo/embed/tools/package.html
trunk/foray/foray-app/src/java/org/foray/demo/package.html
trunk/foray/foray-app/src/java/org/foray/demo/servlet/package.html
trunk/foray/foray-areatree/src/java/org/foray/area/package.html
trunk/foray/foray-common/src/java/org/foray/common/package.html
trunk/foray/foray-common/src/java/org/foray/common/ps/package.html
trunk/foray/foray-common/src/java/org/foray/common/sax/package.html
trunk/foray/foray-common/src/java/org/foray/common/url/classpath/package.html
trunk/foray/foray-common/src/java/org/foray/common/url/package.html
trunk/foray/foray-core/src/java/org/foray/core/package.html
trunk/foray/foray-font/src/java/org/foray/font/format/package.html
trunk/foray/foray-font/src/java/org/foray/font/output/package.html
trunk/foray/foray-font/src/java/org/foray/font/package.html
trunk/foray/foray-fotree/src/java/org/foray/fotree/axsl/obj/package.html
trunk/foray/foray-fotree/src/java/org/foray/fotree/axsl/package.html
trunk/foray/foray-fotree/src/java/org/foray/fotree/axsl/prop/package.html
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/enums/package.html
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/package.html
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/package.html
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/package.html
trunk/foray/foray-fotree/src/java/org/foray/fotree/foray/package.html
trunk/foray/foray-fotree/src/java/org/foray/fotree/math/obj/package.html
trunk/foray/foray-fotree/src/java/org/foray/fotree/math/package.html
trunk/foray/foray-fotree/src/java/org/foray/fotree/package.html
trunk/foray/foray-fotree/src/java/org/foray/fotree/parse/package.html
trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/obj/package.html
trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/package.html
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/package.html
trunk/foray/foray-fotree/src/java/org/foray/fotree/xml/package.html
trunk/foray/foray-fotree/src/java/org/foray/fotree/xml/prop/package.html
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/package.html
trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/package.html
trunk/foray/foray-graphic/src/java/org/foray/graphic/math/package.html
trunk/foray/foray-graphic/src/java/org/foray/graphic/output/package.html
trunk/foray/foray-graphic/src/java/org/foray/graphic/package.html
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/package.html
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/util/package.html
trunk/foray/foray-layout/src/java/org/foray/layout/package.html
trunk/foray/foray-mif/src/java/org/foray/mif/package.html
trunk/foray/foray-output/src/java/org/foray/output/package.html
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/package.html
trunk/foray/foray-pdf/src/java/org/foray/pdf/package.html
trunk/foray/foray-pioneer/src/java/org/foray/pioneer/package.html
trunk/foray/foray-pretty/src/java/org/foray/pretty/dtd/package.html
trunk/foray/foray-pretty/src/java/org/foray/pretty/package.html
trunk/foray/foray-ps/src/java/org/foray/ps/encode/package.html
trunk/foray/foray-ps/src/java/org/foray/ps/filter/package.html
trunk/foray/foray-ps/src/java/org/foray/ps/java2d/demo/package.html
trunk/foray/foray-ps/src/java/org/foray/ps/java2d/package.html
trunk/foray/foray-ps/src/java/org/foray/ps/package.html
trunk/foray/foray-ps/src/java/org/foray/ps/pdf/package.html
trunk/foray/foray-ps/src/java/org/foray/ps/readonly/package.html
trunk/foray/foray-ps/src/java/org/foray/ps/type1/package.html
trunk/foray/foray-render/src/java/org/foray/render/awt/package.html
trunk/foray/foray-render/src/java/org/foray/render/awt/viewer/package.html
trunk/foray/foray-render/src/java/org/foray/render/package.html
trunk/foray/foray-render/src/java/org/foray/render/pcl/package.html
trunk/foray/foray-render/src/java/org/foray/render/pdf/package.html
trunk/foray/foray-render/src/java/org/foray/render/ps/package.html
trunk/foray/foray-render/src/java/org/foray/render/svg/package.html
trunk/foray/foray-render/src/java/org/foray/render/txt/package.html
trunk/foray/foray-render/src/java/org/foray/render/xml/package.html
trunk/foray/foray-speech/src/java/org/foray/speech/package.html
trunk/foray/foray-text/src/java/org/foray/text/line/package.html
trunk/foray/foray-text/src/java/org/foray/text/line/solitary/package.html
trunk/foray/foray-text/src/java/org/foray/text/package.html
Copied: trunk/foray/foray-app/src/java/org/foray/app/ant/package-info.java (from rev 10892, trunk/foray/foray-app/src/java/org/foray/app/ant/package.html)
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/app/ant/package-info.java (rev 0)
+++ trunk/foray/foray-app/src/java/org/foray/app/ant/package-info.java 2010-01-30 17:37:15 UTC (rev 10899)
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2010 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$
+ */
+
+/**
+ * <p>Classes for making FOray accessible from within Ant.</p>
+ */
+
+package org.foray.app.ant;
Deleted: trunk/foray/foray-app/src/java/org/foray/app/ant/package.html
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/app/ant/package.html 2010-01-30 01:05:48 UTC (rev 10898)
+++ trunk/foray/foray-app/src/java/org/foray/app/ant/package.html 2010-01-30 17:37:15 UTC (rev 10899)
@@ -1,6 +0,0 @@
-<html>
-<title>Package org.foray.app.ant</title>
-<body>
-<p>Classes for making FOray accessible from within Ant.</p>
-</body>
-</html>
\ No newline at end of file
Copied: trunk/foray/foray-app/src/java/org/foray/app/package-info.java (from rev 10892, trunk/foray/foray-app/src/java/org/foray/app/package.html)
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/app/package-info.java (rev 0)
+++ trunk/foray/foray-app/src/java/org/foray/app/package-info.java 2010-01-30 17:37:15 UTC (rev 10899)
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2010 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$
+ */
+
+/**
+ * <p>Application classes used for running FOray both on the command line and embedded in other applications.</p>
+ */
+
+package org.foray.app;
Deleted: trunk/foray/foray-app/src/java/org/foray/app/package.html
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/app/package.html 2010-01-30 01:05:48 UTC (rev 10898)
+++ trunk/foray/foray-app/src/java/org/foray/app/package.html 2010-01-30 17:37:15 UTC (rev 10899)
@@ -1,7 +0,0 @@
-<html>
-<title>org.foray.app Package</title>
-<body>
-<p>Application classes used for running FOray both on the command line and
-embedded in other applications.</p>
-</body>
-</html>
Copied: trunk/foray/foray-app/src/java/org/foray/app/test/package-info.java (from rev 10892, trunk/foray/foray-app/src/java/org/foray/app/test/package.html)
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/app/test/package-info.java (rev 0)
+++ trunk/foray/foray-app/src/java/org/foray/app/test/package-info.java 2010-01-30 17:37:15 UTC (rev 10899)
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2010 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$
+ */
+
+/**
+ * <p>Classes useful for testing the FOray application and its various modules.</p>
+ */
+
+package org.foray.app.test;
Deleted: trunk/foray/foray-app/src/java/org/foray/app/test/package.html
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/app/test/package.html 2010-01-30 01:05:48 UTC (rev 10898)
+++ trunk/foray/foray-app/src/java/org/foray/app/test/package.html 2010-01-30 17:37:15 UTC (rev 10899)
@@ -1,6 +0,0 @@
-<html>
-<title>org.foray.app.test Package</title>
-<body>
-<p>Classes useful for testing the FOray application and its various modules.</p>
-</body>
-</html>
Copied: trunk/foray/foray-app/src/java/org/foray/demo/embed/model/package-info.java (from rev 10892, trunk/foray/foray-app/src/java/org/foray/demo/embed/model/package.html)
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/demo/embed/model/package-info.java (rev 0)
+++ trunk/foray/foray-app/src/java/org/foray/demo/embed/model/package-info.java 2010-01-30 17:37:15 UTC (rev 10899)
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2010 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$
+ */
+
+/**
+ * <p>A sample application demonstrating use of FOray embedded in another application.</p>
+ */
+
+package org.foray.demo.embed.model;
Deleted: trunk/foray/foray-app/src/java/org/foray/demo/embed/model/package.html
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/demo/embed/model/package.html 2010-01-30 01:05:48 UTC (rev 10898)
+++ trunk/foray/foray-app/src/java/org/foray/demo/embed/model/package.html 2010-01-30 17:37:15 UTC (rev 10899)
@@ -1,7 +0,0 @@
-<html>
-<title>org.foray.font Package</title>
-<body>
-<p>A sample application demonstrating use of FOray embedded in another
-application.</p>
-</body>
-</html>
Copied: trunk/foray/foray-app/src/java/org/foray/demo/embed/package-info.java (from rev 10892, trunk/foray/foray-app/src/java/org/foray/demo/embed/package.html)
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/demo/embed/package-info.java (rev 0)
+++ trunk/foray/foray-app/src/java/org/foray/demo/embed/package-info.java 2010-01-30 17:37:15 UTC (rev 10899)
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2010 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$
+ */
+
+/**
+ * <p>Classes useful for demonstrating FOray embedded in other applications.</p>
+ */
+
+package org.foray.demo.embed;
Deleted: trunk/foray/foray-app/src/java/org/foray/demo/embed/package.html
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/demo/embed/package.html 2010-01-30 01:05:48 UTC (rev 10898)
+++ trunk/foray/foray-app/src/java/org/foray/demo/embed/package.html 2010-01-30 17:37:15 UTC (rev 10899)
@@ -1,6 +0,0 @@
-<html>
-<title>org.foray.font Package</title>
-<body>
-<p>Classes useful for demonstrating FOray embedded in other applications.</p>
-</body>
-</html>
Copied: trunk/foray/foray-app/src/java/org/foray/demo/embed/tools/package-info.java (from rev 10892, trunk/foray/foray-app/src/java/org/foray/demo/embed/tools/package.html)
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/demo/embed/tools/package-info.java (rev 0)
+++ trunk/foray/foray-app/src/java/org/foray/demo/embed/tools/package-info.java 2010-01-30 17:37:15 UTC (rev 10899)
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2010 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$
+ */
+
+/**
+ * <p>Utility classes useful when embedding FOray in other applications.</p>
+ */
+
+package org.foray.demo.embed.tools;
Deleted: trunk/foray/foray-app/src/java/org/foray/demo/embed/tools/package.html
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/demo/embed/tools/package.html 2010-01-30 01:05:48 UTC (rev 10898)
+++ trunk/foray/foray-app/src/java/org/foray/demo/embed/tools/package.html 2010-01-30 17:37:15 UTC (rev 10899)
@@ -1,6 +0,0 @@
-<html>
-<title>org.foray.font Package</title>
-<body>
-<p>Utility classes useful when embedding FOray in other applications.</p>
-</body>
-</html>
Copied: trunk/foray/foray-app/src/java/org/foray/demo/package-info.java (from rev 10892, trunk/foray/foray-app/src/java/org/foray/demo/package.html)
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/demo/package-info.java (rev 0)
+++ trunk/foray/foray-app/src/java/org/foray/demo/package-info.java 2010-01-30 17:37:15 UTC (rev 10899)
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2010 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$
+ */
+
+/**
+ * <p>Classes useful for demonstrating FOray's capabilities, which may be useful superclasses for actual
+ * applications.</p>
+ */
+
+package org.foray.demo;
Deleted: trunk/foray/foray-app/src/java/org/foray/demo/package.html
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/demo/package.html 2010-01-30 01:05:48 UTC (rev 10898)
+++ trunk/foray/foray-app/src/java/org/foray/demo/package.html 2010-01-30 17:37:15 UTC (rev 10899)
@@ -1,7 +0,0 @@
-<html>
-<title>org.foray.font Package</title>
-<body>
-<p>Classes useful for demonstrating FOray's capabilities, which may be useful
-superclasses for actual applications.</p>
-</body>
-</html>
Copied: trunk/foray/foray-app/src/java/org/foray/demo/servlet/package-info.java (from rev 10892, trunk/foray/foray-app/src/java/org/foray/demo/servlet/package.html)
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/demo/servlet/package-info.java (rev 0)
+++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/package-info.java 2010-01-30 17:37:15 UTC (rev 10899)
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2010 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$
+ */
+
+/**
+ * <p>Classes demonstrating use of FOray as a servlet.</p>
+ */
+
+package org.foray.demo.servlet;
Deleted: trunk/foray/foray-app/src/java/org/foray/demo/servlet/package.html
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/demo/servlet/package.html 2010-01-30 01:05:48 UTC (rev 10898)
+++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/package.html 2010-01-30 17:37:15 UTC (rev 10899)
@@ -1,6 +0,0 @@
-<html>
-<title>org.foray.font Package</title>
-<body>
-<p>Classes demonstrating use of FOray as a servlet.</p>
-</body>
-</html>
Copied: trunk/foray/foray-areatree/src/java/org/foray/area/package-info.java (from rev 10892, trunk/foray/foray-areatree/src/java/org/foray/area/package.html)
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/package-info.java (rev 0)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/package-info.java 2010-01-30 17:37:15 UTC (rev 10899)
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2010 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$
+ */
+
+/**
+ * <p>Classes representing the actual layout of content on pages.</p>
+ */
+
+package org.foray.area;
Deleted: trunk/foray/foray-areatree/src/java/org/foray/area/package.html
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/package.html 2010-01-30 01:05:48 UTC (rev 10898)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/package.html 2010-01-30 17:37:15 UTC (rev 10899)
@@ -1,6 +0,0 @@
-<html>
-<title>Package org.foray.area</title>
-<body>
-<p>Classes representing the actual layout of content on pages.</p>
-</body>
-</html>
Copied: trunk/foray/foray-common/src/java/org/foray/common/package-info.java (from rev 10892, trunk/foray/foray-common/src/java/org/foray/common/package.html)
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/package-info.java (rev 0)
+++ trunk/foray/foray-common/src/java/org/foray/common/package-info.java 2010-01-30 17:37:15 UTC (rev 10899)
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2010 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
+ *
+ */
+
+/*
+ * $LastChangedRevis...
[truncated message content] |
|
From: <vic...@us...> - 2010-01-31 18:07:27
|
Revision: 10901
http://foray.svn.sourceforge.net/foray/?rev=10901&view=rev
Author: victormote
Date: 2010-01-31 18:07:21 +0000 (Sun, 31 Jan 2010)
Log Message:
-----------
Work around problems with some parsers not knowing how to handle entities declared in the DTD.
Modified Paths:
--------------
trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java
trunk/foray/scripts/foray-pretty.bat
Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java
===================================================================
--- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2010-01-30 19:13:42 UTC (rev 10900)
+++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2010-01-31 18:07:21 UTC (rev 10901)
@@ -44,6 +44,7 @@
import javax.xml.namespace.QName;
import javax.xml.stream.Location;
import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLResolver;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
@@ -92,12 +93,13 @@
/**
* Constructor accepting URLs to compare.
* @param urls An array of URLs to be compared.
+ * @param catalog The location of a catalog file that should be used to find the DTD for this document.
* @throws IOException For errors opening the files.
* @throws XMLStreamException For errors parsing the files.
- * @see #FOrayXDiff(InputStream[]) For a constructor that takes any
+ * @see #FOrayXDiff(InputStream[], String) For a constructor that takes any
* {@link InputStream}.
*/
- public FOrayXDiff(final URL[] urls) throws IOException, XMLStreamException {
+ public FOrayXDiff(final URL[] urls, final String catalog) throws IOException, XMLStreamException {
if (urls == null) {
throw new NullPointerException("No URLs to compare.");
}
@@ -110,28 +112,30 @@
streams[i] = in;
this.readerIDs[i] = urls[i].toExternalForm();
}
- convertStreams(streams);
+ convertStreams(catalog, streams);
}
/**
* Constructor accepting InputStreams to compare.
* @param streams An array of InputStreams to be compared.
+ * @param catalog The location of a catalog file that should be used to find the DTD for this document.
* @throws XMLStreamException For errors during the diff.
- * @see #FOrayXDiff(URL[]) For a constructor that takes {@link URL}s.
+ * @see #FOrayXDiff(URL[], String) For a constructor that takes {@link URL}s.
*/
- public FOrayXDiff(final InputStream[] streams) throws XMLStreamException {
+ public FOrayXDiff(final InputStream[] streams, final String catalog) throws XMLStreamException {
if (this.readerIDs == null) {
this.readerIDs = new String[streams.length];
}
- convertStreams(streams);
+ convertStreams(catalog, streams);
}
/**
* Converts the input streams to XMLStreamReaders for pull-parsing.
+ * @param catalog The location of a catalog file that should be used to find the DTD for this document.
* @param streams The input streams to convert.
* @throws XMLStreamException For error creating the {@link XMLStreamReader} instances.
*/
- private void convertStreams(final InputStream[] streams)
+ private void convertStreams(final String catalog, final InputStream[] streams)
throws XMLStreamException {
if (streams == null) {
throw new IllegalArgumentException("No InputStreams to compare.");
@@ -151,9 +155,21 @@
factory.setProperty("javax.xml.stream.isReplacingEntityReferences", Boolean.FALSE);
/* Turn off resolution of external entities. */
factory.setProperty("javax.xml.stream.isSupportingExternalEntities", Boolean.FALSE);
- /* Turn off DTD support. We think this will keep the parser from parsing the DTD. All we want is for the DTD
- * declaration to be the same. */
- factory.setProperty("javax.xml.stream.supportDTD", Boolean.FALSE);
+
+ /* The following setting is troublesome. We originally set it to TRUE. However, this seemed to make the parsers
+ * try to find the DTD and parse that, which in some cases causes what seemed like unnecessary network traffic
+ * (we don't really want the DTD parsed, we just want to know whether the references to it are identical).
+ * However, if we set it to FALSE, some JRE/JDKs will complain that the document has entities that are not
+ * declared, even when they are declared in the DTD. So it appears that this needs to be TRUE. See setting
+ * below where we allow a catalog to be used to alleviate the network traffic. */
+ factory.setProperty("javax.xml.stream.supportDTD", Boolean.TRUE);
+
+ if (! "null".equalsIgnoreCase(catalog)) {
+ final String[] catalogs = new String[] {catalog};
+ final XMLResolver resolver = XMLUtil.getXMLResolver(catalogs);
+ factory.setProperty("javax.xml.stream.resolver", resolver);
+ }
+
for (int i = 0; i < streams.length; i++) {
final InputStream in = streams[i];
this.readers[i] = factory.createXMLStreamReader(in);
@@ -598,12 +614,14 @@
* <li>3 (differences found between the two input files)</li>
* </ul>
*
- * @param args Two or more URLs that should be compared.
+ * @param args The first argument is the location of an XML catalog to be used to resolve DTDS.
+ * The remaining arguments are two or more URLs that should be compared.
*/
public static void main(final String[] args) {
/* Checkstyle-GenericIllegalRegexp-Off. */
- final InputStream[] streamsToCompare = new InputStream[args.length];
- for (int i = 0; i < args.length; i++) {
+ final String catalog = args[0];
+ final InputStream[] streamsToCompare = new InputStream[args.length - 1];
+ for (int i = 1; i < args.length; i++) {
InputStream stream = null;
try {
final File file = new File(args[i]);
@@ -612,10 +630,10 @@
System.out.println("File Not Found: " + args[i]);
System.exit(FOrayXDiff.STATUS_MALFORMED_URL);
}
- streamsToCompare[i] = stream;
+ streamsToCompare[i - 1] = stream;
}
try {
- final FOrayXDiff processor = new FOrayXDiff(streamsToCompare);
+ final FOrayXDiff processor = new FOrayXDiff(streamsToCompare, catalog);
final boolean equivalent = processor.equivalent();
if (equivalent) {
System.out.println("All XML Streams are equivalent.");
Modified: trunk/foray/scripts/foray-pretty.bat
===================================================================
--- trunk/foray/scripts/foray-pretty.bat 2010-01-30 19:13:42 UTC (rev 10900)
+++ trunk/foray/scripts/foray-pretty.bat 2010-01-31 18:07:21 UTC (rev 10901)
@@ -11,6 +11,7 @@
set INPUT_NAME=%2
set CATALOG=%3
+java -version
echo Start pretty-printing of %INPUT_NAME%.
rem Call an external script in a loop to add the lib jar files to the classpath.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2010-01-31 19:23:20
|
Revision: 10902
http://foray.svn.sourceforge.net/foray/?rev=10902&view=rev
Author: victormote
Date: 2010-01-31 19:23:13 +0000 (Sun, 31 Jan 2010)
Log Message:
-----------
Use Apache Commons CLI package to clean up the CLI for FOrayXDiff.
Modified Paths:
--------------
trunk/foray/foray-pretty/.classpath
trunk/foray/foray-pretty/scripts/build.xml
trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java
trunk/foray/scripts/foray-pretty.bat
Added Paths:
-----------
trunk/foray/lib/commons-cli-1.2.jar
trunk/foray/lib/commons-cli-license.txt
trunk/foray/lib-build/commons-cli/
trunk/foray/lib-build/commons-cli/commons-cli-1.2-sources.jar
Modified: trunk/foray/foray-pretty/.classpath
===================================================================
--- trunk/foray/foray-pretty/.classpath 2010-01-31 18:07:21 UTC (rev 10901)
+++ trunk/foray/foray-pretty/.classpath 2010-01-31 19:23:13 UTC (rev 10902)
@@ -7,5 +7,6 @@
<classpathentry kind="lib" path="/FOray Lib/stax-1.2.0.jar" sourcepath="/FOray Lib-Build/stax/stax-src-1.2.0.zip"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="lib" path="/FOray Lib/commons-cli-1.2.jar" sourcepath="/FOray Lib-Build/commons-cli/commons-cli-1.2-sources.jar"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-pretty/scripts/build.xml
===================================================================
--- trunk/foray/foray-pretty/scripts/build.xml 2010-01-31 18:07:21 UTC (rev 10901)
+++ trunk/foray/foray-pretty/scripts/build.xml 2010-01-31 19:23:13 UTC (rev 10902)
@@ -26,6 +26,7 @@
<include name="stax*.jar"/>
<include name="resolver*.jar"/>
<include name="commons-logging-*.jar"/>
+ <include name="commons-cli-*.jar"/>
</fileset>
<fileset dir="${foray.sandbox}/foray-common/build/ant">
<include name="*.jar"/>
Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java
===================================================================
--- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2010-01-31 18:07:21 UTC (rev 10901)
+++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2010-01-31 19:23:13 UTC (rev 10902)
@@ -32,6 +32,13 @@
import org.foray.common.StringUtil;
import org.foray.common.XMLUtil;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.PosixParser;
import org.apache.commons.logging.Log;
import java.io.File;
@@ -68,9 +75,12 @@
/** Command-line status constant indicating a parsing error. */
public static final byte STATUS_PARSING_ERROR = 2;
+ /** Command-line status constant indicating that the command line itself was not properly formed. */
+ public static final byte STATUS_COMMAND_LINE_ERROR = 4;
+
/** Command-line status constant indicating that a substantive difference
* between the two inputs was detected. */
- public static final byte STATUS_DIFFERENCE_FOUND = 3;
+ public static final byte STATUS_DIFFERENCE_FOUND = 99;
/** The pull parsers for the input documents. */
private XMLStreamReader[] readers;
@@ -164,7 +174,7 @@
* below where we allow a catalog to be used to alleviate the network traffic. */
factory.setProperty("javax.xml.stream.supportDTD", Boolean.TRUE);
- if (! "null".equalsIgnoreCase(catalog)) {
+ if (! (catalog == null)) {
final String[] catalogs = new String[] {catalog};
final XMLResolver resolver = XMLUtil.getXMLResolver(catalogs);
factory.setProperty("javax.xml.stream.resolver", resolver);
@@ -597,6 +607,22 @@
}
/**
+ * Returns the command-line options for the {@link #main(String[])} method.
+ * @return Command-line options.
+ */
+ private static Options getCommandLineOptions() {
+ final Options clOptions = new Options();
+ final Option catalog = new Option("c", "catalog", true, "path to the catalog file (optional)");
+ catalog.setRequired(false);
+ final Option files = new Option("f", "files", true, "paths to the files to be compared.");
+ files.setRequired(true);
+ files.setArgs(Option.UNLIMITED_VALUES);
+ clOptions.addOption(catalog);
+ clOptions.addOption(files);
+ return clOptions;
+ }
+
+ /**
* Command-line interface for {@link FOrayXDiff}.
*
* <p>Design Note: We use files instead of URLs here to more easily
@@ -619,18 +645,31 @@
*/
public static void main(final String[] args) {
/* Checkstyle-GenericIllegalRegexp-Off. */
- final String catalog = args[0];
- final InputStream[] streamsToCompare = new InputStream[args.length - 1];
- for (int i = 1; i < args.length; i++) {
+ final Options commandLineOptions = FOrayXDiff.getCommandLineOptions();
+ final CommandLineParser commandLineParser = new PosixParser();
+ CommandLine parsedCommandLine = null;
+ try {
+ parsedCommandLine = commandLineParser.parse(commandLineOptions, args);
+ } catch (final ParseException e) {
+ System.out.println(e.getMessage());
+ final HelpFormatter helpFormatter = new HelpFormatter();
+ helpFormatter.printHelp("java -cp $FORAY_CLASSPATH " + FOrayXDiff.class.getName(), commandLineOptions);
+ System.exit(FOrayXDiff.STATUS_COMMAND_LINE_ERROR);
+ }
+ final String catalog = parsedCommandLine.getOptionValue("catalog");
+ final String[] files = parsedCommandLine.getOptionValues("files");
+
+ final InputStream[] streamsToCompare = new InputStream[files.length];
+ for (int i = 0; i < files.length; i++) {
InputStream stream = null;
try {
- final File file = new File(args[i]);
+ final File file = new File(files[i]);
stream = new FileInputStream(file);
} catch (final FileNotFoundException e) {
- System.out.println("File Not Found: " + args[i]);
+ System.out.println("File Not Found: " + files[i]);
System.exit(FOrayXDiff.STATUS_MALFORMED_URL);
}
- streamsToCompare[i - 1] = stream;
+ streamsToCompare[i] = stream;
}
try {
final FOrayXDiff processor = new FOrayXDiff(streamsToCompare, catalog);
Added: trunk/foray/lib/commons-cli-1.2.jar
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib/commons-cli-1.2.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/foray/lib/commons-cli-license.txt
===================================================================
--- trunk/foray/lib/commons-cli-license.txt (rev 0)
+++ trunk/foray/lib/commons-cli-license.txt 2010-01-31 19:23:13 UTC (rev 10902)
@@ -0,0 +1,202 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
Added: trunk/foray/lib-build/commons-cli/commons-cli-1.2-sources.jar
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib-build/commons-cli/commons-cli-1.2-sources.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/foray/scripts/foray-pretty.bat
===================================================================
--- trunk/foray/scripts/foray-pretty.bat 2010-01-31 18:07:21 UTC (rev 10901)
+++ trunk/foray/scripts/foray-pretty.bat 2010-01-31 19:23:13 UTC (rev 10902)
@@ -34,7 +34,7 @@
rem Make sure the pretty-printed version has the same content as original.
echo Comparing content for unintended changes during pretty-print.
set CLASS=org.foray.pretty.FOrayXDiff
-set COMMAND=java -cp %FORAY_CP% %CLASS% %INPUT_NAME% %TEMP_NAME%
+set COMMAND=java -cp %FORAY_CP% %CLASS% --catalog %CATALOG% --files %INPUT_NAME% %TEMP_NAME%
%COMMAND%
echo End comparison.
if %errorlevel% == 0 goto :copy
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2010-01-31 19:56:29
|
Revision: 10904
http://foray.svn.sourceforge.net/foray/?rev=10904&view=rev
Author: victormote
Date: 2010-01-31 19:56:21 +0000 (Sun, 31 Jan 2010)
Log Message:
-----------
Use Apache Commons CLI package to clean up the CLI for FOrayPretty.
Modified Paths:
--------------
trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java
trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java
trunk/foray/scripts/foray-pretty.bat
Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java
===================================================================
--- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2010-01-31 19:31:25 UTC (rev 10903)
+++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2010-01-31 19:56:21 UTC (rev 10904)
@@ -34,6 +34,13 @@
import org.foray.pretty.dtd.DTDElement;
import org.foray.pretty.dtd.ElementStack;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.PosixParser;
import org.apache.commons.logging.Log;
import org.xml.sax.Attributes;
@@ -67,28 +74,19 @@
*/
public class FOrayPretty extends DefaultHandler2 {
- /** Command-line return status constant indicating that the number of
- * arguments is wrong. */
- public static final byte STATUS_WRONG_QTY_ARGUMENTS = 1;
+ /** Command-line status constant indicating that the command line itself was not properly formed. */
+ public static final byte STATUS_COMMAND_LINE_ERROR = 1;
- /** Command-line return status constant indicating that a file was not
- * found. */
+ /** Command-line return status constant indicating that a file was not found. */
public static final byte STATUS_FILE_NOT_FOUND = 2;
- /** Command-line return status constant indicating that there was a parsing
- * error. */
+ /** Command-line return status constant indicating that there was an error parsing the input file. */
public static final byte STATUS_PARSING_ERROR = 3;
/** The default line length that should be used in the pretty-printed
* output. */
private static final byte DEFAULT_LINE_LENGTH = 80;
- /** The minimum number of command-line arguments. */
- private static final byte MIN_CL_ARGUMENTS = 2;
-
- /** The maximum number of command-line arguments. */
- private static final byte MAX_CL_ARGUMENTS = 3;
-
/** The input source to be pretty-printed. */
private InputSource input;
@@ -191,12 +189,15 @@
* @param input The input source encapsulating the document to be pretty-printed.
* @param output The output stream to which the pretty-printed document should be sent.
* @param catalog The location of a catalog file that should be used to find the DTD for this document.
+ * This may be null.
*/
public FOrayPretty(final InputSource input, final OutputStream output, final String catalog) {
this.input = input;
this.output = output;
- final String [] catalogs = {catalog};
- this.entityResolver = XMLUtil.getEntityResolver(catalogs);
+ if (catalog != null) {
+ final String [] catalogs = {catalog};
+ this.entityResolver = XMLUtil.getEntityResolver(catalogs);
+ }
/* Set the line terminator to the default for this operating system. */
this.lineTerminator = System.getProperty("line.separator");
@@ -1217,6 +1218,24 @@
}
/**
+ * Returns the command-line options for the {@link #main(String[])} method.
+ * @return Command-line options.
+ */
+ private static Options getCommandLineOptions() {
+ final Options clOptions = new Options();
+ final Option input = new Option("i", "input", true, "path to the input file");
+ input.setRequired(true);
+ final Option output = new Option("o", "output", true, "path to the output (pretty-printed) file");
+ output.setRequired(true);
+ final Option catalog = new Option("c", "catalog", true, "path to the OASIS XML catalog");
+ output.setRequired(true);
+ clOptions.addOption(input);
+ clOptions.addOption(output);
+ clOptions.addOption(catalog);
+ return clOptions;
+ }
+
+ /**
* Command-line interface for pretty-printing an XML document.
*
* <p>Design Note: We use files instead of URLs here to more easily
@@ -1242,18 +1261,23 @@
*/
public static void main(final String[] args) {
/* Checkstyle-GenericIllegalRegexp-Off. */
- if (args == null
- || args.length < FOrayPretty.MIN_CL_ARGUMENTS
- || args.length > FOrayPretty.MAX_CL_ARGUMENTS) {
- System.out.print("Wrong number of arguments.");
- System.exit(FOrayPretty.STATUS_WRONG_QTY_ARGUMENTS);
+ final Options commandLineOptions = FOrayPretty.getCommandLineOptions();
+ final CommandLineParser commandLineParser = new PosixParser();
+ CommandLine parsedCommandLine = null;
+ try {
+ parsedCommandLine = commandLineParser.parse(commandLineOptions, args);
+ } catch (final ParseException e) {
+ System.out.println(e.getMessage());
+ final HelpFormatter helpFormatter = new HelpFormatter();
+ helpFormatter.printHelp("java -cp $FORAY_CLASSPATH " + FOrayPretty.class.getName(), commandLineOptions,
+ true);
+ System.exit(FOrayPretty.STATUS_COMMAND_LINE_ERROR);
}
- final String input = args[0];
- final String output = args[1];
- String catalog = null;
- if (args.length > 2) {
- catalog = args[2];
- }
+
+ final String input = parsedCommandLine.getOptionValue("input");
+ final String output = parsedCommandLine.getOptionValue("output");
+ final String catalog = parsedCommandLine.getOptionValue("catalog");
+
InputStream inputStream = null;
try {
FileInputStream fis = null;
Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java
===================================================================
--- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2010-01-31 19:31:25 UTC (rev 10903)
+++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2010-01-31 19:56:21 UTC (rev 10904)
@@ -69,15 +69,15 @@
/** Command-line status constant indicating success. */
public static final byte STATUS_SUCCESS = 0;
+ /** Command-line status constant indicating that the command line itself was not properly formed. */
+ public static final byte STATUS_COMMAND_LINE_ERROR = 1;
+
/** Command-line status constant indicating a malformed URL. */
- public static final byte STATUS_MALFORMED_URL = 1;
+ public static final byte STATUS_MALFORMED_URL = 2;
/** Command-line status constant indicating a parsing error. */
- public static final byte STATUS_PARSING_ERROR = 2;
+ public static final byte STATUS_PARSING_ERROR = 3;
- /** Command-line status constant indicating that the command line itself was not properly formed. */
- public static final byte STATUS_COMMAND_LINE_ERROR = 4;
-
/** Command-line status constant indicating that a substantive difference
* between the two inputs was detected. */
public static final byte STATUS_DIFFERENCE_FOUND = 99;
@@ -174,7 +174,7 @@
* below where we allow a catalog to be used to alleviate the network traffic. */
factory.setProperty("javax.xml.stream.supportDTD", Boolean.TRUE);
- if (! (catalog == null)) {
+ if (catalog != null) {
final String[] catalogs = new String[] {catalog};
final XMLResolver resolver = XMLUtil.getXMLResolver(catalogs);
factory.setProperty("javax.xml.stream.resolver", resolver);
@@ -612,9 +612,9 @@
*/
private static Options getCommandLineOptions() {
final Options clOptions = new Options();
- final Option catalog = new Option("c", "catalog", true, "path to the catalog file (optional)");
+ final Option catalog = new Option("c", "catalog", true, "path to the OASIS XML catalog file");
catalog.setRequired(false);
- final Option files = new Option("f", "files", true, "paths to the files to be compared.");
+ final Option files = new Option("f", "files", true, "paths to the files to be compared (minimum 2)");
files.setRequired(true);
files.setArgs(Option.UNLIMITED_VALUES);
clOptions.addOption(catalog);
@@ -637,11 +637,15 @@
* <li>0 (success, no differences found)</li>
* <li>1 (malformed URL)</li>
* <li>2 (parsing error)</li>
- * <li>3 (differences found between the two input files)</li>
+ * <li>3 (command-line error)
+ * <li>99 (differences found between the two input files)</li>
* </ul>
*
- * @param args The first argument is the location of an XML catalog to be used to resolve DTDS.
- * The remaining arguments are two or more URLs that should be compared.
+ * @param args The following are valid command-line arguments:
+ * <ul>
+ * <li>-c,--catalog <arg> path to the catalog file (optional)</li>
+ * <li>-f,--files <arg> paths to the files to be compared (required, minimum 2)</li>
+ * </ul>
*/
public static void main(final String[] args) {
/* Checkstyle-GenericIllegalRegexp-Off. */
@@ -653,7 +657,8 @@
} catch (final ParseException e) {
System.out.println(e.getMessage());
final HelpFormatter helpFormatter = new HelpFormatter();
- helpFormatter.printHelp("java -cp $FORAY_CLASSPATH " + FOrayXDiff.class.getName(), commandLineOptions);
+ helpFormatter.printHelp("java -cp $FORAY_CLASSPATH " + FOrayXDiff.class.getName(), commandLineOptions,
+ true);
System.exit(FOrayXDiff.STATUS_COMMAND_LINE_ERROR);
}
final String catalog = parsedCommandLine.getOptionValue("catalog");
Modified: trunk/foray/scripts/foray-pretty.bat
===================================================================
--- trunk/foray/scripts/foray-pretty.bat 2010-01-31 19:31:25 UTC (rev 10903)
+++ trunk/foray/scripts/foray-pretty.bat 2010-01-31 19:56:21 UTC (rev 10904)
@@ -22,7 +22,7 @@
set TEMP_NAME=pretty.xml
rem Run the pretty-printer.
-set COMMAND=java -cp %FORAY_CP% %CLASS% %INPUT_NAME% %TEMP_NAME% %CATALOG%
+set COMMAND=java -cp %FORAY_CP% %CLASS% --input %INPUT_NAME% --output %TEMP_NAME% --catalog %CATALOG%
%COMMAND%
echo End pretty-printing.
rem echo Error Level is %errorlevel%
@@ -34,7 +34,7 @@
rem Make sure the pretty-printed version has the same content as original.
echo Comparing content for unintended changes during pretty-print.
set CLASS=org.foray.pretty.FOrayXDiff
-set COMMAND=java -cp %FORAY_CP% %CLASS% --catalog %CATALOG% --files %INPUT_NAME% %TEMP_NAME%
+set COMMAND=java -cp %FORAY_CP% %CLASS% --files %INPUT_NAME% %TEMP_NAME% --catalog %CATALOG%
%COMMAND%
echo End comparison.
if %errorlevel% == 0 goto :copy
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2010-02-01 15:40:03
|
Revision: 10905
http://foray.svn.sourceforge.net/foray/?rev=10905&view=rev
Author: victormote
Date: 2010-02-01 15:39:30 +0000 (Mon, 01 Feb 2010)
Log Message:
-----------
Introduce the Commons CLI parsing to the main FOray class. Used only for validation right now.
Modified Paths:
--------------
trunk/foray/doc/web/00-release/notes-unreleased.html
trunk/foray/foray-app/.classpath
trunk/foray/foray-app/scripts/build.xml
trunk/foray/foray-app/src/java/org/foray/app/FOray.java
trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java
Added Paths:
-----------
trunk/foray/foray-app/src/javatest/org/foray/app/TestFOray.java
Modified: trunk/foray/doc/web/00-release/notes-unreleased.html
===================================================================
--- trunk/foray/doc/web/00-release/notes-unreleased.html 2010-01-31 19:56:21 UTC (rev 10904)
+++ trunk/foray/doc/web/00-release/notes-unreleased.html 2010-02-01 15:39:30 UTC (rev 10905)
@@ -38,6 +38,11 @@
<li>Miscellaneous improvements to the Panose class, thanks to Jason Harrop.
These include greatly improved Panose matching, and methods to return bold and italic Panose
instances.</li>
+ <li>Some minor changes have been made to the command-line options.
+Previously, assumptions were made that the input file was and FO file and that the output was PDF.
+These options must now be explicitly set on the command-line.
+For example, previously "FOray foo.fo foo.pdf" would have parsed an FO file and produced a PDF.
+To get the same results now, use "FOray -fo foo.fo -pdf foo.pdf".</li>
</ul>
<h3>Unreleased changes of interest to Developers</h3>
Modified: trunk/foray/foray-app/.classpath
===================================================================
--- trunk/foray/foray-app/.classpath 2010-01-31 19:56:21 UTC (rev 10904)
+++ trunk/foray/foray-app/.classpath 2010-02-01 15:39:30 UTC (rev 10905)
@@ -41,5 +41,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/FOrayMIF"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslPs"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="lib" path="/FOray Lib/commons-cli-1.2.jar" sourcepath="/FOray Lib-Build/commons-cli/commons-cli-1.2-sources.jar"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-app/scripts/build.xml
===================================================================
--- trunk/foray/foray-app/scripts/build.xml 2010-01-31 19:56:21 UTC (rev 10904)
+++ trunk/foray/foray-app/scripts/build.xml 2010-02-01 15:39:30 UTC (rev 10905)
@@ -29,6 +29,7 @@
<include name="axsl*.jar"/>
<include name="commons-io-*.jar"/>
<include name="commons-logging-*.jar"/>
+ <include name="commons-cli-*.jar"/>
<include name="servlet*.jar"/>
<include name="xercesImpl*.jar"/>
<include name="xml-apis*.jar"/>
Modified: trunk/foray/foray-app/src/java/org/foray/app/FOray.java
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/app/FOray.java 2010-01-31 19:56:21 UTC (rev 10904)
+++ trunk/foray/foray-app/src/java/org/foray/app/FOray.java 2010-02-01 15:39:30 UTC (rev 10905)
@@ -32,6 +32,14 @@
import org.foray.core.FOrayException;
import org.foray.core.SessionConfig;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionGroup;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.PosixParser;
import org.apache.commons.logging.Log;
import java.io.FileNotFoundException;
@@ -41,6 +49,21 @@
*/
public final class FOray {
+ /** Command-line status constant indicating that the command line itself was not properly formed. */
+ public static final byte STATUS_COMMAND_LINE_ERROR = 1;
+
+ /** Command-line example for testing and documentation. */
+ public static final String COMMAND_LINE_EXAMPLE_001 = "-fo foo.fo -pdf foo.pdf";
+
+ /** Examples of command-line arguments. These are used for testing, and for generating help documentation. */
+ public static final String[] COMMAND_LINE_EXAMPLES = new String[] {
+ "foray -fo foo.fo -pdf foo.pdf",
+ "foray -xsl foo.xsl -xml foo.xml -pdf foo.pdf",
+ "foray foo.fo -mif foo.mif",
+ "foray foo.fo -print or foray -print foo.fo",
+ "foray foo.fo -awt"
+ };
+
/**
* Private Constructor. This is a utility class and should never be
* instantiated.
@@ -48,12 +71,77 @@
private FOray() { }
/**
+ * Returns the command-line options for the {@link #main(String[])} method.
+ * @return Command-line options.
+ */
+ static Options getCommandLineOptions() {
+ final Options clOptions = new Options();
+
+ /* Configuration file and configuration options. */
+ final Option configurationFile = new Option("c", "configuration-file", true, "path to the configuration file");
+ configurationFile.setRequired(false);
+ configurationFile.setArgName("file");
+ clOptions.addOption(configurationFile);
+
+ /* Input. */
+ final OptionGroup inputGroup = new OptionGroup();
+ inputGroup.setRequired(true);
+
+ final Option foInputOption = new Option("fo", "fo-input", true, "XSL-FO input file");
+ foInputOption.setArgName("file");
+ inputGroup.addOption(foInputOption);
+
+ final Option xmlInputOption = new Option("xml", "xml-input", true, "XML input file (-xsl option required)");
+ xmlInputOption.setArgName("file");
+ inputGroup.addOption(xmlInputOption);
+
+ clOptions.addOptionGroup(inputGroup);
+
+ /* Output. */
+ final OptionGroup outputGroup = new OptionGroup();
+ outputGroup.setRequired(true);
+
+ final Option pdfOutputOption = new Option("pdf", "pdf-output", true, "Document will be rendered as PDF");
+ pdfOutputOption.setArgName("file");
+ outputGroup.addOption(pdfOutputOption);
+
+ clOptions.addOptionGroup(outputGroup);
+
+ return clOptions;
+ }
+
+ /**
+ * Parses a command-line.
+ * @param commandLineOptions The command-line options controlling the parsing.
+ * @param args The command-line arguments to be parsed.
+ * @return The results of the parsing.
+ * @throws ParseException For errors in <code>args</code>.
+ */
+ public static CommandLine parseCommandLine(final Options commandLineOptions, final String[] args)
+ throws ParseException {
+ final CommandLineParser commandLineParser = new PosixParser();
+ final CommandLine parsedCommandLine = commandLineParser.parse(commandLineOptions, args);
+ return parsedCommandLine;
+ }
+
+ /**
* Main command-line entry point to FOray.
* @param args The command-line arguments. See the application documentation
* for details on these arguments.
*/
public static void main(final String[] args) {
/* Checkstyle-GenericIllegalRegexp-Off. */
+ final Options commandLineOptions = FOray.getCommandLineOptions();
+ try {
+ /* TODO: Keep the return value and use it downstream. Right now all we are doing is testing the options. */
+ FOray.parseCommandLine(commandLineOptions, args);
+ } catch (final ParseException e) {
+ System.out.println(e.getMessage());
+ final HelpFormatter helpFormatter = new HelpFormatter();
+ helpFormatter.printHelp("java -cp $FORAY_CLASSPATH " + FOray.class.getName(), commandLineOptions,
+ true);
+ System.exit(FOray.STATUS_COMMAND_LINE_ERROR);
+ }
CommandLineOptions options = null;
final Log logger = Logging.makeDefaultLogger();
Added: trunk/foray/foray-app/src/javatest/org/foray/app/TestFOray.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/TestFOray.java (rev 0)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/TestFOray.java 2010-02-01 15:39:30 UTC (rev 10905)
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2010 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: 9908 $
+ * $LastChangedDate: 2007-07-02 12:22:30 -0600 (Mon, 02 Jul 2007) $
+ * $LastChangedBy$
+ */
+
+package org.foray.app;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.ParseException;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests of {@link FOray}.
+ */
+public class TestFOray extends TestCase {
+
+ /**
+ * Splits the raw command-line into an array of Strings expected by "main" methods.
+ * @param input The raw command-line to be split into arguments.
+ * @return The array of Strings parsed by using space as a delimiter.
+ */
+ private String[] splitCommandLineArgs(final String input) {
+ return input.split(" ");
+ }
+
+ /**
+ * Parses a raw command-line into its component pieces.
+ * @param input The raw command-line to be tested.
+ * @return The parsed command-line.
+ * @throws ParseException For errors on the input line.
+ */
+ private CommandLine parseCommandLine(final String input) throws ParseException {
+ final org.apache.commons.cli.Options commandLineOptions = FOray.getCommandLineOptions();
+ final String[] commandLineArgs = splitCommandLineArgs(input);
+ final CommandLine commandLine = FOray.parseCommandLine(commandLineOptions, commandLineArgs);
+ return commandLine;
+ }
+
+ /**
+ * Test of {@link FOray#parseCommandLine(org.apache.commons.cli.Options, String[])}.
+ * @throws ParseException For errors on the input line.
+ */
+ public void testParseCommandLine001() throws ParseException {
+ final CommandLine commandLine = parseCommandLine(FOray.COMMAND_LINE_EXAMPLE_001);
+ assertEquals("foo.fo", commandLine.getOptionValue("fo"));
+ assertEquals("foo.pdf", commandLine.getOptionValue("pdf"));
+ }
+
+}
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java 2010-01-31 19:56:21 UTC (rev 10904)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java 2010-02-01 15:39:30 UTC (rev 10905)
@@ -54,12 +54,12 @@
public static Test suite() {
final TestSuite testSuite = new TestSuite("The FOray Application");
- /* First the FO Tree tests. */
+ /* FO Tree tests. */
testSuite.addTestSuite(TestInvalidXml.class);
testSuite.addTestSuite(TestFont.class);
testSuite.addTestSuite(TestGraphic.class);
- /* Now the Area Tree tests. */
+ /* Area Tree tests. */
testSuite.addTestSuite(TestBorder.class);
testSuite.addTestSuite(TestBlock.class);
testSuite.addTestSuite(TestInline.class);
@@ -67,6 +67,9 @@
testSuite.addTestSuite(TestGraphicArea.class);
testSuite.addTestSuite(TestVertical.class);
+ /* Tests of classes in this project. */
+ testSuite.addTestSuite(TestFOray.class);
+
return testSuite;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2010-02-01 17:09:34
|
Revision: 10906
http://foray.svn.sourceforge.net/foray/?rev=10906&view=rev
Author: victormote
Date: 2010-02-01 17:09:24 +0000 (Mon, 01 Feb 2010)
Log Message:
-----------
More work on command-line.
Modified Paths:
--------------
trunk/foray/doc/web/00-release/notes-unreleased.html
trunk/foray/doc/web/app/using/run.html
trunk/foray/foray-app/src/java/org/foray/app/FOray.java
trunk/foray/foray-app/src/javatest/org/foray/app/TestFOray.java
Modified: trunk/foray/doc/web/00-release/notes-unreleased.html
===================================================================
--- trunk/foray/doc/web/00-release/notes-unreleased.html 2010-02-01 15:39:30 UTC (rev 10905)
+++ trunk/foray/doc/web/00-release/notes-unreleased.html 2010-02-01 17:09:24 UTC (rev 10906)
@@ -42,7 +42,9 @@
Previously, assumptions were made that the input file was and FO file and that the output was PDF.
These options must now be explicitly set on the command-line.
For example, previously "FOray foo.fo foo.pdf" would have parsed an FO file and produced a PDF.
-To get the same results now, use "FOray -fo foo.fo -pdf foo.pdf".</li>
+To get the same results now, use "FOray -fo foo.fo -pdf foo.pdf".
+Option "awt" was changed to "screen".
+Option "at" was changed to "area".</li>
</ul>
<h3>Unreleased changes of interest to Developers</h3>
Modified: trunk/foray/doc/web/app/using/run.html
===================================================================
--- trunk/foray/doc/web/app/using/run.html 2010-02-01 15:39:30 UTC (rev 10905)
+++ trunk/foray/doc/web/app/using/run.html 2010-02-01 17:09:24 UTC (rev 10906)
@@ -96,33 +96,28 @@
<p>[INPUT]</p>
-<pre> infile XSLFO input file (the same as the next)
- -fo infile xsl:fo input file
- -xml infile xml input file, must be used together with -xsl
- -xsl stylesheet xslt stylesheet</pre>
+<pre> -fo infile XSL-FO input file
+ -xml infile XML input file (-xsl option required)
+ -xsl stylesheet XSL input stylesheet file (use with -xml)</pre>
<p>[OUTPUT]</p>
-<pre> outfile input will be rendered as pdf file into outfile
- -pdf outfile input will be rendered as pdf file (outfile req'd)
- -awt input will be displayed on screen
- -mif outfile input will be rendered as mif file (outfile req'd)
- -pcl outfile input will be rendered as pcl file (outfile req'd)
- -ps outfile input will be rendered as PostScript file (outfile req'd)
- -txt outfile input will be rendered as text file (outfile req'd)
- -svg outfile input will be rendered as an svg slides file (outfile req'd)
- -at outfile representation of area tree as XML (outfile req'd)
- -print input file will be rendered and sent to the printer
- see print specific options with "-print help"</pre>
+<pre> -pdf outfile Document will be rendered as PDF
+ -mif outfile Document will be rendered as MIF
+ -pcl outfile Document will be rendered as PCL
+ -ps outfile Document will be rendered as PostScript
+ -txt outfile Document will be rendered as text
+ -svg outfile Document will be rendered as SVG slides
+ -area outfile Document will be rendered as an Area Tree (XML)
+ -screen Document will be rendered to the screen
+ -print Document will be rendered to a printer</pre>
<p>[Examples]</p>
-<pre> foray foo.fo foo.pdf
- foray -fo foo.fo -pdf foo.pdf (does the same as the previous line)
- foray -xsl foo.xsl -xml foo.xml -pdf foo.pdf
- foray foo.fo -mif foo.mif
- foray foo.fo -print or foray -print foo.fo
- foray foo.fo -awt</pre>
+<pre> org.foray.app.FOray -fo foo.fo -pdf foo.pdf
+ org.foray.app.FOray -xsl foo.xsl -xml foo.xml -pdf foo.pdf
+ org.foray.app.FOray -fo foo.fo -print
+ org.foray.app.FOray -fo foo.fo -screen</pre>
<p>The -so option allows any configuration option to be set from the
command-line by supplying the key and value for that option. See
Modified: trunk/foray/foray-app/src/java/org/foray/app/FOray.java
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/app/FOray.java 2010-02-01 15:39:30 UTC (rev 10905)
+++ trunk/foray/foray-app/src/java/org/foray/app/FOray.java 2010-02-01 17:09:24 UTC (rev 10906)
@@ -55,6 +55,15 @@
/** Command-line example for testing and documentation. */
public static final String COMMAND_LINE_EXAMPLE_001 = "-fo foo.fo -pdf foo.pdf";
+ /** Command-line example for testing and documentation. */
+ public static final String COMMAND_LINE_EXAMPLE_002 = "-xsl foo.xsl -xml foo.xml -pdf foo.pdf";
+
+ /** Command-line example for testing and documentation. */
+ public static final String COMMAND_LINE_EXAMPLE_003 = "-fo foo.fo -print";
+
+ /** Command-line example for testing and documentation. */
+ public static final String COMMAND_LINE_EXAMPLE_004 = "-fo foo.fo -screen";
+
/** Examples of command-line arguments. These are used for testing, and for generating help documentation. */
public static final String[] COMMAND_LINE_EXAMPLES = new String[] {
"foray -fo foo.fo -pdf foo.pdf",
@@ -97,6 +106,11 @@
clOptions.addOptionGroup(inputGroup);
+ /* Dependent input option. */
+ final Option xslInputOption = new Option("xsl", "xsl-input", true, "XSL input stylesheet file (use with -xml)");
+ xslInputOption.setArgName("stylesheet");
+ clOptions.addOption(xslInputOption);
+
/* Output. */
final OptionGroup outputGroup = new OptionGroup();
outputGroup.setRequired(true);
@@ -105,6 +119,39 @@
pdfOutputOption.setArgName("file");
outputGroup.addOption(pdfOutputOption);
+ final Option mifOutputOption = new Option("mif", "mif-output", true, "Document will be rendered as MIF");
+ mifOutputOption.setArgName("file");
+ outputGroup.addOption(mifOutputOption);
+
+ final Option pclOutputOption = new Option("pcl", "pcl-output", true, "Document will be rendered as PCL");
+ pclOutputOption.setArgName("file");
+ outputGroup.addOption(pclOutputOption);
+
+ final Option psOutputOption = new Option("ps", "ps-output", true, "Document will be rendered as PostScript");
+ psOutputOption.setArgName("file");
+ outputGroup.addOption(psOutputOption);
+
+ final Option txtOutputOption = new Option("txt", "txt-output", true, "Document will be rendered as text");
+ txtOutputOption.setArgName("file");
+ outputGroup.addOption(txtOutputOption);
+
+ final Option svgOutputOption = new Option("svg", "svg-output", true, "Document will be rendered as SVG slides");
+ svgOutputOption.setArgName("file");
+ outputGroup.addOption(svgOutputOption);
+
+ final Option areaOutputOption = new Option("area", "area-output", true,
+ "Document will be rendered as an Area Tree (XML)");
+ areaOutputOption.setArgName("file");
+ outputGroup.addOption(areaOutputOption);
+
+ final Option screenOutputOption = new Option("screen", "screen-output", false,
+ "Document will be rendered to the screen");
+ outputGroup.addOption(screenOutputOption);
+
+ final Option printOutputOption = new Option("print", "print-output", false,
+ "Document will be rendered to a printer");
+ outputGroup.addOption(printOutputOption);
+
clOptions.addOptionGroup(outputGroup);
return clOptions;
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/TestFOray.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/TestFOray.java 2010-02-01 15:39:30 UTC (rev 10905)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/TestFOray.java 2010-02-01 17:09:24 UTC (rev 10906)
@@ -70,4 +70,35 @@
assertEquals("foo.pdf", commandLine.getOptionValue("pdf"));
}
+ /**
+ * Test of {@link FOray#parseCommandLine(org.apache.commons.cli.Options, String[])}.
+ * @throws ParseException For errors on the input line.
+ */
+ public void testParseCommandLine002() throws ParseException {
+ final CommandLine commandLine = parseCommandLine(FOray.COMMAND_LINE_EXAMPLE_002);
+ assertEquals("foo.xml", commandLine.getOptionValue("xml"));
+ assertEquals("foo.xsl", commandLine.getOptionValue("xsl"));
+ assertEquals("foo.pdf", commandLine.getOptionValue("pdf"));
+ }
+
+ /**
+ * Test of {@link FOray#parseCommandLine(org.apache.commons.cli.Options, String[])}.
+ * @throws ParseException For errors on the input line.
+ */
+ public void testParseCommandLine003() throws ParseException {
+ final CommandLine commandLine = parseCommandLine(FOray.COMMAND_LINE_EXAMPLE_003);
+ assertEquals("foo.fo", commandLine.getOptionValue("fo"));
+ assertTrue(commandLine.hasOption("print"));
+ }
+
+ /**
+ * Test of {@link FOray#parseCommandLine(org.apache.commons.cli.Options, String[])}.
+ * @throws ParseException For errors on the input line.
+ */
+ public void testParseCommandLine004() throws ParseException {
+ final CommandLine commandLine = parseCommandLine(FOray.COMMAND_LINE_EXAMPLE_004);
+ assertEquals("foo.fo", commandLine.getOptionValue("fo"));
+ assertTrue(commandLine.hasOption("screen"));
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|