sboag 00/11/22 21:56:51
Modified: java/src/org/apache/xalan/serialize FormatterToXML.java
OutputFormat.java
java/src/org/apache/xalan/templates
OutputFormatExtended.java
java/src/org/apache/xml/utils QName.java
Removed: java/src/org/apache/xalan/serialize QName.java
Log:
Removed org.apache.xalan.serialize.QName in favor of
org.apache.utils.QName.
Revision Changes Path
1.6 +1 -1
xml-xalan/java/src/org/apache/xalan/serialize/FormatterToXML.java
Index: FormatterToXML.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/serialize/FormatterToXML.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FormatterToXML.java 2000/11/23 04:57:35 1.5
+++ FormatterToXML.java 2000/11/23 05:56:49 1.6
@@ -77,7 +77,7 @@
import org.apache.xalan.serialize.Serializer;
import org.apache.xalan.serialize.OutputFormat;
import org.apache.xalan.serialize.DOMSerializer;
-import org.apache.xalan.serialize.QName;
+import org.apache.xml.utils.QName;
import org.apache.xml.utils.BoolStack;
import org.apache.xml.utils.TreeWalker;
1.2 +2 -0
xml-xalan/java/src/org/apache/xalan/serialize/OutputFormat.java
Index: OutputFormat.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/serialize/OutputFormat.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- OutputFormat.java 2000/11/13 16:27:02 1.1
+++ OutputFormat.java 2000/11/23 05:56:49 1.2
@@ -56,6 +56,8 @@
*/
package org.apache.xalan.serialize;
+import org.apache.xml.utils.QName;
+
/**
* The output format affects the manner in which a document is
* serialized. The output format determines the output method,
1.12 +3 -3
xml-xalan/java/src/org/apache/xalan/templates/OutputFormatExtended.java
Index: OutputFormatExtended.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/OutputFormatExtended.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- OutputFormatExtended.java 2000/11/23 04:57:56 1.11
+++ OutputFormatExtended.java 2000/11/23 05:56:50 1.12
@@ -411,7 +411,7 @@
m_cdataElementsHasBeenSet = true;
int n = elements.size();
- org.apache.xalan.serialize.QName[] qnames = new QName[n];
+ org.apache.xml.utils.QName[] qnames = new QName[n];
for (int i = 0; i < n; i++)
{
@@ -426,7 +426,7 @@
*
* NEEDSDOC @param elements
*/
- public void setCdataSectionElements(org.apache.xalan.serialize.QName[]
elements)
+ public void setCdataSectionElements(org.apache.xml.utils.QName[] elements)
{
if (m_shouldRecordHasBeenSet)
@@ -616,7 +616,7 @@
* @param nonEscapingElements List of unescaped element tag names
*/
public void setNonEscapingElements(
- org.apache.xalan.serialize.QName[] nonEscapingElements)
+ org.apache.xml.utils.QName[] nonEscapingElements)
{
// TODO: Need to work on this.
1.2 +235 -152 xml-xalan/java/src/org/apache/xml/utils/QName.java
Index: QName.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/QName.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- QName.java 2000/11/23 04:58:45 1.1
+++ QName.java 2000/11/23 05:56:50 1.2
@@ -77,35 +77,29 @@
* is used as the name of the object. The default namespace is not used for
* unprefixed names."
*/
-public class QName extends org.apache.xalan.serialize.QName
- implements java.io.Serializable
+public class QName implements java.io.Serializable
{
/**
- * The XML namespace.
+ * The local name.
*/
- public static final String S_XMLNAMESPACEURI =
- "http://www.w3.org/XML/1998/namespace";
+ protected String _localName;
/**
- * Get the namespace of the qualified name.
- *
- * NEEDSDOC ($objectName$) @return
+ * The namespace URI.
*/
- public String getNamespace()
- {
- return getNamespaceURI();
- }
+ protected String _namespaceURI;
/**
- * Get the local part of the qualified name.
- *
- * NEEDSDOC ($objectName$) @return
+ * The namespace prefix.
*/
- public String getLocalPart()
- {
- return getLocalName();
- }
+ protected String _prefix;
+
+ /**
+ * The XML namespace.
+ */
+ public static final String S_XMLNAMESPACEURI =
+ "http://www.w3.org/XML/1998/namespace";
/**
* The cached hashcode, which is calculated at construction time.
@@ -113,68 +107,47 @@
private int m_hashCode;
/**
- * Return the cached hashcode of the qualified name.
- *
- * NEEDSDOC ($objectName$) @return
+ * Constructs an empty QName.
+ * 20001019: Try making this public, to support Serializable? -- JKESS
*/
- public int hashCode()
- {
- return m_hashCode;
- }
+ public QName(){}
/**
- * Override equals and agree that we're equal if
- * the passed object is a string and it matches
- * the name of the arg.
- *
- * NEEDSDOC @param ns
- * NEEDSDOC @param localPart
+ * Constructs a new QName with the specified namespace URI and
+ * local name.
*
- * NEEDSDOC ($objectName$) @return
+ * @param namespaceURI The namespace URI if known, or null
+ * @param localName The local name
*/
- public boolean equals(String ns, String localPart)
+ public QName(String namespaceURI, String localName)
{
- String thisnamespace = getNamespaceURI();
+ if (localName == null)
+ throw new IllegalArgumentException("Argument 'localName' is null");
- return getLocalName().equals(localPart)
- && (((null != thisnamespace) && (null != ns))
- ? thisnamespace.equals(ns)
- : ((null == thisnamespace) && (null == ns)));
+ _namespaceURI = namespaceURI;
+ _localName = localName;
+ m_hashCode = toString().hashCode();
}
/**
- * Override equals and agree that we're equal if
- * the passed object is a QName and it matches
- * the name of the arg.
+ * Constructs a new QName with the specified namespace URI, prefix
+ * and local name.
*
- * NEEDSDOC @param qname
- *
- * NEEDSDOC ($objectName$) @return
+ * @param namespaceURI The namespace URI if known, or null
+ * @param prefix The namespace prefix is known, or null
+ * @param localName The local name
*/
- public boolean equals(QName qname)
+ public QName(String namespaceURI, String prefix, String localName)
{
- String thisnamespace = getNamespaceURI();
- String thatnamespace = qname.getNamespaceURI();
+ if (localName == null)
+ throw new IllegalArgumentException("Argument 'localName' is null");
- return getLocalName().equals(qname.getLocalName())
- && (((null != thisnamespace) && (null != thatnamespace))
- ? thisnamespace.equals(thatnamespace)
- : ((null == thisnamespace) && (null == thatnamespace)));
- }
-
- public static QName getQNameFromString(String name)
- {
- StringTokenizer tokenizer = new StringTokenizer(name, "{}", false);
- QName qname;
- String s1 = tokenizer.nextToken();
- String s2 = tokenizer.hasMoreTokens() ? tokenizer.nextToken() : null;
- if(null == s2)
- qname = new QName(null, s1);
- else
- qname = new QName(s1, s2);
- return qname;
+ _namespaceURI = namespaceURI;
+ _prefix = prefix;
+ _localName = localName;
+ m_hashCode = toString().hashCode();
}
/**
@@ -185,89 +158,16 @@
*/
public QName(String localName)
{
-
- super(null, localName);
-
- m_hashCode = toString().hashCode();
- }
-
- /**
- * Construct a QName from a namespace and a local name.
- *
- * NEEDSDOC @param ns
- * NEEDSDOC @param localName
- */
- public QName(String ns, String localName)
- {
- super(ns, localName);
+ if (localName == null)
+ throw new IllegalArgumentException("Argument 'localName' is null");
+ _namespaceURI = null;
+ _localName = localName;
m_hashCode = toString().hashCode();
}
/**
- * This function tells if a raw attribute name is a
- * xmlns attribute.
- *
- * NEEDSDOC @param attRawName
- *
- * NEEDSDOC ($objectName$) @return
- */
- public static boolean isXMLNSDecl(String attRawName)
- {
-
- return (attRawName.startsWith("xmlns")
- && (attRawName.equals("xmlns")
- || attRawName.startsWith("xmlns:")));
- }
-
- /**
- * This function tells if a raw attribute name is a
- * xmlns attribute.
- *
- * NEEDSDOC @param attRawName
- *
- * NEEDSDOC ($objectName$) @return
- */
- public static String getPrefixFromXMLNSDecl(String attRawName)
- {
-
- int index = attRawName.indexOf(':');
-
- return (index >= 0) ? attRawName.substring(index + 1) : "";
- }
-
- /**
- * Returns the local name of the given node.
- *
- * NEEDSDOC @param qname
- *
- * NEEDSDOC ($objectName$) @return
- */
- public static String getLocalPart(String qname)
- {
-
- int index = qname.indexOf(':');
-
- return (index < 0) ? qname : qname.substring(index + 1);
- }
-
- /**
- * Returns the local name of the given node.
- *
- * NEEDSDOC @param qname
- *
- * NEEDSDOC ($objectName$) @return
- */
- public static String getPrefixPart(String qname)
- {
-
- int index = qname.indexOf(':');
-
- return (index >= 0) ? qname.substring(0, index) : "";
- }
-
- /**
* Construct a QName from a string, resolving the prefix
* using the given namespace stack. The default namespace is
* not resolved.
@@ -431,24 +331,207 @@
}
/**
+ * Returns the namespace URI. Returns null if the namespace URI
+ * is not known.
+ *
+ * @return The namespace URI, or null
+ */
+ public String getNamespaceURI()
+ {
+ return _namespaceURI;
+ }
+
+ /**
+ * Returns the namespace prefix. Returns null if the namespace
+ * prefix is not known.
+ *
+ * @return The namespace prefix, or null
+ */
+ public String getPrefix()
+ {
+ return _prefix;
+ }
+
+ /**
+ * Returns the local part of the qualified name.
+ *
+ * @return The local part of the qualified name
+ */
+ public String getLocalName()
+ {
+ return _localName;
+ }
+
+ /**
* Return the string representation of the namespace. Performs
* string concatenation, so beware of performance issues.
*
* NEEDSDOC ($objectName$) @return
*/
public String toString()
+ {
+
+ return _prefix != null
+ ? (_prefix + ":" + _localName)
+ : (_namespaceURI != null
+ ? (_namespaceURI + "^" + _localName) : _localName);
+ }
+
+ /**
+ * Get the namespace of the qualified name.
+ *
+ * NEEDSDOC ($objectName$) @return
+ */
+ public String getNamespace()
+ {
+ return getNamespaceURI();
+ }
+
+ /**
+ * Get the local part of the qualified name.
+ *
+ * NEEDSDOC ($objectName$) @return
+ */
+ public String getLocalPart()
+ {
+ return getLocalName();
+ }
+
+ /**
+ * Return the cached hashcode of the qualified name.
+ *
+ * NEEDSDOC ($objectName$) @return
+ */
+ public int hashCode()
{
- return (null != this._namespaceURI)
- ? (this._namespaceURI + ":" + this._localName) : this._localName;
+ return m_hashCode;
}
- /** Serializable objects seem to require a public no-args constructor.
- * Nobody else will be using it, and the object will be promptly
- * overwritten. Should this be putting the object in a recognizable
- * "You shouldn't have done that" state?
- */
- public QName()
- { super();
- /* Deserializer will run after this to fill in the fields */
+ /**
+ * Override equals and agree that we're equal if
+ * the passed object is a string and it matches
+ * the name of the arg.
+ *
+ * NEEDSDOC @param ns
+ * NEEDSDOC @param localPart
+ *
+ * NEEDSDOC ($objectName$) @return
+ */
+ public boolean equals(String ns, String localPart)
+ {
+
+ String thisnamespace = getNamespaceURI();
+
+ return getLocalName().equals(localPart)
+ && (((null != thisnamespace) && (null != ns))
+ ? thisnamespace.equals(ns)
+ : ((null == thisnamespace) && (null == ns)));
+ }
+
+ /**
+ * Override equals and agree that we're equal if
+ * the passed object is a QName and it matches
+ * the name of the arg.
+ *
+ * NEEDSDOC @param qname
+ *
+ * NEEDSDOC ($objectName$) @return
+ */
+ public boolean equals(QName qname)
+ {
+
+ String thisnamespace = getNamespaceURI();
+ String thatnamespace = qname.getNamespaceURI();
+
+ return getLocalName().equals(qname.getLocalName())
+ && (((null != thisnamespace) && (null != thatnamespace))
+ ? thisnamespace.equals(thatnamespace)
+ : ((null == thisnamespace) && (null == thatnamespace)));
+ }
+
+ /**
+ * NEEDSDOC Method getQNameFromString
+ *
+ *
+ * NEEDSDOC @param name
+ *
+ * NEEDSDOC (getQNameFromString) @return
+ */
+ public static QName getQNameFromString(String name)
+ {
+
+ StringTokenizer tokenizer = new StringTokenizer(name, "{}", false);
+ QName qname;
+ String s1 = tokenizer.nextToken();
+ String s2 = tokenizer.hasMoreTokens() ? tokenizer.nextToken() : null;
+
+ if (null == s2)
+ qname = new QName(null, s1);
+ else
+ qname = new QName(s1, s2);
+
+ return qname;
+ }
+
+ /**
+ * This function tells if a raw attribute name is a
+ * xmlns attribute.
+ *
+ * NEEDSDOC @param attRawName
+ *
+ * NEEDSDOC ($objectName$) @return
+ */
+ public static boolean isXMLNSDecl(String attRawName)
+ {
+
+ return (attRawName.startsWith("xmlns")
+ && (attRawName.equals("xmlns")
+ || attRawName.startsWith("xmlns:")));
+ }
+
+ /**
+ * This function tells if a raw attribute name is a
+ * xmlns attribute.
+ *
+ * NEEDSDOC @param attRawName
+ *
+ * NEEDSDOC ($objectName$) @return
+ */
+ public static String getPrefixFromXMLNSDecl(String attRawName)
+ {
+
+ int index = attRawName.indexOf(':');
+
+ return (index >= 0) ? attRawName.substring(index + 1) : "";
+ }
+
+ /**
+ * Returns the local name of the given node.
+ *
+ * NEEDSDOC @param qname
+ *
+ * NEEDSDOC ($objectName$) @return
+ */
+ public static String getLocalPart(String qname)
+ {
+
+ int index = qname.indexOf(':');
+
+ return (index < 0) ? qname : qname.substring(index + 1);
+ }
+
+ /**
+ * Returns the local name of the given node.
+ *
+ * NEEDSDOC @param qname
+ *
+ * NEEDSDOC ($objectName$) @return
+ */
+ public static String getPrefixPart(String qname)
+ {
+
+ int index = qname.indexOf(':');
+
+ return (index >= 0) ? qname.substring(0, index) : "";
}
}