001 /*
002 * $Id: SOAPElementFactory.java,v 1.4.2.7 2004/08/27 19:00:36 goodwin Exp $
003 * $Revision: 1.4.2.7 $
004 * $Date: 2004/08/27 19:00:36 $
005 */
006
007 /*
008 * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
009 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
010 *
011 * This code is free software; you can redistribute it and/or modify it
012 * under the terms of the GNU General Public License version 2 only, as
013 * published by the Free Software Foundation. Sun designates this
014 * particular file as subject to the "Classpath" exception as provided
015 * by Sun in the LICENSE file that accompanied this code.
016 *
017 * This code is distributed in the hope that it will be useful, but WITHOUT
018 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
019 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
020 * version 2 for more details (a copy is included in the LICENSE file that
021 * accompanied this code).
022 *
023 * You should have received a copy of the GNU General Public License version
024 * 2 along with this work; if not, write to the Free Software Foundation,
025 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
026 *
027 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
028 * CA 95054 USA or visit www.sun.com if you need additional information or
029 * have any questions.
030 */
031
032 package javax.xml.soap;
033
034 /**
035 * <code>SOAPElementFactory</code> is a factory for XML fragments that
036 * will eventually end up in the SOAP part. These fragments
037 * can be inserted as children of the <code>SOAPHeader</code> or
038 * <code>SOAPBody</code> or <code>SOAPEnvelope</code>.
039 *
040 * <p>Elements created using this factory do not have the properties
041 * of an element that lives inside a SOAP header document. These
042 * elements are copied into the XML document tree when they are
043 * inserted.
044 * @deprecated - Use <code>javax.xml.soap.SOAPFactory</code> for creating SOAPElements.
045 * @see javax.xml.soap.SOAPFactory
046 */
047 public class SOAPElementFactory {
048
049 private SOAPFactory soapFactory;
050
051 private SOAPElementFactory(SOAPFactory soapFactory) {
052 this .soapFactory = soapFactory;
053 }
054
055 /**
056 * Create a <code>SOAPElement</code> object initialized with the
057 * given <code>Name</code> object.
058 *
059 * @param name a <code>Name</code> object with the XML name for
060 * the new element
061 *
062 * @return the new <code>SOAPElement</code> object that was
063 * created
064 *
065 * @exception SOAPException if there is an error in creating the
066 * <code>SOAPElement</code> object
067 *
068 * @deprecated Use
069 * javax.xml.soap.SOAPFactory.createElement(javax.xml.soap.Name)
070 * instead
071 *
072 * @see javax.xml.soap.SOAPFactory#createElement(javax.xml.soap.Name)
073 * @see javax.xml.soap.SOAPFactory#createElement(javax.xml.namespace.QName)
074 */
075 public SOAPElement create(Name name) throws SOAPException {
076 return soapFactory.createElement(name);
077 }
078
079 /**
080 * Create a <code>SOAPElement</code> object initialized with the
081 * given local name.
082 *
083 * @param localName a <code>String</code> giving the local name for
084 * the new element
085 *
086 * @return the new <code>SOAPElement</code> object that was
087 * created
088 *
089 * @exception SOAPException if there is an error in creating the
090 * <code>SOAPElement</code> object
091 *
092 * @deprecated Use
093 * javax.xml.soap.SOAPFactory.createElement(String localName) instead
094 *
095 * @see javax.xml.soap.SOAPFactory#createElement(java.lang.String)
096 */
097 public SOAPElement create(String localName) throws SOAPException {
098 return soapFactory.createElement(localName);
099 }
100
101 /**
102 * Create a new <code>SOAPElement</code> object with the given
103 * local name, prefix and uri.
104 *
105 * @param localName a <code>String</code> giving the local name
106 * for the new element
107 * @param prefix the prefix for this <code>SOAPElement</code>
108 * @param uri a <code>String</code> giving the URI of the
109 * namespace to which the new element belongs
110 *
111 * @exception SOAPException if there is an error in creating the
112 * <code>SOAPElement</code> object
113 *
114 * @deprecated Use
115 * javax.xml.soap.SOAPFactory.createElement(String localName,
116 * String prefix,
117 * String uri)
118 * instead
119 *
120 * @see javax.xml.soap.SOAPFactory#createElement(java.lang.String, java.lang.String, java.lang.String)
121 */
122 public SOAPElement create(String localName, String prefix,
123 String uri) throws SOAPException {
124 return soapFactory.createElement(localName, prefix, uri);
125 }
126
127 /**
128 * Creates a new instance of <code>SOAPElementFactory</code>.
129 *
130 * @return a new instance of a <code>SOAPElementFactory</code>
131 *
132 * @exception SOAPException if there was an error creating the
133 * default <code>SOAPElementFactory</code>
134 */
135 public static SOAPElementFactory newInstance() throws SOAPException {
136 try {
137 return new SOAPElementFactory(SOAPFactory.newInstance());
138 } catch (Exception ex) {
139 throw new SOAPException(
140 "Unable to create SOAP Element Factory: "
141 + ex.getMessage());
142 }
143 }
144 }
|