pbwest 2002/10/18 20:49:05
Modified: src/org/apache/fop/fo Tag: FOP_0-20-0_Alt-Design
FOAttributes.java FObject.java FObjectNames.java
FONode.java FOPropertySets.java FoRoot.java
FOTree.java PropertyConsts.java PropertySets.java
PropNames.java ReferenceAreaFO.java
ShorthandPropSets.java WritingModes.java
Removed: src/org/apache/fop/fo Tag: FOP_0-20-0_Alt-Design
Properties.java
Log:
PropertyConsts now instantiated.
PropertyConsts data is accessed through a singleton object.
getPropertyIndex() moved to PropNames.
Properties split into properties.Property and properties.<property>.
Revision Changes Path
No revision
No revision
1.1.2.9 +11 -17 xml-fop/src/org/apache/fop/fo/Attic/FOAttributes.java
Index: FOAttributes.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/Attic/FOAttributes.java,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- FOAttributes.java 10 Oct 2002 03:16:12 -0000 1.1.2.8
+++ FOAttributes.java 19 Oct 2002 03:49:04 -0000 1.1.2.9
@@ -79,6 +79,7 @@
= new Integer[] { Ints.consts.get(0) };
private FONode foNode;
+ public final PropertyConsts propertyConsts;
/**
* Construct an <i>FOAttributes</i> object.
@@ -97,6 +98,9 @@
* associated.
*/
public FOAttributes (XMLEvent event, FONode foNode) throws FOPException {
+
+ propertyConsts = PropertyConsts.getPropertyConsts();
+
// If the event is null, there is no event associated with this
// node, probably because this is a manufactured node; e.g.,
// an "invented" FopageSequenceMaster. The default initialisation
@@ -127,18 +131,9 @@
// Catch default namespace declaration here.
if (attrLocalname.equals("xmlns")) break;
// Is this a known (valid) property?
- try {
- // throws PropertyException if invalid
- propIndex =
- PropertyConsts.getPropertyIndex(attrLocalname);
+ propIndex = PropNames.getPropertyIndex(attrLocalname);
// Known attribute name
- foAttrMap.put(Ints.consts.get(propIndex), attrValue);
- } catch (PropertyException e) {
- // Not known - ignore
- MessageHandler.errorln(event.getQName() + " "
- + attrQName
- + " not recognized. Ignoring.");
- }
+ foAttrMap.put(Ints.consts.get(propIndex), attrValue);
} else { // Not the XSL FO namespace
int j;
if (nSpaceAttrMaps == null) {
@@ -234,8 +229,7 @@
public String getFoAttrValue(String propertyName)
throws PropertyException
{
- return getFoAttrValue
- (PropertyConsts.getPropertyIndex(propertyName));
+ return getFoAttrValue(PropNames.getPropertyIndex(propertyName));
}
/**
@@ -274,7 +268,7 @@
throws PropertyException
{
if (uriIndex == XMLNamespaces.DefAttrNSIndex)
- return getFoAttrValue(PropertyConsts.getPropertyIndex(localName));
+ return getFoAttrValue(PropNames.getPropertyIndex(localName));
return (String)
(((HashMap)nSpaceAttrMaps.get(uriIndex)).get(localName));
}
1.1.2.4 +0 -0 xml-fop/src/org/apache/fop/fo/Attic/FObject.java
Index: FObject.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/Attic/FObject.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
1.1.2.5 +1 -1 xml-fop/src/org/apache/fop/fo/Attic/FObjectNames.java
Index: FObjectNames.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/Attic/FObjectNames.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
1.19.2.17 +23 -20 xml-fop/src/org/apache/fop/fo/FONode.java
Index: FONode.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/FONode.java,v
retrieving revision 1.19.2.16
retrieving revision 1.19.2.17
diff -u -r1.19.2.16 -r1.19.2.17
--- FONode.java 9 Oct 2002 05:57:09 -0000 1.19.2.16
+++ FONode.java 19 Oct 2002 03:49:04 -0000 1.19.2.17
@@ -4,6 +4,7 @@
import org.apache.fop.fo.FOAttributes;
import org.apache.fop.fo.FObjectNames;
import org.apache.fop.fo.FOPropertySets;
+import org.apache.fop.fo.properties.Property;
import org.apache.fop.fo.expr.PropertyException;
import org.apache.fop.fo.expr.PropertyParser;
import org.apache.fop.datatypes.PropertyValue;
@@ -61,6 +62,8 @@
protected XMLNamespaces namespaces;
/** The FO type. */
public final int type;
+ /** The PropertyConsts singleton. */
+ public final PropertyConsts propertyConsts;
/** The attributes defined on this node. */
public FOAttributes foAttributes;
/** The unmodifiable map of properties defined on this node. */
@@ -82,10 +85,10 @@
protected ROBitSet attrBitSet;
/** The <tt>ROBitSet</tt> of inherited properties for the
<i>attrSet</i> argument. */
- protected ROBitSet inheritedBitSet;
- /** The <tt>ROBitSet</tt> of non-inherited prperties for the
+ //protected ROBitSet inheritedBitSet;
+ /** The <tt>ROBitSet</tt> of non-inherited properties for the
<i>attrSet</i> argument. */
- protected ROBitSet nonInheritedBitSet;
+ //protected ROBitSet nonInheritedBitSet;
/** Ancestor reference area of this FONode. */
protected FONode ancestorRefArea = null;
@@ -105,13 +108,14 @@
{
foTree.super(parent);
this.foTree = foTree;
+ propertyConsts = PropertyConsts.getPropertyConsts();
this.type = type;
this.parent = parent;
this.event = event;
this.attrSet = attrSet;
attrBitSet = FOPropertySets.getAttrROBitSet(attrSet);
- inheritedBitSet = FOPropertySets.getInheritedROBitSet(attrSet);
- nonInheritedBitSet = FOPropertySets.getNonInheritedROBitSet(attrSet);
+ //inheritedBitSet = FOPropertySets.getInheritedROBitSet(attrSet);
+ //nonInheritedBitSet = FOPropertySets.getNonInheritedROBitSet(attrSet);
xmlevents = foTree.xmlevents;
namespaces = xmlevents.getNamespaces();
exprParser = foTree.exprParser;
@@ -176,18 +180,17 @@
{
// parse the expression
exprParser.resetParser();
- foTree.args[0] = this;
- foTree.args[1] = exprParser.parse(this, property, attrValue);
- try {
- return (PropertyValue)
- (((Method)PropertyConsts.refineParsingMethods
- .get(property))
- .invoke(null, foTree.args));
- } catch (IllegalAccessException e) {
- throw new PropertyException (e);
- } catch (InvocationTargetException e) {
- throw new PropertyException (e);
- }
+ Property prop = propertyConsts.setupProperty(property);
+ return prop.refineParsing
+ (this, exprParser.parse(this, property, attrValue));
+ }
+
+ /**
+ * Get the eclosing <tt>FOTree</tt> instance of this <tt>FONode</tt>.
+ * @return the <tt.FOTree</tt>.
+ */
+ public FOTree getFOTree() {
+ return foTree;
}
/**
@@ -337,7 +340,7 @@
PropertyValue pval;
if ((pval = propertySet[property]) != null)
return IndirectValue.adjustedPropertyValue(pval);
- if (parent != null && PropertyConsts.inheritedProps.get(property))
+ if (parent != null && propertyConsts.isInherited(property))
return (propertySet[property] =
IndirectValue.adjustedPropertyValue
(parent.getPropertyValue(property)));
1.1.2.4 +52 -48 xml-fop/src/org/apache/fop/fo/Attic/FOPropertySets.java
Index: FOPropertySets.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/Attic/FOPropertySets.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- FOPropertySets.java 6 Oct 2002 14:29:04 -0000 1.1.2.3
+++ FOPropertySets.java 19 Oct 2002 03:49:04 -0000 1.1.2.4
@@ -105,6 +105,7 @@
throw new FOPException("Invalid attribute set: " + attrSet);
}
+ /*
public static ROBitSet getInheritedROBitSet(int attrSet)
throws FOPException
{
@@ -152,6 +153,7 @@
}
throw new FOPException("Invalid attribute set: " + attrSet);
}
+ */
public static int getFoIndex(String name) {
return ((Integer)(foToIndex.get(name))).intValue();
@@ -1103,11 +1105,11 @@
/**
* Set of all inherited properties available at fo:root.
*/
- public static final ROBitSet allInheritedProps;
+ //public static final ROBitSet allInheritedProps;
/**
* Set of all non-inherited properties available at fo:root.
*/
- public static final ROBitSet allNonInheritedProps;
+ //public static final ROBitSet allNonInheritedProps;
/**
* set of all properties which are
@@ -1118,12 +1120,12 @@
* set of all inherted properties which are
* usable within the declarations subtree.
*/
- public static final ROBitSet declarationsInherited;
+ //public static final ROBitSet declarationsInherited;
/**
* set of all non-inherited properties which are
* usable within the declarations subtree.
*/
- public static final ROBitSet declarationsNonInherited;
+ //public static final ROBitSet declarationsNonInherited;
/**
* Set of properties for exclusive
@@ -1141,12 +1143,12 @@
* set of all inherited properties which are
* usable within the page-sequence-master-set subtree.
*/
- public static final ROBitSet inheritedSeqMasterSet;
+ //public static final ROBitSet inheritedSeqMasterSet;
/**
* set of all non-inherited properties which are
* usable within the page-sequence-master-set subtree.
*/
- public static final ROBitSet nonInheritedSeqMasterSet;
+ //public static final ROBitSet nonInheritedSeqMasterSet;
/**
* set of all properties which are
@@ -1157,12 +1159,12 @@
* set of all inherited properties which are
* usable within the layout-master-set subtree.
*/
- public static final ROBitSet inheritedLayoutSet;
+ //public static final ROBitSet inheritedLayoutSet;
/**
* set of all non-inherited properties which are
* usable within the layout-master-set subtree.
*/
- public static final ROBitSet nonInheritedLayoutSet;
+ //public static final ROBitSet nonInheritedLayoutSet;
/**
* set of all properties which are
@@ -1173,12 +1175,12 @@
* set of all inherited properties which are
* usable within the page sequence subtree.
*/
- public static final ROBitSet inheritedPageSeqSet;
+ //public static final ROBitSet inheritedPageSeqSet;
/**
* set of all non-inherited properties which are
* usable within the page sequence subtree.
*/
- public static final ROBitSet nonInheritedPageSeqSet;
+ //public static final ROBitSet nonInheritedPageSeqSet;
/**
* set of all properties which are
@@ -1189,12 +1191,12 @@
* set of all inherited properties which are
* usable within the fo:flow subtree.
*/
- public static final ROBitSet inheritedFlowSet;
+ //public static final ROBitSet inheritedFlowSet;
/**
* set of all non-inherite properties which are
* usable within the fo:flow subtree.
*/
- public static final ROBitSet nonInheritedFlowSet;
+ //public static final ROBitSet nonInheritedFlowSet;
/**
* set of all properties which are
@@ -1205,12 +1207,12 @@
* set of all inherited properties which are
* usable <i>within</i> the fo:marker subtree.
*/
- public static final ROBitSet inheritedMarkerSet;
+ //public static final ROBitSet inheritedMarkerSet;
/**
* set of all non-inherited properties which are
* usable <i>within</i> the fo:marker subtree.
*/
- public static final ROBitSet nonInheritedMarkerSet;
+ //public static final ROBitSet nonInheritedMarkerSet;
/**
* set of all properties which are
@@ -1221,13 +1223,14 @@
* set of all inherited properties which are
* usable within the fo:static-content subtree.
*/
- public static final ROBitSet inheritedStaticSet;
+ //public static final ROBitSet inheritedStaticSet;
/**
* set of all non-inherited properties which are
* usable within the fo:static-content subtree.
*/
- public static final ROBitSet nonInheritedStaticSet;
+ //public static final ROBitSet nonInheritedStaticSet;
+ /*
private static BitSet makeInheritedSet(BitSet set) {
BitSet newset = new BitSet(set.size());
newset.or(set);
@@ -1246,6 +1249,7 @@
newset.andNot(ShorthandPropSets.shorthandCompoundProps);
return newset;
}
+ */
static {
@@ -1254,10 +1258,10 @@
allprops.set(1, PropNames.LAST_PROPERTY_INDEX);
allProps = new ROBitSet(allprops);
- allInheritedProps =
- new ROBitSet(makeInheritedSet(allprops));
- allNonInheritedProps =
- new ROBitSet(makeNonInheritedSet(allprops));
+ //allInheritedProps =
+ //new ROBitSet(makeInheritedSet(allprops));
+ //allNonInheritedProps =
+ //new ROBitSet(makeNonInheritedSet(allprops));
//root only set of properties - properties for exclusive use on the
// root element
@@ -1279,8 +1283,8 @@
declarationsAll = new ROBitSet(declarationsall);
// None of the declarations properties are inherited
- declarationsInherited = new ROBitSet(new BitSet(1));
- declarationsNonInherited = new ROBitSet(declarationsall);
+ //declarationsInherited = new ROBitSet(new BitSet(1));
+ //declarationsNonInherited = new ROBitSet(declarationsall);
// seq-master-only set of properties for exclusive use within
// the page-sequence-master subtree
@@ -1297,9 +1301,9 @@
seqmasterset.set(PropNames.MASTER_REFERENCE);
seqMasterSet = new ROBitSet(seqmasterset);
- inheritedSeqMasterSet = new ROBitSet(makeInheritedSet(seqmasterset));
- nonInheritedSeqMasterSet
- = new ROBitSet(makeNonInheritedSet(seqmasterset));
+ //inheritedSeqMasterSet = new ROBitSet(makeInheritedSet(seqmasterset));
+ //nonInheritedSeqMasterSet
+ //= new ROBitSet(makeNonInheritedSet(seqmasterset));
//layout-master-set only set of properties - properties for exclusive
// use within the layout-master-set SUBTREE
@@ -1334,10 +1338,10 @@
// Add the common background properties
layoutmasterset.or(PropertySets.backgroundSet);
layoutMasterSet = new ROBitSet(layoutmasterset);
- inheritedLayoutSet =
- new ROBitSet(makeInheritedSet(layoutmasterset));
- nonInheritedLayoutSet =
- new ROBitSet(makeNonInheritedSet(layoutmasterset));
+ //inheritedLayoutSet =
+ //new ROBitSet(makeInheritedSet(layoutmasterset));
+ //nonInheritedLayoutSet =
+ //new ROBitSet(makeNonInheritedSet(layoutmasterset));
BitSet flowonlyset = new BitSet();
flowonlyset.set(PropNames.MARKER_CLASS_NAME);
@@ -1365,39 +1369,39 @@
pageseqset.andNot(declarationsonly);
pageseqset.andNot(layoutmasteronly);
pageSeqSet = new ROBitSet(pageseqset);
- inheritedPageSeqSet =
- new ROBitSet(makeInheritedSet(pageseqset));
- nonInheritedPageSeqSet =
- new ROBitSet(makeNonInheritedSet(pageseqset));
+ //inheritedPageSeqSet =
+ //new ROBitSet(makeInheritedSet(pageseqset));
+ //nonInheritedPageSeqSet =
+ //new ROBitSet(makeNonInheritedSet(pageseqset));
BitSet flowallset = (BitSet)pageseqset.clone();
flowallset.andNot(pageseqonly);
flowallset.andNot(staticonlyset);
flowAllSet = new ROBitSet(flowallset);
- inheritedFlowSet =
- new ROBitSet(makeInheritedSet(flowallset));
- nonInheritedFlowSet =
- new ROBitSet(makeNonInheritedSet(flowallset));
+ //inheritedFlowSet =
+ //new ROBitSet(makeInheritedSet(flowallset));
+ //nonInheritedFlowSet =
+ //new ROBitSet(makeNonInheritedSet(flowallset));
BitSet staticallset = (BitSet)pageseqset.clone();
staticallset.andNot(pageseqonly);
staticallset.andNot(flowonlyset);
staticAllSet = new ROBitSet(staticallset);
- inheritedStaticSet =
- new ROBitSet(makeInheritedSet(staticallset));
- nonInheritedStaticSet =
- new ROBitSet(makeNonInheritedSet(staticallset));
+ //inheritedStaticSet =
+ //new ROBitSet(makeInheritedSet(staticallset));
+ //nonInheritedStaticSet =
+ //new ROBitSet(makeNonInheritedSet(staticallset));
BitSet markerallset = (BitSet)flowallset.clone();
markerallset.clear(PropNames.MARKER_CLASS_NAME);
markerAllSet = new ROBitSet(markerallset);
- inheritedMarkerSet =
- new ROBitSet(makeInheritedSet(markerallset));
- nonInheritedMarkerSet =
- new ROBitSet(makeNonInheritedSet(markerallset));
+ //inheritedMarkerSet =
+ //new ROBitSet(makeInheritedSet(markerallset));
+ //nonInheritedMarkerSet =
+ //new ROBitSet(makeNonInheritedSet(markerallset));
}
/**
1.1.2.10 +1 -1 xml-fop/src/org/apache/fop/fo/Attic/FoRoot.java
Index: FoRoot.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/Attic/FoRoot.java,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -r1.1.2.9 -r1.1.2.10
1.1.2.18 +6 -10 xml-fop/src/org/apache/fop/fo/Attic/FOTree.java
Index: FOTree.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/Attic/FOTree.java,v
retrieving revision 1.1.2.17
retrieving revision 1.1.2.18
diff -u -r1.1.2.17 -r1.1.2.18
--- FOTree.java 9 Oct 2002 05:55:06 -0000 1.1.2.17
+++ FOTree.java 19 Oct 2002 03:49:04 -0000 1.1.2.18
@@ -10,7 +10,6 @@
import org.apache.fop.apps.Driver;
import org.apache.fop.apps.FOPException;
import org.apache.fop.configuration.Configuration;
-import org.apache.fop.fo.Properties;
import org.apache.fop.fo.PropertyConsts;
import org.apache.fop.fo.PropNames;
import org.apache.fop.fo.expr.PropertyException;
@@ -54,6 +53,7 @@
SyncedXmlEventsBuffer xmlevents;
private Thread parserThread;
private boolean errorDump;
+ public final PropertyConsts propConsts;
/**
* The <tt>PropertyParser</tt> which will be used by the FO tree
@@ -61,11 +61,6 @@
*/
protected PropertyParser exprParser;
- /**
- * Args array for refineParsingMethods[].invoke() calls
- */
- Object[] args = new Object[2];
-
protected PropertyValue[] initialValues
= new PropertyValue[PropNames.LAST_PROPERTY_INDEX + 1];
@@ -80,13 +75,14 @@
errorDump = Configuration.getBooleanValue("debugMode").booleanValue();
this.xmlevents = xmlevents;
exprParser = new PropertyParser(this);
+ propConsts = PropertyConsts.getPropertyConsts();
// Initialize the FontSize first. Any lengths defined in ems must
// be resolved relative to the current font size. This may happen
// during setup of initial values.
// Set the initial value
PropertyValue prop =
- PropertyConsts.getInitialValue(PropNames.FONT_SIZE);
+ propConsts.getInitialValue(PropNames.FONT_SIZE);
if ( ! (prop instanceof Numeric) || ! ((Numeric)prop).isLength())
throw new PropertyException("Initial font-size is not a Length");
initialValues[PropNames.FONT_SIZE] = prop;
@@ -95,7 +91,7 @@
for (int i = 1; i <= PropNames.LAST_PROPERTY_INDEX; i++) {
if (i == PropNames.FONT_SIZE) continue;
// Set up the initial values for each property
- prop = PropertyConsts.getInitialValue(i);
+ prop = propConsts.getInitialValue(i);
//System.out.println("....Setting initial value: "
// + i + ((prop == null) ? " NULL" : " notNULL"));
initialValues[i] = prop;
1.1.2.15 +234 -501 xml-fop/src/org/apache/fop/fo/Attic/PropertyConsts.java
Index: PropertyConsts.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/Attic/PropertyConsts.java,v
retrieving revision 1.1.2.14
retrieving revision 1.1.2.15
diff -u -r1.1.2.14 -r1.1.2.15
--- PropertyConsts.java 4 Oct 2002 16:08:26 -0000 1.1.2.14
+++ PropertyConsts.java 19 Oct 2002 03:49:04 -0000 1.1.2.15
@@ -26,7 +26,7 @@
import org.apache.fop.fo.FOTree;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.PropNames;
-import org.apache.fop.fo.Properties;
+import org.apache.fop.fo.properties.Property;
import org.apache.fop.fo.expr.PropertyException;
import org.apache.fop.datatypes.Numeric;
import org.apache.fop.datatypes.Ints;
@@ -41,20 +41,11 @@
* property index value, determined from the PropNames class. These arrays
* provide a means of accessing information about the nature of a property
* through the property index value.
- * </p><p>
- * Most of the values in the property-indexed arrays are initialised at run
- * time through the static{} initializers contained in this class. This
- * process is not essential; much of the initialization could be done at
- * compile time by directly initializing individual elements of the arrays,
- * but the arrays would each then have to be kept in sync with one another
- * and with the propertyNames array, and the list of property index constants
- * in the PropNames class. This would greatly increase the risk of errors
- * in the initialization. Speed of startup is here being traded for
- * robustness.
- * </p><p>
+ * <p>Most of these arrays are initialised piecemeal as information is
+ * required about a particular property.
* There are also <tt>HashMap</tt>s which encode the various sets of
* properties which are defined to apply to each of the Flow Objects,
- * and a <tt>BitSet</tt> of those properties which are <i>not</i>
+ * and a <tt>BitSet</tt> of those properties which are
* automatically inherited. The <tt>HashMap</tt>s provide a convenient
* means of specifying the relationship between FOs and properties.
*/
@@ -65,59 +56,87 @@
private static final String packageName = "org.apache.fop.fo";
+ private static final PropertyConsts pconsts;
+ static {
+ try {
+ pconsts = new PropertyConsts();
+ } catch (PropertyException e) {
+ throw new RuntimeException(e.getMessage());
+ }
+ }
+
+ public static final PropertyConsts getPropertyConsts() {
+ return pconsts;
+ }
+
+
/**
- * Single element <tt>Class</tt> array for serial use by static methods.
+ * A Property[] array containing Property objects corresponding to each
+ * of the property indices in <tt>PropNames</tt>.
+ * Initially empty, entries are filled on demand as calls for details
+ * about individual properties are made.
*/
- private static final Class[] oneClass = new Class[1];
+ private final Property[] properties
+ = new Property[PropNames.LAST_PROPERTY_INDEX + 1];
+
/**
- * Two element <tt>Class</tt> array for serial use by static methods.
+ * A Class[] array containing Class objects corresponding to each of the
+ * class names in the classNames array. It is initialized in a
+ * static initializer in parallel to the creation of the class names in
+ * the classNames array. It can be indexed by the property name
+ * constants defined in this file.
*/
- private static final Class[] twoClasses = new Class[2];
+ private final Class[] classes
+ = new Class[PropNames.LAST_PROPERTY_INDEX + 1];
+
/**
- * Single element <tt>Object</tt> array for serial use by static methods.
+ * A HashMap whose elements are an integer index value keyed by a
+ * property name. The index value is the index of the property name in
+ * the PropNames.propertyNames[] array.
+ * It is initialized in a static initializer.
*/
- private static final Object[] oneObject = new Object[1];
+ private final HashMap toIndex
+ = new HashMap(PropNames.LAST_PROPERTY_INDEX + 1);
+
/**
- * Two element <tt>Object</tt> array for serial use by static methods.
+ * An <tt>int[]</tt> containing the <i>inherited</i> values from the
+ * <tt>Property</tt> classes.
*/
- private static final Object[] twoObjects = new Object[2];
- private static final Class intClass = int.class;
- private static final Class integerClass = Integer.class;
+ private final int[] inherited
+ = new int[PropNames.LAST_PROPERTY_INDEX + 1];
/**
- * Get the property index of a property name.
- * @param property <tt>String</tt> name of the FO property
- * @return <tt>int</tt> index of the named FO property in the array of
- * property names.
- * @exception PropertyException if the property name is not found.
+ * A <tt>BitSet</tt> of properties which are normally inherited
+ * (strictly, not not inherited).
+ * It is defined relative to the set of all properties; i.e. the
+ * inheritability of any property can be established by testing the
+ * bit in this set that corresponds to the queried property's index.
+ * <p>The <tt>BitSet</tt> is private and is the basis for
+ * <i>inheritedProperties</i>.
*/
- public static int getPropertyIndex(String property)
- throws PropertyException
- {
- Integer integer = (Integer)toIndex.get(property);
- if (integer == null)
- throw new PropertyException
- ("Property " + property + " not found.");
- return integer.intValue();
- }
+ private final BitSet inheritedprops
+ = new BitSet(PropNames.LAST_PROPERTY_INDEX + 1);
/**
- * Get the property index of a property class name.
- * @param propertyClassName String name of the FO property class
- * @return int index of the named FO property class in the array of
- * property class names.
- * @exception PropertyException if the property class name is not found.
+ * An int[] array of the types of the <i>initialValue</i> field of each
+ * property. The array is indexed by the index value constants that are
+ * defined in the PropNames class in parallel to the
+ * PropNames.propertyNames[] array.
*/
- public static int getPropertyClassIndex(String propertyClass)
- throws PropertyException
- {
- Integer integer =
- (Integer)classToIndex.get(propertyClass);
- if (integer == null)
- throw new PropertyException
- ("Property class " + propertyClass + " not found.");
- return integer.intValue();
- }
+ private final int[] initialValueTypes
+ = new int[PropNames.LAST_PROPERTY_INDEX + 1];
+
+ /**
+ * An int[] array of the values of the <i>dataTypes</i> field of each
+ * property. The array is indexed by the index value constants that are
+ * defined in the PropNames class in parallel to the
+ * PropNames.propertyNames[] array.
+ * <p>
+ * The array is initialized in a static initializer from the values of the
+ * <i>dataTypes</i> field in each property class.
+ */
+ private final int[] datatypes
+ = new int[PropNames.LAST_PROPERTY_INDEX + 1];
/**
* Get the initial value type for a property name.
@@ -126,49 +145,39 @@
* as static final ints in this class. Note that an undefined property
* name will return the constant defined as NOTYPE_IT
*/
- public static int getInitialValueType(String property)
+ public int getInitialValueType(String property)
throws PropertyException
{
// Get the property index then index into the initialvaluetypes array
- return initialValueTypes[getPropertyIndex(property)];
+ return getInitialValueType(PropNames.getPropertyIndex(property));
}
/**
* get the initial value type for a property index.
- * @param propertyIndex int index of the FO property
+ * @param propindex int index of the FO property
* @return int enumerated initialValueType. These constants are defined
- * as static final ints in this class. Note that an undefined property
- * name will return the constant defined as NOTYPE_IT
+ * as static final ints in the Property class.
+ * @throws PropertyException
*/
- public static int getInitialValueType(int propertyIndex) {
- return initialValueTypes[propertyIndex];
+ public int getInitialValueType(int propindex)
+ throws PropertyException
+ {
+ setupProperty(propindex);
+ return initialValueTypes[propindex];
}
/**
* Get the initial value for a property index.
- * @param property <tt>int</tt> index of the property
+ * @param propindex <tt>int</tt> index of the property
* @return <tt>PropertyValue</tt> from property's <i>getInitialValue</i>
* method
* @exception <tt>PropertyException</tt>
*/
- public static PropertyValue getInitialValue(int property)
- throws PropertyException
+ public PropertyValue getInitialValue(int propindex)
+ throws PropertyException
{
- Method method = null;
- try {
- oneClass[0] = intClass;
- method = classes[property].getMethod("getInitialValue", oneClass);
- oneObject[0] = Ints.consts.get(property);
- return (PropertyValue)(method.invoke(null, oneObject));
- } catch (NoSuchMethodException nsme) {
- throw new PropertyException
- ("No getInitialValue method in "
- + classes[property].getName() + ": " + nsme.getMessage());
- } catch (IllegalAccessException iae) {
- throw new PropertyException(iae.getMessage());
- } catch (InvocationTargetException ite) {
- throw new PropertyException(ite);
- }
+ Property property = setupProperty(propindex);
+ return property.getInitialValue(propindex);
}
/**
@@ -178,134 +187,128 @@
* <i>refineParsing</i> method
* @exception <tt>PropertyException</tt>
*/
- public static PropertyValue refineParsing
- (FONode foNode, PropertyValue value)
+ public PropertyValue refineParsing(FONode foNode, PropertyValue value)
throws PropertyException
{
- int property = value.getProperty();
- try {
- twoObjects[0] = foNode;
- twoObjects[1] = value;
- return (PropertyValue)
- (refineparsingmethods[property].invoke(null, twoObjects));
- } catch (IllegalAccessException iae) {
- throw new PropertyException(iae.getMessage());
- } catch (InvocationTargetException ite) {
- throw new PropertyException(ite.getMessage());
- }
+ int propindex = value.getProperty();
+ Property property = setupProperty(propindex);
+ return property.refineParsing(foNode, value);
}
- public static Numeric getMappedNumeric(int property, int enum)
- throws PropertyException
+ /**
+ * Get the <tt>Numeric</tt> value corresponding to an enumerated value.
+ * @param propindex int index of the FO property
+ * @param enum - the integer equivalent of the enumeration keyword.
+ * @return the <tt>Numeric</tt> result.
+ * @throws PropertyException.
+ */
+ public Numeric getMappedNumeric(int propindex, int enum)
+ throws PropertyException
{
- Method method;
- if ((method =
- (Method)(mappednummethods.get(Ints.consts.get(property))))
- == null)
- throw new PropertyException("No mappedLength method in "
- + classes[property].getName());
- try {
- oneObject[0] = Ints.consts.get(enum);
- return (Numeric)(method.invoke(null, oneObject));
- } catch (IllegalAccessException iae) {
- throw new PropertyException(iae.getMessage());
- } catch (InvocationTargetException ite) {
- throw new PropertyException(ite.getMessage());
- }
+ Property property = setupProperty(propindex);
+ if ((datatypes[propindex] & Property.MAPPED_LENGTH) != 0)
+ return property.getMappedLength(enum);
+ else
+ throw new PropertyException
+ ("MAPPED_LENGTH not valid in "
+ + PropNames.getPropertyName(propindex));
}
/**
- * @param property String name of the FO property
+ * @param propindex int index of the FO property
* @return int type of inheritance for this property
* (See constants defined in Properties.)
+ * @throws PropertyException.
*/
- public static int inheritance(String property)
- throws PropertyException
- {
- return inherit[getPropertyIndex(property)];
+ public int inheritance(String property) throws PropertyException {
+ return inheritance(PropNames.getPropertyIndex(property));
}
/**
- * @param propertyIndex int index of the FO property
+ * @param propindex int index of the FO property
* @return int type of inheritance for this property
- * (See constants defined in Properties.)
+ * (See constants defined in Property.)
+ * @throws PropertyException.
*/
- public static int inheritance(int propertyIndex) {
- return inherit[propertyIndex];
+ public int inheritance(int propindex) throws PropertyException {
+ setupProperty(propindex);
+ return inherited[propindex];
}
/**
- * @param propertyIndex int index of the FO property
+ * @param propindex int index of the FO property
+ * @return <tt>boolean</tt> is property inherited?
+ * @throws PropertyException.
+ */
+ public boolean isInherited(int propindex) throws PropertyException {
+ Property property = setupProperty(propindex);
+ return (inherited[propindex] & Property.NO) == 0;
+ }
+
+ /**
+ * @param property String name of the FO property
+ * @return <tt>boolean</tt> is property inherited?
+ * @throws PropertyException.
+ */
+ public boolean isInherited(String property) throws PropertyException {
+ return isInherited(PropNames.getPropertyIndex(property));
+ }
+
+ /**
+ * @param propindex int index of the FO property
* @return <tt>boolean</tt> is property a shorthand?
+ * @throws PropertyException.
*/
- public static boolean isShorthand(int propertyIndex) {
- return (datatypes[propertyIndex] & Properties.SHORTHAND) != 0;
+ public boolean isShorthand(int propindex) throws PropertyException {
+ Property property = setupProperty(propindex);
+ return (datatypes[propindex] & Property.SHORTHAND) != 0;
}
/**
* @param property String name of the FO property
* @return <tt>boolean</tt> is property a shorthand?
+ * @throws PropertyException.
*/
- public static boolean isShorthand(String property)
- throws PropertyException
- {
- return (datatypes[getPropertyIndex(property)] & Properties.SHORTHAND)
- != 0;
+ public boolean isShorthand(String property) throws PropertyException {
+ return isShorthand(PropNames.getPropertyIndex(property));
}
/**
* @param propertyIndex int index of the FO property
* @return <tt>boolean</tt> is property a compound?
+ * @throws PropertyException.
*/
- public static boolean isCompound(int propertyIndex) {
- return (datatypes[propertyIndex] & Properties.COMPOUND) != 0;
+ public boolean isCompound(int propertyIndex) throws PropertyException {
+ Property property = setupProperty(propertyIndex);
+ return (datatypes[propertyIndex] & Property.COMPOUND) != 0;
}
/**
* @param property String name of the FO property
* @return <tt>boolean</tt> is property a compound?
+ * @throws PropertyException.
*/
- public static boolean isCompound(String property)
- throws PropertyException
- {
- return (datatypes[getPropertyIndex(property)] & Properties.COMPOUND)
- != 0;
+ public boolean isCompound(String property) throws PropertyException {
+ return isCompound(PropNames.getPropertyIndex(property));
}
/**
- * Map the String value of an enum to its integer equivalent.
- * @param value the enum text
- * @param values an <tt>ROStringArray</tt> of all of the enum text values.
- * This array is effectively 1-based.
- * @return the integer equivalent of the enum text
- * @exception PropertyException if the enum text is not valid.
+ * @param propertyIndex int index of the FO property
+ * @return <tt>int</tt> dataTypes value.
+ * @throws PropertyException.
*/
- static int enumValueToIndex(String value, ROStringArray values)
- throws PropertyException
- {
- for (int i = 1; i < values.length; i++) {
- if (value.equals(values.get(i))) {
- return i;
- }
- }
- throw new PropertyException("Enum text " + value +" not found.");
+ public int getDataTypes(int propertyIndex) throws PropertyException {
+ Property property = setupProperty(propertyIndex);
+ return datatypes[propertyIndex];
}
/**
- * Map the String value of an enum to its integer equivalent.
- * @param value the enum text
- * @param valuesMap a <tt>Map</tt> mapping enum text to integer
- * equivalent
- * @return the integer equivalent of the enum text
- * @exception PropertyException if the enum text is not valid.
+ * @param property String name of the FO property
+ * @return <tt>int</tt> dataTypes value.
+ * @throws PropertyException.
*/
- static int enumValueToIndex(String value, Map valuesMap)
- throws PropertyException
- {
- Integer i = (Integer) valuesMap.get((Object) value);
- if (i == null)
- throw new PropertyException("Enum text " + value +" not found.");
- return i.intValue();
+ public int getDataTypes(String property) throws PropertyException {
+ return getDataTypes(PropNames.getPropertyIndex(property));
}
/**
@@ -317,383 +320,113 @@
* with the mapped enumeration values.
* @return a <tt>String</tt> with the mapped enumeration text.
*/
- static String enumIndexToMapping(int index, ROStringArray enumMap) {
+ public String enumIndexToMapping(int index, ROStringArray enumMap)
+ {
return enumMap.get(index);
}
/**
- * @param property <tt>int</tt> property index.
+ * @param propindex <tt>int</tt> property index.
* @param enum <tt>String</tt> containing the enumeration text.
* @return <tt>int</tt> constant representing the enumeration value.
* @exception PropertyException
*/
- public static int getEnumIndex(int property, String enum)
+ public int getEnumIndex(int propindex, String enum)
throws PropertyException
{
- // Get the object represented by the enumValues field in the
- // property class
- Object values;
- try {
- values
- = classes[property].getField("enumValues").get(null);
- }
- catch (NoSuchFieldException e) {
- throw new PropertyException(
- "Missing field \"" + e.getMessage() + "\""
- + " in class " + classNames[property]);
- }
- catch (IllegalAccessException e) {
- throw new PropertyException(
- "Illegal access on \"" + e.getMessage() + "\" in class " +
- classNames[property]);
- }
- if (values instanceof Map)
- return enumValueToIndex(enum, (Map)values);
- return enumValueToIndex(enum, (ROStringArray)values);
+ Property property = setupProperty(propindex);
+ return property.getEnumIndex(enum);
}
/**
- * @param property <tt>int</tt> property index.
+ * @param propindex <tt>int</tt> property index.
* @param enumIndex <tt>int</tt> containing the enumeration index.
* @return <tt>String</tt> containing the enumeration text.
* @exception PropertyException
*/
- public static String getEnumText(int property, int enumIndex)
+ public String getEnumText(int propindex, int enumIndex)
throws PropertyException
{
- // Get the object represented by the enumValues field in the
- // property class
- Object enums;
- try {
- enums
- = classes[property].getField("enums").get(null);
- }
- catch (NoSuchFieldException e) {
- throw new PropertyException(
- "Missing field \"" + e.getMessage() + "\""
- + " in class " + classNames[property]);
- }
- catch (IllegalAccessException e) {
- throw new PropertyException(
- "Illegal access on \"" + e.getMessage() + "\" in class " +
- classNames[property]);
- }
- return ((ROStringArray)enums).get(enumIndex);
+ Property property = setupProperty(propindex);
+ return property.getEnumText(enumIndex);
}
/**
- * A String[] array of the property 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
- * property names from the array PropNames.propertyNames into class
- * names by converting the first character of every component word to
- * upper case, and removing all punctuation characters.
- * It can be indexed by the property name constants defined in
- * the PropNames class.
+ * Set up the details of a single property and return the
+ * <tt>Property</tt> object. If the <tt>Property</tt> object
+ * corresponding to the property index has not been resolved before,
+ * derive the Class and Property objects, and extract certain field
+ * values from the Property.
+ * @param propindex - the <tt>int</tt> index.
+ * @return - the <tt>Property</tt> corresponding to the index.
+ * @throws <tt>PropertyException.
*/
- private static final String[] classNames;
-
- /**
- * An ROStringArray of the property class names. This read-only array
- * is derived from <i>classNames</i>, above.
- * It can be indexed by the property name constants defined in
- * the PropNames class.
- */
- public static final ROStringArray propertyClassNames;
-
- /**
- * A Class[] array containing Class objects corresponding to each of the
- * class names in the classNames array. It is initialized in a
- * static initializer in parallel to the creation of the class names in
- * the classNames array. It can be indexed by the property name
- * constants defined in this file.
- */
- private static final Class[] classes;
-
- /**
- * An unmodifiable List of the property classes. This random access list
- * is derived fo <i>classes</i>, above.
- * It can be indexed by the property name constants defined in
- * the PropNames class.
- */
- public static final List propertyClasses;
-
- /**
- * A HashMap whose elements are an integer index value keyed by a
- * property name. The index value is the index of the property name in
- * the PropNames.propertyNames[] array.
- * It is initialized in a static initializer.
- */
- private static final HashMap toIndex;
-
- /**
- * A HashMap whose elements are an integer index value keyed by the name
- * of a property class. the index value is the index of the property
- * class name in the classNames[] array. It is initialized in a
- * static initializer.
- */
- private static final HashMap classToIndex;
-
- /** <p>
- * An int[] array of values specifying the type of inheritance of a
- * property. The array is indexed by the index value constants that are
- * defined in the PropNames class in parallel to the
- * PropNames.propertyNames[] array.
- * </p><p>
- * The array is initialized in a static initializer from the values of the
- * <i>inherited</i> field in each property class.
- */
- private static final int[] inherit;
-
- /**
- * An ROIntArray of the property <i>inherited</i> values.
- * This read-only array is derived from <i>inherit</i>, above.
- * It can be indexed by the property name constants defined in
- * the PropNames class.
- */
- public static final ROIntArray inherited;
-
- /**
- * An <tt>ROBitSet</tt> of properties which are not normally inherited.
- * It is defined relative to the set of all properties; i.e. the
- * non-inheritance of any property can be established by testing the
- * bit in this set that corresponds to the queried property's index.
- */
- public static final ROBitSet nonInheritedProps;
-
- /**
- * A <tt>BitSet</tt> of properties which are not normally inherited.
- * It is defined relative to the set of all properties; i.e. the
- * non-inheritance of any property can be established by testing the
- * bit in this set that corresponds to the queried property's index.
- * <p>The <tt>BitSet</tt> is private and is the basis for
- * <i>nonInheritedProperties</i>.
- */
- private static final BitSet noninheritedprops;
-
- /**
- * An <tt>ROBitSet</tt> of properties which are normally inherited
- * (strictly, not not inherited).
- * It is defined relative to the set of all properties; i.e. the
- * inheritability of any property can be established by testing the
- * bit in this set that corresponds to the queried property's index.
- */
- public static final ROBitSet inheritedProps;
-
- /**
- * A <tt>BitSet</tt> of properties which are normally inherited
- * (strictly, not not inherited).
- * It is defined relative to the set of all properties; i.e. the
- * inheritability of any property can be established by testing the
- * bit in this set that corresponds to the queried property's index.
- * <p>The <tt>BitSet</tt> is private and is the basis for
- * <i>inheritedProperties</i>.
- */
- private static final BitSet inheritedprops;
-
- /** <p>
- * An int[] array of the types of the <i>initialValue</i> field of each
- * property. The array is indexed by the index value constants that are
- * defined in the PropNames class in parallel to the
- * PropNames.propertyNames[] array.
- * </p><p>
- * The array is initialized in a static initializer from the values of the
- * <i>initialValueType</i> field in each property class.
- */
- private static final int[] initialValueTypes;
+ public Property setupProperty(int propindex)
+ throws PropertyException
+ {
+ String cname = "";
+ Class pclass;
+ Property property;
- /** <p>
- * An int[] array of the values of the <i>traitMapping</i> field of each
- * property. The array is indexed by the index value constants that are
- * defined in the PropNames class in parallel to the
- * PropNames.propertyNames[] array.
- * </p><p>
- * The array is initialized in a static initializer from the values of the
- * <i>traitMapping</i> field in each property class.
- */
- private static final int[] traitMappings;
+ if ((property = properties[propindex]) != null) return property;
- /**
- * <p>An int[] array of the values of the <i>dataTypes</i> field of each
- * property. The array is indexed by the index value constants that are
- * defined in the PropNames class in parallel to the
- * PropNames.propertyNames[] array.
- * </p><p>
- * The array is initialized in a static initializer from the values of the
- * <i>dataTypes</i> field in each property class.
- * </p>
- */
- private static final int[] datatypes;
+ // Get the property class name
+ StringTokenizer stoke;
+ stoke = new StringTokenizer
+ (PropNames.getPropertyName(propindex), "-.:");
+ while (stoke.hasMoreTokens()) {
+ String token = stoke.nextToken();
+ String pname = new Character(
+ Character.toUpperCase(token.charAt(0))
+ ).toString() + token.substring(1);
+ cname = cname + pname;
+ }
+ //classNames[propindex] = cname;
- /**
- * An ROIntArray of the property <i>dataTypes</i> values.
- * This read-only array is derived from <i>datatypes</i>, above.
- * It can be indexed by the property name constants defined in
- * the PropNames class.
- */
- public static final ROIntArray dataTypes;
+ // Get the class for this property name
+ String name = packageName + "." + cname;
+ try {
+ //System.out.println("classes["+propindex+"] "+name);//DEBUG
+ pclass = Class.forName(name);
+ classes[propindex] = pclass;
- /**
- * An array of <tt>Method</tt> objects. This array holds, for each
- * property, the <tt>method</tt> object corresponding to the
- * <em>refineParsing</em> method of the property's class.<br/>
- * <em>refineParsing</em> methods defined in individual properties
- * shadow the method in the <em>Properties</em> class.
- */
- private static final Method[] refineparsingmethods;
+ // Instantiate the class
+ property = (Property)(pclass.newInstance());
+ properties[propindex] = property;
- /**
- * An unmodifiable List of the property <i>refineParsing</i> methods.
- * This random access list is derived from <i>refineparsingmethods</i>,
- * above.
- * It can be indexed by the property name constants defined in
- * the PropNames class.
- */
- public static final List refineParsingMethods;
+ // Set inheritance value
+ if ((inherited[propindex] = property.inherited) != Property.NO)
+ inheritedprops.set(propindex);
+ // Set datatypes
+ datatypes[propindex] = property.dataTypes;
- /**
- * A <tt>HashMap</tt> of <tt>Method</tt> objects. It contains the
- * <em>getMappedNumMap</em> methods from properties which support a
- * <tt>MAPPED_NUMERIC</tt> datatype. The map is indexed by the
- * integer index of the property.
- */
- private static final HashMap mappednummethods;
+ // Set initialValueTypes
+ initialValueTypes[propindex] = property.initialValueType;
- /**
- * An unmodifiable map of the property <i>getMappedNumMap</i> methods.
- * It is derived from the <i>mappednummethods</i> map, above.
- */
- public static final Map mappedNumMethods;
+ } catch (ClassNotFoundException e) {
+ throw new PropertyException(e);
+ } catch (IllegalAccessException e) {
+ throw new PropertyException(e);
+ } catch (InstantiationException e) {
+ throw new PropertyException(e);
+ }
- static {
- String prefix = packageName + "." + "Properties" + "$";
- String cname = "";
+ return property;
+ }
- classNames = new String[PropNames.LAST_PROPERTY_INDEX + 1];
- toIndex = new HashMap(PropNames.LAST_PROPERTY_INDEX + 1);
- classToIndex = new HashMap(PropNames.LAST_PROPERTY_INDEX + 1);
- inherit = new int[PropNames.LAST_PROPERTY_INDEX + 1];
- noninheritedprops = new BitSet(PropNames.LAST_PROPERTY_INDEX + 1);
- initialValueTypes = new int[PropNames.LAST_PROPERTY_INDEX + 1];
- traitMappings = new int[PropNames.LAST_PROPERTY_INDEX + 1];
- datatypes = new int[PropNames.LAST_PROPERTY_INDEX + 1];
- classes = new Class[PropNames.LAST_PROPERTY_INDEX + 1];
- refineparsingmethods = new Method[PropNames.LAST_PROPERTY_INDEX + 1];
- mappednummethods = new HashMap();
-
- oneClass[0] = int.class;
- twoClasses[0] = FONode.class;
- twoClasses[1] = PropertyValue.class;
+ private PropertyConsts () throws PropertyException {
+
+ // Set up the toIndex Hashmap with the name of the
+ // property as a key, and the integer index as a value
for (int i = 0; i <= PropNames.LAST_PROPERTY_INDEX; i++) {
- cname = "";
-
- // Set the array of property class names
- StringTokenizer stoke;
- try {
- stoke = new StringTokenizer
- (PropNames.getPropertyName(i), "-.:");
- } catch (PropertyException e) {
- throw new RuntimeException(e.getMessage());
- }
- while (stoke.hasMoreTokens()) {
- String token = stoke.nextToken();
- String pname = new Character(
- Character.toUpperCase(token.charAt(0))
- ).toString() + token.substring(1);
- cname = cname + pname;
- }
- classNames[i] = cname;
-
- // Set up the array of Class objects representing each of the
- // member classes of the Properties class
- String name = prefix + cname;
- try {
- //System.out.println("classes["+i+"] "+name);//DEBUG
- classes[i] = Class.forName(name);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(
- "Class " + name + " could not be found.");
- }
-
- // Set up the toIndex Hashmap with the name of the
- // property as a key, and the integer index as a value
-
- try {
- if (toIndex.put(PropNames.getPropertyName(i),
- Ints.consts.get(i)) != null) {
- throw new RuntimeException(
- "Duplicate values in toIndex for key " +
- PropNames.getPropertyName(i));
- }
- } catch (PropertyException e) {
- throw new RuntimeException(e.getMessage());
- }
-
- // Set up the classToIndex Hashmap with the name of the
- // property class as a key, and the integer index as a value
-
- if (classToIndex.put(classNames[i],
+ if (toIndex.put(PropNames.getPropertyName(i),
Ints.consts.get(i)) != null) {
- throw new RuntimeException(
- "Duplicate values in classToIndex for key " +
- classNames[i]);
- }
-
- try {
- Class vclass = classes[i];
- cname = vclass.getName();
- inherit[i] = classes[i].getField("inherited").getInt(null);
- if (inherit[i] == Properties.NO) noninheritedprops.set(i);
- initialValueTypes[i] =
- classes[i].getField("initialValueType").getInt(null);
- traitMappings[i] =
- classes[i].getField("traitMapping").getInt(null);
- datatypes[i] = classes[i].getField("dataTypes").getInt(null);
- refineparsingmethods[i] =
- classes[i].getMethod("refineParsing", twoClasses);
-
- if ((datatypes[i] & Properties.MAPPED_LENGTH) != 0) {
- mappednummethods.put(Ints.consts.get(i),
- classes[i].getMethod("getMappedLength", oneClass));
- }
- }
- catch (NoSuchFieldException e) {
- throw new RuntimeException(
- "Missing field \"" + e.getMessage() + "\""
- + " in class " + cname);
- }
- catch (NoSuchMethodException e) {
- throw new RuntimeException(
- "Missing method \"" + e.getMessage() + "\""
- + " in class " + cname);
- }
- catch (IllegalAccessException e) {
- throw new RuntimeException(
- "Illegal access on \"" + e.getMessage() + "\" in class " +
- cname);
+ throw new PropertyException(
+ "Duplicate values in toIndex for key " +
+ PropNames.getPropertyName(i));
}
-
}
-
- // Initialise the RO arrays
- inheritedprops = (BitSet)noninheritedprops.clone();
- inheritedprops.flip(1, inheritedprops.length() - 1);
-
- propertyClassNames = new ROStringArray(classNames);
- propertyClasses = Collections.unmodifiableList
- (Arrays.asList(classes));
- inherited = new ROIntArray(inherit);
- nonInheritedProps = new ROBitSet(noninheritedprops);
- inheritedProps = new ROBitSet(inheritedprops);
- dataTypes = new ROIntArray(datatypes);
- refineParsingMethods = Collections.unmodifiableList
- (Arrays.asList(refineparsingmethods));
- mappedNumMethods = Collections.unmodifiableMap(mappednummethods);
-
}
-
-
- private PropertyConsts (){}
}
1.1.2.20 +1 -1 xml-fop/src/org/apache/fop/fo/Attic/PropertySets.java
Index: PropertySets.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/Attic/PropertySets.java,v
retrieving revision 1.1.2.19
retrieving revision 1.1.2.20
diff -u -r1.1.2.19 -r1.1.2.20
1.1.2.8 +35 -3 xml-fop/src/org/apache/fop/fo/Attic/PropNames.java
Index: PropNames.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/Attic/PropNames.java,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -u -r1.1.2.7 -r1.1.2.8
--- PropNames.java 15 Sep 2002 04:54:27 -0000 1.1.2.7
+++ PropNames.java 19 Oct 2002 03:49:04 -0000 1.1.2.8
@@ -9,7 +9,10 @@
package org.apache.fop.fo;
+import java.util.HashMap;
+
import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.datatypes.Ints;
/**
* A class of constants; an array of all property names and the constants
@@ -735,6 +738,25 @@
};
/**
+ * A <tt>hashMap</tt> mapping property names (the keys) to
+ * property integer indices.
+ */
+ private static final HashMap toIndex;
+ static {
+ toIndex = new HashMap(LAST_PROPERTY_INDEX + 1);
+ // Set up the toIndex Hashmap with the name of the
+ // property as a key, and the integer index as a value
+ for (int i = 0; i <= LAST_PROPERTY_INDEX; i++) {
+ if (toIndex.put(propertyNames[i],
+ Ints.consts.get(i)) != null) {
+ throw new RuntimeException(
+ "Duplicate values in toIndex for key " +
+ propertyNames[i]);
+ }
+ }
+ }
+
+ /**
* @param propindex <tt>int</tt> index of the FO property.
* @return <tt>String</tt> name of the indexd FO property.
* @exception PropertyException if the property index is invalid.
@@ -746,6 +768,16 @@
throw new PropertyException
("getPropertyName: index is invalid: " + propindex);
return propertyNames[propindex];
+ }
+
+ /**
+ * @param propindex <tt>int</tt> index of the FO property.
+ * @return <tt>String</tt> name of the indexd FO property.
+ * @exception PropertyException if the property index is invalid.
+ */
+ public static int getPropertyIndex(String name)
+ {
+ return ((Integer)(toIndex.get(name))).intValue();
}
}
1.1.2.2 +1 -1 xml-fop/src/org/apache/fop/fo/Attic/ReferenceAreaFO.java
Index: ReferenceAreaFO.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/Attic/ReferenceAreaFO.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
1.1.2.3 +1 -1 xml-fop/src/org/apache/fop/fo/Attic/ShorthandPropSets.java
Index: ShorthandPropSets.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/Attic/ShorthandPropSets.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
1.1.2.2 +2 -2 xml-fop/src/org/apache/fop/fo/Attic/WritingModes.java
Index: WritingModes.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/Attic/WritingModes.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]