You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by jo...@apache.org on 2006/11/24 13:04:29 UTC
svn commit: r478847 [3/3] - in /webservices/jaxme/branches/MAVEN/jaxme-api:
./ src/ src/main/ src/main/java/ src/main/java/javax/
src/main/java/javax/xml/ src/main/java/javax/xml/bind/
src/main/java/javax/xml/bind/helpers/ src/main/java/javax/xml/bind/...
Added: webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/bind/util/JAXBSource.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/bind/util/JAXBSource.java?view=auto&rev=478847
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/bind/util/JAXBSource.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/bind/util/JAXBSource.java Fri Nov 24 04:04:25 2006
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2003, 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ */
+package javax.xml.bind.util;
+
+import java.io.IOException;
+
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.transform.sax.SAXSource;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.DTDHandler;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLFilterImpl;
+
+
+/** This utility class allows to use a JAXB object as the
+ * source of a stylesheet transformation.<br>
+ * If you depend on any methods from
+ * {@link javax.xml.transform.sax.SAXSource}, you should
+ * use this class. In particular, you must not use the
+ * methods
+ * {@link javax.xml.transform.sax.SAXSource#setInputSource(InputSource)},
+ * or
+ * {@link javax.xml.transform.sax.SAXSource#setXMLReader(XMLReader)}
+ * on an instance of <code>JAXBSource</code>.<br>
+ * If you depend on these methods, a replacement for the
+ * <code>JAXBSource</code> can be obtained as follows:
+ * <pre>
+ * javax.xml.bind.JAXBContext context;
+ * javax.xml.bind.Element object;
+ * java.io.StringWriter sw = new java.io.StringWriter();
+ * context.createMarshaller().marshal(object, sw);
+ * org.xml.sax.InputSource isource = new org.xml.sax.InputSource(new java.io.StringReader(sw.toString()));
+ * javax.xml.transform.sax.SAXSource source = new javax.xml.transform.sax.SAXSource(isource);
+ * </pre>
+ *
+ * @author JSR-31
+ * @since JAXB1.0
+ */
+public class JAXBSource extends SAXSource {
+ /** This private class basically wraps a marshaller and calls its marshal
+ * method when the parse methods are called on the XMLReader.
+ **/
+ private class JAXBSourceXMLReader implements XMLReader {
+ private EntityResolver resolver;
+ private DTDHandler dtdHandler;
+ private ErrorHandler errorHandler;
+ private XMLFilterImpl contentHandlerProxy = new XMLFilterImpl();
+
+ public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
+ if (name.equals("http://xml.org/sax/features/namespaces")
+ || name.equals("http://xml.org/sax/features/namespace-prefixes")) {
+ return true;
+ } else {
+ throw new SAXNotRecognizedException("Unknown feature: " + name);
+ }
+ }
+
+ public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException {
+ if(name.equals("http://xml.org/sax/features/namespaces")
+ || name.equals("http://xml.org/sax/features/namespace-prefixes")) {
+ if(!value) {
+ throw new SAXNotSupportedException("The feature " + name + " cannot be disabled.");
+ }
+ } else {
+ throw new SAXNotRecognizedException("Unknown feature: " + name);
+ }
+ }
+
+ public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
+ throw new SAXNotRecognizedException("Unknown property: " + name);
+ }
+
+ public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException {
+ throw new SAXNotRecognizedException("Unknown property: " + name);
+ }
+
+ public EntityResolver getEntityResolver() {
+ return resolver;
+ }
+
+ public void setEntityResolver(EntityResolver resolver) {
+ this.resolver = resolver;
+ }
+
+ public DTDHandler getDTDHandler() {
+ return dtdHandler;
+ }
+
+ public void setDTDHandler(DTDHandler handler) {
+ this.dtdHandler = handler;
+ }
+
+ public ContentHandler getContentHandler() {
+ return contentHandlerProxy.getContentHandler();
+ }
+
+ public void setContentHandler(ContentHandler handler) {
+ contentHandlerProxy.setContentHandler(handler);
+ }
+
+ public ErrorHandler getErrorHandler() {
+ return errorHandler;
+ }
+
+ public void setErrorHandler(ErrorHandler handler) {
+ errorHandler = handler;
+ }
+
+ public void parse(String systemId) throws IOException, SAXException {
+ throw new IllegalStateException("The XMLReader created by a JAXBSource must not be used to parse a system ID.");
+ }
+
+ public void parse(InputSource pInput) throws IOException, SAXException {
+ if (pInput != inputSource) {
+ throw new IllegalArgumentException("The XMLReader created by an instance of JAXBSource can only be used to parse the InputSource returned by the same JAXBSource.");
+ }
+ try {
+ marshaller.marshal(contentObject, contentHandlerProxy);
+ } catch(JAXBException e) {
+ SAXParseException spe = new SAXParseException(e.getMessage(), null, null, -1, -1, e);
+ if(errorHandler!=null) {
+ errorHandler.fatalError(spe);
+ }
+ throw spe;
+ }
+ }
+ }
+
+ private final Marshaller marshaller;
+ private final Object contentObject;
+ private final InputSource inputSource;
+
+ /** <p>Creates a new instance of JAXBSource. The given
+ * {@link javax.xml.bind.JAXBContext} will be used to
+ * construct a {@link javax.xml.bind.Marshaller} and
+ * invoke the constructor
+ * {@link #JAXBSource(javax.xml.bind.Marshaller, Object)}.</p>
+ */
+ public JAXBSource(javax.xml.bind.JAXBContext pContext, Object pObject) throws JAXBException {
+ this(pContext.createMarshaller(), pObject);
+ }
+
+ /** <p>Creates a new instance of JAXBSource.</p>
+ */
+ public JAXBSource(javax.xml.bind.Marshaller pMarshaller, Object pObject) throws JAXBException {
+ marshaller = pMarshaller;
+ contentObject = pObject;
+ inputSource = new InputSource();
+ super.setInputSource(inputSource);
+ super.setXMLReader(new JAXBSourceXMLReader());
+ }
+}
Added: webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/bind/util/ValidationEventCollector.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/bind/util/ValidationEventCollector.java?view=auto&rev=478847
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/bind/util/ValidationEventCollector.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/bind/util/ValidationEventCollector.java Fri Nov 24 04:04:25 2006
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2003, 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ */
+package javax.xml.bind.util;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.ValidationEvent;
+import javax.xml.bind.ValidationEventHandler;
+
+
+/** <p>Simple implementation of a {@link javax.xml.bind.ValidationEventHandler},
+ * which simply collects all the events, regardless whether they
+ * are warnings, errors, or fatal errors. You may retrieve these events
+ * at a later time using {@link #getEvents()}.</p>
+ *
+ * @author JSR-31
+ * @since JAXB1.0
+ */
+public class ValidationEventCollector implements ValidationEventHandler {
+ private List events = new ArrayList();
+
+ /** <p>Creates a new instance of <code>ValidationEventCollector</code>.</p>
+ */
+ public ValidationEventCollector() {
+ }
+
+ /** <p>Returns the events collected so far. Empty array, if no
+ * events have been found.</p>
+ */
+ public ValidationEvent[] getEvents() {
+ return (ValidationEvent[]) events.toArray(new ValidationEvent[events.size()]);
+ }
+
+ /** <p>Clears the list of collected warnings, errors, and fatal errors.</p>
+ */
+ public void reset() {
+ events.clear();
+ }
+
+ /** <p>Returns whether any event has been collected.</p>
+ */
+ public boolean hasEvents() {
+ return !events.isEmpty();
+ }
+
+ /** <p>Will always return true.</p>
+ */
+ public boolean handleEvent(ValidationEvent pEvent) {
+ events.add(pEvent);
+ return true;
+ }
+}
Added: webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/bind/util/package.html
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/bind/util/package.html?view=auto&rev=478847
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/bind/util/package.html (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/bind/util/package.html Fri Nov 24 04:04:25 2006
@@ -0,0 +1,29 @@
+<!--
+
+ Copyright 2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<html>
+ <head>
+ <title>
+Package Documentation for javax.xml.bind.util Package
+ </title>
+</head>
+ <body bgcolor="white">
+ <p>
+Utility classes used by the JAXB standard.
+ </p>
+</body>
+</html>
\ No newline at end of file
Added: webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/namespace/NamespaceContext.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/namespace/NamespaceContext.java?view=auto&rev=478847
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/namespace/NamespaceContext.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/namespace/NamespaceContext.java Fri Nov 24 04:04:25 2006
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2003, 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ */
+package javax.xml.namespace;
+
+/** <p>The <code>NamespaceContext</code> interface is a helper tool for
+ * XML parsing applications which need to know the mappings between XML
+ * namespace prefixes and namespace URI's. As such, it is closely related
+ * to the events
+ * {@link org.xml.sax.ContentHandler#startPrefixMapping(String,String)},
+ * and {@link org.xml.sax.ContentHandler#endPrefixMapping(String)} in
+ * {@link org.xml.sax.ContentHandler}.</p>
+ * <p>In what follows, it is important to note, that a single prefix
+ * can only be mapped to a single namespace URI at any time. However,
+ * the converse is not true: Multiple prefixes can be mapped to the
+ * same namespace URI's.</p>
+ * <p>For example, in the case of an XML Schema parser, an instance
+ * of <code>NamespaceContext</code> might be used to resolve the namespace
+ * URI's of referenced data types, and element or attribute names, which
+ * are typically given as qualified names, including a prefix and a local
+ * name.</p>
+ *
+ * @author JSR-31
+ * @since JAXB 1.0
+ */
+public interface NamespaceContext {
+ /** <p>Given a prefix, returns the namespace URI associated with the prefix.
+ * More precisely, the following rules apply:
+ * <table border="1">
+ * <tr><th>Prefix (Input)</th><th>Namespace URI (Output)</th></tr>
+ * <tr><th>{@link javax.xml.XMLConstants#DEFAULT_NS_PREFIX} ("")</th>
+ * <td>The current default namespace URI or null, if there is no
+ * such default. (In which case the absence of a prefix indicates
+ * the absence of a namespace URI.)</td></tr>
+ * <tr><th>{@link javax.xml.XMLConstants#XML_NS_PREFIX} ("xml")</th>
+ * <td>{@link javax.xml.XMLConstants#XML_NS_URI} ("http://www.w3.org/XML/1998/namespace")</td></tr>
+ * <tr><th>{@link javax.xml.XMLConstants#XMLNS_ATTRIBUTE} ("xmlns")</th>
+ * <td>{@link javax.xml.XMLConstants#XMLNS_ATTRIBUTE_NS_URI} ("http://www.w3.org/2000/xmlns/")</td>
+ * </tr>
+ * <tr><th>Any other prefix</th><td>The namespace URI currently mapped to the
+ * prefix or null, if no such mapping is established.</td></tr>
+ * </table></p>
+ * @param pPrefix The prefix being looked up in the list of mappings.
+ * @return The Namespace URI to which the input prefix is currently mapped
+ * or null, if there is no such mapping.
+ * @throws IllegalArgumentException The input prefix is null.
+ */
+ public String getNamespaceURI(String pPrefix);
+
+
+ /** <p>This method returns a prefix, which is currently mapped to the given
+ * namespace URI. Note, that multiple prefixes may be mapped to the namespace
+ * URI, in which case the returned prefix is undetermined. Do not make any
+ * assumptions on the order in such cases. It is a better choice to use
+ * {@link #getPrefixes(String)} instead, if you depend on some order
+ * <table border="1">
+ * <tr><th>Namespace URI (Input)</th><th>Prefix (Output)</th></tr>
+ * <tr><th>Current default namespace URI</th>
+ * <td>{@link javax.xml.XMLConstants#DEFAULT_NS_PREFIX} ("")</td></tr>
+ * <tr><th>{@link javax.xml.XMLConstants#XML_NS_URI} ("http://www.w3.org/XML/1998/namespace")</th>
+ * <td>{@link javax.xml.XMLConstants#XML_NS_PREFIX} ("xml")</td></tr>
+ * <tr><th>{@link javax.xml.XMLConstants#XMLNS_ATTRIBUTE_NS_URI} ("http://www.w3.org/2000/xmlns/")</th>
+ * <td>{@link javax.xml.XMLConstants#XMLNS_ATTRIBUTE}</td></tr>
+ * </table></p>
+ *
+ * @param pNamespaceURI The namespace URI being looked up in the list of mappings.
+ * @return A prefix currently mapped to the given namespace URI or null, if there
+ * is no such mapping
+ * @throws IllegalArgumentException The input URI is null
+ */
+ public java.lang.String getPrefix(java.lang.String pNamespaceURI);
+
+
+ /** <p>This method returns a collection of prefixes, which are currently mapped
+ * to the given namespace URI. Note, that the collection may contain more than
+ * one prefix, in which case the order is undetermined. If you do not depend
+ * on a certain order and any prefix will do, you may choose to use
+ * {@link #getPrefix(String)} instead. The following table describes the
+ * returned values in more details:
+ * <table border="1">
+ * <tr><th>Namespace URI (Input)</th><th>Prefix collection (Output)</th></tr>
+ * <tr><th>{@link javax.xml.XMLConstants#XML_NS_URI} ("http://www.w3.org/XML/1998/namespace")</th>
+ * <td>Collection with a single element: {@link javax.xml.XMLConstants#XML_NS_PREFIX} ("xml")</td></tr>
+ * <tr><th>{@link javax.xml.XMLConstants#XMLNS_ATTRIBUTE_NS_URI} ("http://www.w3.org/2000/xmlns/")</th>
+ * <td>Collection with a single element: {@link javax.xml.XMLConstants#XMLNS_ATTRIBUTE}</td></tr>
+ * </table></p>
+ *
+ * @param pNamespaceURI The namespace URI being looked up in the list of
+ * mappings or null, if there is no such mapping.
+ * @return An unmodifiable {@link java.util.Iterator}: Using it's
+ * {@link java.util.Iterator#remove()} method throws an
+ * {@link UnsupportedOperationException}.
+ * @throws IllegalStateException The input URI is null
+ */
+ public java.util.Iterator getPrefixes(java.lang.String pNamespaceURI);
+}
Added: webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/namespace/QName.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/namespace/QName.java?view=auto&rev=478847
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/namespace/QName.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/namespace/QName.java Fri Nov 24 04:04:25 2006
@@ -0,0 +1,176 @@
+/*
+ * Copyright 2003, 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ */
+package javax.xml.namespace;
+
+import java.io.Serializable;
+
+
+/** <p>A <code>QName</code> is a qualified name, as specified by
+ * XML Schema Part2: Datatypes specification, Namespaces in XML, Namespaces in XML Errata.
+ * A qualified name is made up of a namespace URI, a local part, and a prefix.
+ * The prefix is not really a part of the <code>QName</code> and
+ * remains only to provide lexical information. It is <em>not</em>
+ * used in the {@link #equals(Object)} or {@link #hashCode()}
+ * methods.</p>
+ * <p>Namespace URI and prefix may be omitted, in which case the
+ * default value "" (empty string) is used.</p>
+ * <p>Instances of <code>QName</code> are immutable. You may safely
+ * store references.</p>
+ */
+public class QName implements Serializable {
+ private final String namespaceURI, localPart, prefix;
+
+ /** <p>Creates a new <code>QName</code> with the given
+ * <code>pNamespaceURI</code> and <code>pLocalPart</code>. The
+ * prefix is set to "" (empty string).</p>
+ * @param pNamespaceURI The namespace URI; may be null, in which case
+ * the default value "" (empty string) is used.
+ * @param pLocalPart The local part.
+ * @throws IllegalArgumentException The local part was null.
+ */
+ public QName(String pNamespaceURI, String pLocalPart) {
+ if (pLocalPart == null) {
+ throw new IllegalArgumentException("The local part must not be null");
+ }
+ namespaceURI = pNamespaceURI == null ? "" : pNamespaceURI;
+ localPart = pLocalPart;
+ prefix = "";
+ }
+
+ /** <p>Creates a new <code>QName</code> with the given
+ * <code>pNamespaceURI</code>, <code>pLocalPart</code>, and
+ * <code>pPrefix</code>.</p>
+ * @param pNamespaceURI The namespace URI; may be null, in which case
+ * the default value "" (empty string) is used.
+ * @param pLocalPart The local part.
+ * @param pPrefix The prefix. Must not be null. Use "" (empty string)
+ * to indicate that no namespace URI is present or the namespace
+ * URI is not relevant.
+ * @throws IllegalArgumentException The local part or the prefix was null.
+ */
+ public QName(String pNamespaceURI, String pLocalPart, java.lang.String pPrefix) {
+ if (pLocalPart == null) {
+ throw new IllegalArgumentException("The local part must not be null");
+ }
+ if (pPrefix == null) {
+ throw new IllegalArgumentException("The prefix must not be null");
+ }
+ namespaceURI = pNamespaceURI == null ? "" : pNamespaceURI;
+ localPart = pLocalPart;
+ prefix = pPrefix;
+ }
+
+ /** <p>Creates a new <code>QName</code> with the given
+ * <code>pLocalPart</code>, the namespace URI "" (empty string),
+ * and the prefix "" (empty string).</p>
+ * @param pLocalPart The local part.
+ * @throws IllegalArgumentException The local part or the prefix was null.
+ */
+ public QName(String pLocalPart) {
+ if (pLocalPart == null) {
+ throw new IllegalArgumentException("The local part must not be null");
+ }
+ namespaceURI = "";
+ localPart = pLocalPart;
+ prefix = "";
+ }
+
+ /** <p>Returns the namespace URI.</p>
+ * @return Namespace URI or "" (empty string) to indicate the absence
+ * of a namespace.
+ */
+ public String getNamespaceURI() {
+ return namespaceURI;
+ }
+
+ /** <p>Returns the local part of the <code>QName</code>.</p>
+ * @return The local part.
+ */
+ public String getLocalPart() {
+ return localPart;
+ }
+
+ /** <p>Returns the namespace prefix.</p>
+ * @return The namespace prefix or "" (empty string) to indicate the
+ * default namespace
+ */
+ public String getPrefix() {
+ return prefix;
+ }
+
+ /** <p>Returns true, if
+ * <ul>
+ * <li><code>pOther</code> instanceof QName</li>
+ * <li>getNamespaceURI().equals(pOther.getNamespaceURI())</li>
+ * <li>getLocalPart().equals(pOther.getLocalPart())</li>
+ * </ul>
+ * <em>Note</em>: The prefix is ignored.</p>
+ */
+ public boolean equals(Object pOther) {
+ if (!(pOther instanceof QName)) {
+ return false;
+ }
+ QName other = (QName) pOther;
+ return namespaceURI.equals(other.namespaceURI) && localPart.equals(other.localPart);
+ }
+
+ /** <p>Returns the <code>QName</code>'s hash code.
+ * The prefix is ignored when calculating the hash code.</p>
+ */
+ public int hashCode() {
+ return namespaceURI.hashCode() + localPart.hashCode();
+ }
+
+ /** <p>Converts the QName into a string representation. The current
+ * implementation returns the local part, if the namespace URI is
+ * "" (empty string). Otherwise returns "{" + namespaceURI + "}" + localPart.
+ * The prefix is ignored.</p>
+ * <p>The representation is subject to changes, as there is currently no
+ * standard representation for a <code>QName</code>. You should use this
+ * method for debugging or logging purposes only.</p>
+ */
+ public java.lang.String toString() {
+ return namespaceURI.length() == 0 ?
+ localPart : "{" + namespaceURI + "}" + localPart;
+ }
+
+ /** <p>Parses the given string representation of a <code>pQName</code>.
+ * The <code>QName</code> is expected to have the same representation
+ * than returned by {@link #toString()}.</p>
+ * <p>It is not possible to specify a prefix. The returned
+ * <code>QName</code> will always have the prefix "" (empty string).</p>
+ * @param pQName String representation of a QName, as generated by
+ * {@link #toString()}.
+ * @return QName with the prefix "" (empty string)
+ * @throws IllegalArgumentException The given <code>pQName</code>
+ * was null or empty.
+ */
+ public static QName valueOf(String pQName) {
+ if (pQName == null) {
+ throw new IllegalArgumentException("The string representation of a QName must not be null.");
+ }
+ if (pQName.charAt(0) == '{') {
+ int end = pQName.indexOf('}', 1);
+ if (end == -1) {
+ throw new IllegalArgumentException("Expected a terminator ('}') of the namespace URI.");
+ }
+ return new QName(pQName.substring(1, end), pQName.substring(end+1));
+ } else {
+ return new QName(pQName);
+ }
+ }
+}
Added: webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/namespace/package.html
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/namespace/package.html?view=auto&rev=478847
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/namespace/package.html (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/namespace/package.html Fri Nov 24 04:04:25 2006
@@ -0,0 +1,29 @@
+<!--
+
+ Copyright 2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<html>
+ <head>
+ <title>
+Package Documentation for javax.xml.namespace Package
+ </title>
+</head>
+ <body bgcolor="white">
+ <p>
+Clean room implementation of the JAXP standard namespace classes.
+ </p>
+</body>
+</html>
\ No newline at end of file
Added: webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/package.html
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/package.html?view=auto&rev=478847
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/package.html (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-api/src/main/java/javax/xml/package.html Fri Nov 24 04:04:25 2006
@@ -0,0 +1,31 @@
+<!--
+
+ Copyright 2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<html>
+ <head>
+ <title>
+Package Documentation for javax.xml Package
+ </title>
+</head>
+ <body bgcolor="white">
+ <p>
+This package contains the
+<a href='http://ws.apache.org/jaxme/api/index.html'>JaxMeAPI</a>,
+a clean room implementation of the JAXB API.
+ </p>
+</body>
+</html>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org