View Javadoc
1   /*
2    * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4    *
5    * This code is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU General Public License version 2 only, as
7    * published by the Free Software Foundation.  Oracle designates this
8    * particular file as subject to the "Classpath" exception as provided
9    * by Oracle in the LICENSE file that accompanied this code.
10   *
11   * This code is distributed in the hope that it will be useful, but WITHOUT
12   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14   * version 2 for more details (a copy is included in the LICENSE file that
15   * accompanied this code).
16   *
17   * You should have received a copy of the GNU General Public License version
18   * 2 along with this work; if not, write to the Free Software Foundation,
19   * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20   *
21   * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22   * or visit www.oracle.com if you need additional information or have any
23   * questions.
24   */
25  
26  package javax.xml.soap;
27  
28  /**
29   * A representation of an XML name.  This interface provides methods for
30   * getting the local and namespace-qualified names and also for getting the
31   * prefix associated with the namespace for the name. It is also possible
32   * to get the URI of the namespace.
33   * <P>
34   * The following is an example of a namespace declaration in an element.
35   * <PRE>
36   *   &lt;wombat:GetLastTradePrice xmlns:wombat="http://www.wombat.org/trader"&gt;
37   * </PRE>
38   * ("xmlns" stands for "XML namespace".)
39   * The following
40   * shows what the methods in the <code>Name</code> interface will return.
41   * <UL>
42   *  <LI><code>getQualifiedName</code> will return "prefix:LocalName" =
43   *      "WOMBAT:GetLastTradePrice"
44   *  <LI><code>getURI</code> will return "http://www.wombat.org/trader"
45   *  <LI><code>getLocalName</code> will return "GetLastTracePrice"
46   *  <LI><code>getPrefix</code> will return "WOMBAT"
47   * </UL>
48   * <P>
49   * XML namespaces are used to disambiguate SOAP identifiers from
50   * application-specific identifiers.
51   * <P>
52   * <code>Name</code> objects are created using the method
53   * <code>SOAPEnvelope.createName</code>, which has two versions.
54   * One method creates <code>Name</code> objects with
55   * a local name, a namespace prefix, and a namespace URI.
56   *  and the second creates <code>Name</code> objects with just a local name.
57   * The following line of
58   * code, in which <i>se</i> is a <code>SOAPEnvelope</code> object, creates a new
59   * <code>Name</code> object with all three.
60   * <PRE>
61   *     Name name = se.createName("GetLastTradePrice", "WOMBAT",
62   *                                "http://www.wombat.org/trader");
63   * </PRE>
64   * The following line of code gives an example of how a <code>Name</code> object
65   * can be used. The variable <i>element</i> is a <code>SOAPElement</code> object.
66   * This code creates a new <code>SOAPElement</code> object with the given name and
67   * adds it to <i>element</i>.
68   * <PRE>
69   *     element.addChildElement(name);
70   * </PRE>
71   * <P>
72   * The <code>Name</code> interface may be deprecated in a future release of SAAJ
73   * in favor of <code>javax.xml.namespace.QName<code>
74   * @see SOAPEnvelope#createName(String, String, String) SOAPEnvelope.createName
75   * @see SOAPFactory#createName(String, String, String) SOAPFactory.createName
76   */
77  public interface Name {
78      /**
79       * Gets the local name part of the XML name that this <code>Name</code>
80       * object represents.
81       *
82       * @return a string giving the local name
83       */
84      String getLocalName();
85  
86      /**
87       * Gets the namespace-qualified name of the XML name that this
88       * <code>Name</code> object represents.
89       *
90       * @return the namespace-qualified name as a string
91       */
92      String getQualifiedName();
93  
94      /**
95       * Returns the prefix that was specified when this <code>Name</code> object
96       * was initialized. This prefix is associated with the namespace for the XML
97       * name that this <code>Name</code> object represents.
98       *
99       * @return the prefix as a string
100      */
101     String getPrefix();
102 
103     /**
104      * Returns the URI of the namespace for the XML
105      * name that this <code>Name</code> object represents.
106      *
107      * @return the URI as a string
108      */
109     String getURI();
110 }