1 /*
2 * $Id: Detail1_2Impl.java,v 1.24 2006/01/27 12:49:45 vj135062 Exp $
3 */
4
5 /*
6 * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 *
9 * This code is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 only, as
11 * published by the Free Software Foundation. Sun designates this
12 * particular file as subject to the "Classpath" exception as provided
13 * by Sun in the LICENSE file that accompanied this code.
14 *
15 * This code is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 * version 2 for more details (a copy is included in the LICENSE file that
19 * accompanied this code).
20 *
21 * You should have received a copy of the GNU General Public License version
22 * 2 along with this work; if not, write to the Free Software Foundation,
23 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24 *
25 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
26 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * have any questions.
28 */
29
30 /**
31 *
32 * @author SAAJ RI Development Team
33 */
34 package com.sun.xml.internal.messaging.saaj.soap.ver1_2;
35
36 import java.util.logging.Logger;
37
38 import javax.xml.namespace.QName;
39 import javax.xml.soap;
40
41 import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
42 import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument;
43 import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
44 import com.sun.xml.internal.messaging.saaj.soap.impl.DetailImpl;
45 import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
46
47 public class Detail1_2Impl extends DetailImpl {
48
49 protected static Logger log =
50 Logger.getLogger(Detail1_2Impl.class.getName(),
51 "com.sun.xml.internal.messaging.saaj.soap.ver1_2.LocalStrings");
52
53 public Detail1_2Impl(SOAPDocumentImpl ownerDocument, String prefix) {
54 super(ownerDocument, NameImpl.createSOAP12Name("Detail", prefix));
55 }
56
57 public Detail1_2Impl(SOAPDocumentImpl ownerDocument) {
58 super(ownerDocument, NameImpl.createSOAP12Name("Detail"));
59 }
60
61 protected DetailEntry createDetailEntry(Name name) {
62 return new DetailEntry1_2Impl(
63 ((SOAPDocument) getOwnerDocument()).getDocument(),
64 name);
65 }
66
67 protected DetailEntry createDetailEntry(QName name) {
68 return new DetailEntry1_2Impl(
69 ((SOAPDocument) getOwnerDocument()).getDocument(),
70 name);
71 }
72
73 /*
74 * Override setEncodingStyle of ElementImpl to restrict adding encodingStyle
75 * attribute to SOAP Detail (SOAP 1.2 spec, part 1, section 5.1.1)
76 */
77 public void setEncodingStyle(String encodingStyle) throws SOAPException {
78 log.severe("SAAJ0403.ver1_2.no.encodingStyle.in.detail");
79 throw new SOAPExceptionImpl("EncodingStyle attribute cannot appear in Detail");
80 }
81
82 public SOAPElement addAttribute(Name name, String value)
83 throws SOAPException {
84 if (name.getLocalName().equals("encodingStyle")
85 && name.getURI().equals(NameImpl.SOAP12_NAMESPACE)) {
86 setEncodingStyle(value);
87 }
88 return super.addAttribute(name, value);
89 }
90
91 public SOAPElement addAttribute(QName name, String value)
92 throws SOAPException {
93 if (name.getLocalPart().equals("encodingStyle")
94 && name.getNamespaceURI().equals(NameImpl.SOAP12_NAMESPACE)) {
95 setEncodingStyle(value);
96 }
97 return super.addAttribute(name, value);
98 }
99 }