pbwest 2004/05/08 06:02:43
Modified: src/java/org/apache/fop/fo Tag: FOP_0-20-0_Alt-Design
FObjects.java
Log:
Methods in FObjects made static.
Unused functionality removed.
Revision Changes Path
No revision
No revision
1.1.2.11 +9 -195 xml-fop/src/java/org/apache/fop/fo/Attic/FObjects.java
Index: FObjects.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/Attic/FObjects.java,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -u -r1.1.2.10 -r1.1.2.11
--- FObjects.java 19 Feb 2004 03:11:56 -0000 1.1.2.10
+++ FObjects.java 8 May 2004 13:02:43 -0000 1.1.2.11
@@ -20,13 +20,13 @@
package org.apache.fop.fo;
-import java.lang.reflect.Constructor;
-import java.util.HashMap;
-import java.util.StringTokenizer;
+//import java.lang.reflect.Constructor;
+//import java.util.HashMap;
+//import java.util.StringTokenizer;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.Fop;
-import org.apache.fop.datatypes.Ints;
+//import org.apache.fop.datatypes.Ints;
import org.apache.fop.fo.flow.*;
import org.apache.fop.xml.FoXmlEvent;
import org.apache.fop.xml.XmlEvent;
@@ -46,160 +46,10 @@
public static final String packageNamePrefix = Fop.fopPackage;
/**
- * Create a singleton FObjects object
- */
- public static final FObjects fobjects;
- static {
- fobjects = new FObjects();
- }
-
- /**
- * @return the singleton
- */
- public static final FObjects getFObjects() {
- return fobjects;
- }
-
- /**
* FObjects cannot be instantiated
*/
private FObjects() {}
- /**
- * A String[] array of the fo class names. This array is
- * effectively 1-based, with the first element being unused.
- * The array is initialized in a static initializer by converting the
- * fo names from the array FObjectNames.foLocalNames into class names by
- * converting the first character of every component word to upper case,
- * removing all punctuation characters and prepending the prefix 'Fo'.
- * It can be indexed by the fo name constants defined in the
- * <tt>FObjectNames</tt> class.
- */
- private static final String[] foClassNames;
-
- /**
- * A String[] array of the fo class package names. This array is
- * effectively 1-based, with the first element being unused.
- * The array is initialized in a static initializer by constructing
- * the package name from the common package prefix set in the field
- * <tt>packageNamePrefix</tt>, the package name suffix associated with
- * the fo local names in the <tt>FObjectNames.foLocalNames</tt> array,
- * the the class name which has been constructed in the
- * <tt>foClassNames</tt> array here.
- * It can be indexed by the fo name constants defined in the
- * <tt>FObjectNames</tt> class.
- */
- private static final String[] foPkgClassNames;
-
- /**
- * An Class[] array containing Class objects corresponding to each of the
- * class names in the foClassNames array. It is initialized in a static
- * initializer in parallel with the creation of the class names in the
- * foClassNames array. It can be indexed by the class name constants
- * defined in this file.
- *
- * It is not guaranteed that there exists a class corresponding to each of
- * the FlowObjects defined in this file.
- */
- private final Constructor[] foConstructors
- = new Constructor[FObjectNames.foLocalNamesLength];
-
- /**
- * The default constructor arguments for an FObject. <b>N.B.</b> not
- * all subclasses of <tt>FONode</tt> use this constructor; e.g.
- * <tt>FoRoot</tt>, <tt>FoPageSequence</tt> & <tt>FoFlow</tt>.
- * Generally these FObjects are not invoked through reflection. If such
- * invocation becomes necessary for a particular class, a contructor of
- * this kind must be added to the class.
- * <p>At present, the only difference is in the addition of the
- * <tt>int.class</tt> constructor argument.
- */
- protected static final Class[] defaultConstructorArgs =
- new Class[] {
- FOTree.class
- ,FONode.class
- ,FOPageSeqNode.class
- ,FoXmlEvent.class
- ,int.class
- };
-
- /**
- * A HashMap whose elements are an integer index value keyed by an
- * fo local name. The index value is the index of the fo local name in
- * the FObjectNames.foLocalNames[] array.
- * It is initialized in a static initializer.
- */
- private static final HashMap foToIndex;
-
- /**
- * A HashMap whose elements are an integer index value keyed by the name
- * of a fo class. The index value is the index of the fo
- * class name in the foClassNames[] array. It is initialized in a
- * static initializer.
- */
- private static final HashMap foClassToIndex;
-
- static {
- String prefix = packageNamePrefix + ".";
- String foPrefix = "Fo";
- int namei = 0; // Index of localName in FObjectNames.foLocalNames
- int pkgi = 1; // Index of package suffix in foLocalNames
-
- foClassNames = new String[FObjectNames.foLocalNamesLength];
- foPkgClassNames = new String[FObjectNames.foLocalNamesLength];
- foToIndex = new HashMap(
- (int)(FObjectNames.foLocalNamesLength / 0.75) + 1);
- foClassToIndex = new HashMap(
- (int)(FObjectNames.foLocalNamesLength / 0.75) + 1);
-
- for (int i = 1; i < FObjectNames.foLocalNamesLength; i++) {
- String cname = foPrefix;
- String foName;
- String pkgname;
- try {
- foName = FObjectNames.getFOName(i);
- pkgname = FObjectNames.getFOPkg(i);
- } catch (FOPException fex) {
- throw new RuntimeException(fex.getMessage());
- }
- StringTokenizer stoke =
- new StringTokenizer(foName, "-");
- while (stoke.hasMoreTokens()) {
- String token = stoke.nextToken();
- String pname = new Character(
- Character.toUpperCase(token.charAt(0))
- ).toString() + token.substring(1);
- cname = cname + pname;
- }
- foClassNames[i] = cname;
-
- // Set up the array of class package names
- // Set up the array of Class objects, indexed by the fo
- // constants.
- String name = prefix + pkgname + "." + cname;
- foPkgClassNames[i] = name;
-
- // Set up the foToIndex Hashmap with the name of the
- // flow object as a key, and the integer index as a value
- if (foToIndex.put(foName,
- Ints.consts.get(i)) != null) {
- throw new RuntimeException(
- "Duplicate values in propertyToIndex for key " +
- foName);
- }
-
- // Set up the foClassToIndex Hashmap with the name of the
- // fo class as a key, and the integer index as a value
-
- if (foClassToIndex.put(foClassNames[i],
- Ints.consts.get(i)) != null) {
- throw new RuntimeException(
- "Duplicate values in foClassToIndex for key " +
- foClassNames[i]);
- }
-
- }
- }
/**
* This method generates generates new FO objects, except for FoPcdata
@@ -216,7 +66,7 @@
* @return the new FO node
* @throws FOPException
*/
- public Object makePageSeqFOChild(
+ public static Object makePageSeqFOChild(
FOTree foTree, FONode pageSequence, FOPageSeqNode parent,
FoXmlEvent event, int stateFlags)
throws FOPException
@@ -319,7 +169,7 @@
* @return
* @throws FOPException
*/
- public Object makePageSeqFOChild(FOTree foTree, FONode pageSequence,
+ public static Object makePageSeqFOChild(FOTree foTree, FONode pageSequence,
FOPageSeqNode parent, XmlEvent event, int stateFlags)
throws FOPException
{
@@ -333,42 +183,6 @@
+ XmlEvent.eventTypeName(event.getType()));
}
return new FoPcdata(foTree, pageSequence, parent, event, stateFlags);
- }
-
- /**
- * Get the index of an unqualified FO class name
- * @param name of the FO
- * @return the index
- */
- public static int getFoIndex(String name) {
- return ((Integer)(foToIndex.get(name))).intValue();
- }
-
- /**
- * Get the unqualified class name of the indicated FO
- * @param foIndex of the rwquired FO
- * @return the unqualified class name
- */
- public static String getClassName(int foIndex) {
- return foClassNames[foIndex];
- }
-
- /**
- * Get the fully-qualified class name of the indicated FO
- * @param foIndex of the required FO
- * @return the fully-qualified class name
- */
- public static String getPkgClassName(int foIndex) {
- return foPkgClassNames[foIndex];
- }
-
- /**
- * Get the <code>Constructor</code> object for a given FO
- * @param foIndex of the FO
- * @return the <code>Constructor</code>
- */
- public Constructor getConstructor(int foIndex) {
- return foConstructors[foIndex];
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]