001: /*
002: * $Id: SOAPElementFactory.java,v 1.12 2006/03/30 00:59:41 ofung Exp $
003: * $Revision: 1.12 $
004: * $Date: 2006/03/30 00:59:41 $
005: */
006:
007: /*
008: * The contents of this file are subject to the terms
009: * of the Common Development and Distribution License
010: * (the License). You may not use this file except in
011: * compliance with the License.
012: *
013: * You can obtain a copy of the license at
014: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
015: * See the License for the specific language governing
016: * permissions and limitations under the License.
017: *
018: * When distributing Covered Code, include this CDDL
019: * Header Notice in each file and include the License file
020: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
021: * If applicable, add the following below the CDDL Header,
022: * with the fields enclosed by brackets [] replaced by
023: * you own identifying information:
024: * "Portions Copyrighted [year] [name of copyright owner]"
025: *
026: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
027: */
028:
029: package javax.xml.soap;
030:
031: /**
032: * <code>SOAPElementFactory</code> is a factory for XML fragments that
033: * will eventually end up in the SOAP part. These fragments
034: * can be inserted as children of the <code>SOAPHeader</code> or
035: * <code>SOAPBody</code> or <code>SOAPEnvelope</code>.
036: *
037: * <p>Elements created using this factory do not have the properties
038: * of an element that lives inside a SOAP header document. These
039: * elements are copied into the XML document tree when they are
040: * inserted.
041: * @deprecated - Use <code>javax.xml.soap.SOAPFactory</code> for creating SOAPElements.
042: * @see javax.xml.soap.SOAPFactory
043: */
044: public class SOAPElementFactory {
045:
046: private SOAPFactory soapFactory;
047:
048: private SOAPElementFactory(SOAPFactory soapFactory) {
049: this .soapFactory = soapFactory;
050: }
051:
052: /**
053: * Create a <code>SOAPElement</code> object initialized with the
054: * given <code>Name</code> object.
055: *
056: * @param name a <code>Name</code> object with the XML name for
057: * the new element
058: *
059: * @return the new <code>SOAPElement</code> object that was
060: * created
061: *
062: * @exception SOAPException if there is an error in creating the
063: * <code>SOAPElement</code> object
064: *
065: * @deprecated Use
066: * javax.xml.soap.SOAPFactory.createElement(javax.xml.soap.Name)
067: * instead
068: *
069: * @see javax.xml.soap.SOAPFactory#createElement(javax.xml.soap.Name)
070: * @see javax.xml.soap.SOAPFactory#createElement(javax.xml.namespace.QName)
071: */
072: public SOAPElement create(Name name) throws SOAPException {
073: return soapFactory.createElement(name);
074: }
075:
076: /**
077: * Create a <code>SOAPElement</code> object initialized with the
078: * given local name.
079: *
080: * @param localName a <code>String</code> giving the local name for
081: * the new element
082: *
083: * @return the new <code>SOAPElement</code> object that was
084: * created
085: *
086: * @exception SOAPException if there is an error in creating the
087: * <code>SOAPElement</code> object
088: *
089: * @deprecated Use
090: * javax.xml.soap.SOAPFactory.createElement(String localName) instead
091: *
092: * @see javax.xml.soap.SOAPFactory#createElement(java.lang.String)
093: */
094: public SOAPElement create(String localName) throws SOAPException {
095: return soapFactory.createElement(localName);
096: }
097:
098: /**
099: * Create a new <code>SOAPElement</code> object with the given
100: * local name, prefix and uri.
101: *
102: * @param localName a <code>String</code> giving the local name
103: * for the new element
104: * @param prefix the prefix for this <code>SOAPElement</code>
105: * @param uri a <code>String</code> giving the URI of the
106: * namespace to which the new element belongs
107: *
108: * @exception SOAPException if there is an error in creating the
109: * <code>SOAPElement</code> object
110: *
111: * @deprecated Use
112: * javax.xml.soap.SOAPFactory.createElement(String localName,
113: * String prefix,
114: * String uri)
115: * instead
116: *
117: * @see javax.xml.soap.SOAPFactory#createElement(java.lang.String, java.lang.String, java.lang.String)
118: */
119: public SOAPElement create(String localName, String prefix,
120: String uri) throws SOAPException {
121: return soapFactory.createElement(localName, prefix, uri);
122: }
123:
124: /**
125: * Creates a new instance of <code>SOAPElementFactory</code>.
126: *
127: * @return a new instance of a <code>SOAPElementFactory</code>
128: *
129: * @exception SOAPException if there was an error creating the
130: * default <code>SOAPElementFactory</code>
131: */
132: public static SOAPElementFactory newInstance() throws SOAPException {
133: try {
134: return new SOAPElementFactory(SOAPFactory.newInstance());
135: } catch (Exception ex) {
136: throw new SOAPException(
137: "Unable to create SOAP Element Factory: "
138: + ex.getMessage());
139: }
140: }
141: }
|