sboag 01/08/05 21:56:51
Modified: java/src/org/apache/xml/utils NamespaceSupport2.java
Log:
Moved anonomous class to PrefixEnumerator, in response
to problems encountered with 1.1.8 build.
Joe may want to fix this in another way, as
I'm sure the anon class is probably a bit
cheaper?
Revision Changes Path
1.4 +66 -61
xml-xalan/java/src/org/apache/xml/utils/NamespaceSupport2.java
Index: NamespaceSupport2.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/utils/NamespaceSupport2.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NamespaceSupport2.java 2001/08/03 18:38:14 1.3
+++ NamespaceSupport2.java 2001/08/06 04:56:51 1.4
@@ -288,13 +288,13 @@
boolean isAttribute)
{
String[] name=currentContext.processName(qName, isAttribute);
- if(name==null)
- return null;
+ if(name==null)
+ return null;
- // JJK: This recopying is required because processName may return
- // a cached result. I Don't Like It. *****
- System.arraycopy(name,0,parts,0,3);
- return parts;
+ // JJK: This recopying is required because processName may return
+ // a cached result. I Don't Like It. *****
+ System.arraycopy(name,0,parts,0,3);
+ return parts;
}
@@ -381,14 +381,14 @@
* @see #getURI */
public Enumeration getPrefixes (String uri)
{
- // JJK: The old code involved creating a vector, filling it
- // with all the matching prefixes, and then getting its
- // elements enumerator. Wastes storage, wastes cycles if we
- // don't actually need them all. Better to either implement
- // a specific enumerator for these prefixes... or a filter
- // around the all-prefixes enumerator, which comes out to
- // roughly the same thing.
-
+ // JJK: The old code involved creating a vector, filling it
+ // with all the matching prefixes, and then getting its
+ // elements enumerator. Wastes storage, wastes cycles if we
+ // don't actually need them all. Better to either implement
+ // a specific enumerator for these prefixes... or a filter
+ // around the all-prefixes enumerator, which comes out to
+ // roughly the same thing.
+
// Vector prefixes = new Vector();
// Enumeration allPrefixes = getPrefixes();
// while (allPrefixes.hasMoreElements()) {
@@ -399,52 +399,57 @@
// }
// return prefixes.elements();
- // Anonymous implementation of Enumeration filter, wrapped
- // aroung the get-all-prefixes version of the operation.
- return new Enumeration()
- {
- private Enumeration allPrefixes;
- private String uri;
- private String lookahead=null;
-
- // Kluge: Since one can't do a constructor on an
- // anonymous class (as far as I know)...
- Enumeration setup(String uri, Enumeration allPrefixes)
- {
- this.uri=uri;
- this.allPrefixes=allPrefixes;
- return this;
- }
-
- public boolean hasMoreElements()
- {
- if(lookahead!=null)
- return true;
-
- while(allPrefixes.hasMoreElements())
- {
- String prefix=(String)allPrefixes.nextElement();
- if(uri.equals(getURI(prefix)))
- {
- lookahead=prefix;
- return true;
- }
- }
- return false;
- }
-
- public Object nextElement()
- {
- if(hasMoreElements())
- {
- String tmp=lookahead;
- lookahead=null;
- return tmp;
- }
- else
- throw new java.util.NoSuchElementException();
- }
- }.setup(uri,getPrefixes());
+ PrefixEnumerator prefixEnumerator = new PrefixEnumerator();
+ return prefixEnumerator.setup(uri,getPrefixes());
+ }
+
+ /**
+ * Implementation of Enumeration filter, wrapped
+ * aroung the get-all-prefixes version of the operation.
+ */
+ class PrefixEnumerator implements Enumeration
+ {
+ private Enumeration allPrefixes;
+ private String uri;
+ private String lookahead=null;
+
+ // Kluge: Since one can't do a constructor on an
+ // anonymous class (as far as I know)...
+ Enumeration setup(String uri, Enumeration allPrefixes)
+ {
+ this.uri=uri;
+ this.allPrefixes=allPrefixes;
+ return this;
+ }
+
+ public boolean hasMoreElements()
+ {
+ if(lookahead!=null)
+ return true;
+
+ while(allPrefixes.hasMoreElements())
+ {
+ String prefix=(String)allPrefixes.nextElement();
+ if(uri.equals(getURI(prefix)))
+ {
+ lookahead=prefix;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Object nextElement()
+ {
+ if(hasMoreElements())
+ {
+ String tmp=lookahead;
+ lookahead=null;
+ return tmp;
+ }
+ else
+ throw new java.util.NoSuchElementException();
+ }
}
@@ -660,7 +665,7 @@
// Save in the cache for future use.
table.put(name[2], name);
tablesDirty = true;
- return name;
+ return name;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]