import java.util.List;
import java.util.Map;
import java.util.Collections;
+import java.util.Arrays;
/*
* FOAttributes.java
*/
private HashMap foAttrMap = new HashMap(0);
- private int DefAttrNSIndex = XMLNamespaces.DefAttrNSIndex;
+ /**
+ * An sorted array of the keys (property indices) of the values in
+ * <i>foAttrMap</i>.
+ */
+ private Integer[] foAttrKeys = null;
+
+ /**
+ * A static array of <tt>Integer</tt> as a template for the generation
+ * of the <i>foAttrKeys</i> array.
+ */
+ private static Integer[] integerArray
+ = new Integer[] { Ints.consts.get(0) };
private FONode foNode;
int attrUriIndex = foNode.namespaces.getURIIndex(attrUri);
//System.out.println("FONode:" + event);
- if (attrUriIndex == DefAttrNSIndex) {
+ if (attrUriIndex == XMLNamespaces.DefAttrNSIndex) {
// Standard FO namespace
// Catch default namespace declaration here. This seems to
// be a kludge. Should 'xmlns' come through here?
System.out.println("Creating nSpaceAttrMaps");
nSpaceAttrMaps = new ArrayList(attrUriIndex + 1);
// Add the fo list
- for (j = 0; j < DefAttrNSIndex; j++)
+ for (j = 0; j < XMLNamespaces.DefAttrNSIndex; j++)
nSpaceAttrMaps.add(new HashMap(0));
System.out.println("Adding foAttrMap");
tmpHash.put(attrLocalname, attrValue);
}
}
+ // Set up the sorted array of the foAttr keys, if foAttrMap has
+ // any entries.
+ if (foAttrMap.size() > 0) {
+ foAttrKeys = (Integer[])(foAttrMap.keySet().toArray(integerArray));
+ Arrays.sort(foAttrKeys);
+ }
}
/**
+ * Get the default namespace attribute values as an unmodifiable
+ * <tt>Map</tt>.
* @return a unmodifiable <tt>Map</tt> containing the the attribute
* values for all of the default attribute namespace attributes in this
* attribute list, indexed by the property name index from
}
/**
+ * Get the <tt>HashMap</tt> of all default namespace attributes.
* @return <tt>HashMap</tt> <i>foAttrMap</i> containing the the attribute
* values for all of the default attribute namespace attributes in this
* attribute list, indexed by the property name index from
return foAttrMap;
}
+ /**
+ * Get the sorted array of property index keys for the default namespace
+ * attributes.
+ * @return <tt>Integer[]</tt> <i>foAttrKeys</i> containing the the
+ * sorted keys (the property indices from <tt>PropNames</tt>) of the
+ * attribute values for all of the default attribute namespace attributes
+ * in this attribute list.
+ * Warning: This array may be changed by the calling process.
+ */
+ public Integer[] getFoAttrKeys() {
+ return foAttrKeys;
+ }
+
/**
* A convenience method for accessing attribute values from the default
* attribute namespace.
}
/**
+ * Get an unmodifiable <tt>Map</tt> of the attribute values for a
+ * particular namespace.
* @param uriIndex an <tt>int</tt> containing the index of the attribute
* values namespace, maintained in an <tt>XMLEvent</tt> <tt>static</tt>
* array.
* derived from the one maintained in <i>nSpaceAttrMaps</i>.
*/
public Map getAttrMap(int uriIndex) {
- if (uriIndex == DefAttrNSIndex)
+ if (uriIndex == XMLNamespaces.DefAttrNSIndex)
return Collections.unmodifiableMap((Map)foAttrMap);
if (nSpaceAttrMaps != null) {
if (uriIndex >= nSpaceAttrMaps.size()) return null;
}
/**
+ * Get the value of an attribute in a particular namespace.
* @param uriIndex an <tt>int</tt> index of the URIs maintained
* by <tt>XMLEvent</tt>.
* @param localName a <tt>String</tt> with the local name of the
public String getUriAttrValue(int uriIndex, String localName)
throws PropertyException
{
- if (uriIndex == DefAttrNSIndex)
+ if (uriIndex == XMLNamespaces.DefAttrNSIndex)
return getFoAttrValue(PropertyConsts.getPropertyIndex(localName));
return (String)
(((HashMap)nSpaceAttrMaps.get(uriIndex)).get(localName));
// the entries from the merging foAttrs
for (int i = 0; i < attrLen; i++) {
// skip foAttrMap
- if (i == DefAttrNSIndex) continue;
+ if (i == XMLNamespaces.DefAttrNSIndex) continue;
((HashMap) nSpaceAttrMaps.get(i))
.putAll(foAttrs.getAttrMap(i));
}