KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xml > internal > security > signature > ObjectContainer


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17 package com.sun.org.apache.xml.internal.security.signature;
18
19
20
21 import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
22 import com.sun.org.apache.xml.internal.security.utils.Constants;
23 import com.sun.org.apache.xml.internal.security.utils.IdResolver;
24 import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
25 import org.w3c.dom.Document JavaDoc;
26 import org.w3c.dom.Element JavaDoc;
27 import org.w3c.dom.Node JavaDoc;
28
29
30 /**
31  * Handles <code>&lt;ds:Object&gt;</code> elements
32  * <code>Object<code> {@link Element} supply facility which can contain any kind data
33  *
34  *
35  * @author Christian Geuer-Pollmann
36  * $todo$ if we remove childen, the boolean values are not updated
37  */

38 public class ObjectContainer extends SignatureElementProxy {
39
40    /** {@link java.util.logging} logging facility */
41    static java.util.logging.Logger JavaDoc log =
42        java.util.logging.Logger.getLogger(ObjectContainer.class.getName());
43
44    /**
45     * Constructs {@link ObjectContainer}
46     *
47     * @param doc the {@link Document} in which <code>Object</code> element is placed
48     */

49    public ObjectContainer(Document JavaDoc doc) {
50
51       super(doc);
52    }
53
54    /**
55     * Constructs {@link ObjectContainer} from {@link Element}
56     *
57     * @param element is <code>Object</code> element
58     * @param BaseURI the URI of the resource where the XML instance was stored
59     * @throws XMLSecurityException
60     */

61    public ObjectContainer(Element JavaDoc element, String JavaDoc BaseURI)
62            throws XMLSecurityException {
63
64       super(element, BaseURI);
65    }
66
67    /**
68     * Sets the <code>Id</code> attribute
69     *
70     * @param Id <code>Id</code> attribute
71     */

72    public void setId(String JavaDoc Id) {
73
74       if ((this._state == MODE_SIGN) && (Id != null)) {
75          this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
76          IdResolver.registerElementById(this._constructionElement, Id);
77       }
78    }
79
80    /**
81     * Returns the <code>Id</code> attribute
82     *
83     * @return the <code>Id</code> attribute
84     */

85    public String JavaDoc getId() {
86       return this._constructionElement.getAttributeNS(null, Constants._ATT_ID);
87    }
88
89    /**
90     * Sets the <code>MimeType</code> attribute
91     *
92     * @param MimeType the <code>MimeType</code> attribute
93     */

94    public void setMimeType(String JavaDoc MimeType) {
95
96       if ((this._state == MODE_SIGN) && (MimeType != null)) {
97          this._constructionElement.setAttributeNS(null, Constants._ATT_MIMETYPE,
98                                                 MimeType);
99       }
100    }
101
102    /**
103     * Returns the <code>MimeType</code> attribute
104     *
105     * @return the <code>MimeType</code> attribute
106     */

107    public String JavaDoc getMimeType() {
108       return this._constructionElement.getAttributeNS(null, Constants._ATT_MIMETYPE);
109    }
110
111    /**
112     * Sets the <code>Encoding</code> attribute
113     *
114     * @param Encoding the <code>Encoding</code> attribute
115     */

116    public void setEncoding(String JavaDoc Encoding) {
117
118       if ((this._state == MODE_SIGN) && (Encoding != null)) {
119          this._constructionElement.setAttributeNS(null, Constants._ATT_ENCODING,
120                                                 Encoding);
121       }
122    }
123
124    /**
125     * Returns the <code>Encoding</code> attribute
126     *
127     * @return the <code>Encoding</code> attribute
128     */

129    public String JavaDoc getEncoding() {
130       return this._constructionElement.getAttributeNS(null, Constants._ATT_ENCODING);
131    }
132
133    /**
134     * Adds childe Node
135     *
136     * @param node childe Node
137     * @return the new node in the tree.
138     */

139    public Node JavaDoc appendChild(Node JavaDoc node) {
140
141       Node JavaDoc result = null;
142
143       if (this._state == MODE_SIGN) {
144          result = this._constructionElement.appendChild(node);
145       }
146
147       return result;
148    }
149
150    /** @inheritDoc */
151    public String JavaDoc getBaseLocalName() {
152       return Constants._TAG_OBJECT;
153    }
154 }
155
Popular Tags