001    /*
002     * Copyright 2001-2004 The Apache Software Foundation.
003     * 
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     * 
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package javax.xml.soap;
017    
018    /**
019     * <P><CODE>SOAPElementFactory</CODE> is a factory for XML
020     * fragments that will eventually end up in the SOAP part. These
021     * fragments can be inserted as children of the <CODE>
022     * SOAPHeader</CODE> or <CODE>SOAPBody</CODE> or <CODE>
023     * SOAPEnvelope</CODE>.</P>
024     *
025     * <P>Elements created using this factory do not have the
026     * properties of an element that lives inside a SOAP header
027     * document. These elements are copied into the XML document tree
028     * when they are inserted.</P>
029     * @deprecated - Use javax.xml.soap.SOAPFactory for creating SOAPElements.
030     * @see SOAPFactory SOAPFactory
031     */
032    public class SOAPElementFactory {
033    
034        /**
035         * Create a new <code>SOAPElementFactory from a <code>SOAPFactory</code>.
036         *
037         * @param soapfactory  the <code>SOAPFactory</code> to use
038         */
039        private SOAPElementFactory(SOAPFactory soapfactory) {
040            sf = soapfactory;
041        }
042    
043        /**
044         * Create a <CODE>SOAPElement</CODE> object initialized with
045         * the given <CODE>Name</CODE> object.
046         * @param   name a <CODE>Name</CODE> object with
047         *     the XML name for the new element
048         * @return the new <CODE>SOAPElement</CODE> object that was
049         *     created
050         * @throws  SOAPException if there is an error in
051         *     creating the <CODE>SOAPElement</CODE> object
052         * @deprecated Use javax.xml.soap.SOAPFactory.createElement(javax.xml.soap.Name) instead
053         * @see SOAPFactory#createElement(javax.xml.soap.Name) SOAPFactory.createElement(javax.xml.soap.Name)
054         */
055        public SOAPElement create(Name name) throws SOAPException {
056            return sf.createElement(name);
057        }
058    
059        /**
060         * Create a <CODE>SOAPElement</CODE> object initialized with
061         * the given local name.
062         * @param   localName a <CODE>String</CODE> giving
063         *     the local name for the new element
064         * @return the new <CODE>SOAPElement</CODE> object that was
065         *     created
066         * @throws  SOAPException if there is an error in
067         *     creating the <CODE>SOAPElement</CODE> object
068         * @deprecated Use javax.xml.soap.SOAPFactory.createElement(String localName) instead
069         * @see SOAPFactory#createElement(java.lang.String) SOAPFactory.createElement(java.lang.String)
070         */
071        public SOAPElement create(String localName) throws SOAPException {
072            return sf.createElement(localName);
073        }
074    
075        /**
076         * Create a new <CODE>SOAPElement</CODE> object with the
077         * given local name, prefix and uri.
078         * @param   localName a <CODE>String</CODE> giving
079         *     the local name for the new element
080         * @param   prefix the prefix for this <CODE>
081         *     SOAPElement</CODE>
082         * @param   uri a <CODE>String</CODE> giving the
083         *     URI of the namespace to which the new element
084         *     belongs
085         * @return the new <CODE>SOAPElement</CODE> object that was
086         *     created
087         * @throws  SOAPException if there is an error in
088         *     creating the <CODE>SOAPElement</CODE> object
089         * @deprecated Use javax.xml.soap.SOAPFactory.createElement(String localName, String prefix, String uri) instead
090         * @see SOAPFactory#createElement(java.lang.String, java.lang.String, java.lang.String) SOAPFactory.createElement(java.lang.String, java.lang.String, java.lang.String)
091         */
092        public SOAPElement create(String localName, String prefix, String uri)
093                throws SOAPException {
094            return sf.createElement(localName, prefix, uri);
095        }
096    
097        /**
098         * Creates a new instance of <CODE>SOAPElementFactory</CODE>.
099         *
100         * @return a new instance of a <CODE>
101         *     SOAPElementFactory</CODE>
102         * @throws  SOAPException if there was an error creating
103         *     the default <CODE>SOAPElementFactory
104         */
105        public static SOAPElementFactory newInstance() throws SOAPException {
106    
107            try {
108                return new SOAPElementFactory(SOAPFactory.newInstance());
109            } catch (Exception exception) {
110                throw new SOAPException("Unable to create SOAP Element Factory: "
111                                        + exception.getMessage());
112            }
113        }
114    
115        private SOAPFactory sf;
116    }