KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > saaj > AttrImpl


1 /*
2  * Copyright 2004,2005 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 package org.apache.axis2.saaj;
17
18 import org.apache.axis2.om.OMAttribute;
19 import org.w3c.dom.Attr JavaDoc;
20 import org.w3c.dom.Element JavaDoc;
21
22 /**
23  * @author Jayachandra
24  *
25  */

26 public class AttrImpl extends NodeImpl implements Attr JavaDoc {
27     
28     private boolean specified = false;
29     private OMAttribute omAttr;
30     private Element JavaDoc ownerElement=null;
31
32     /**
33      *
34      */

35     public AttrImpl() {
36         super();
37     }
38
39     /**
40      * @param attrib
41      */

42     public AttrImpl(OMAttribute attrib, Element JavaDoc owner) {
43         super(attrib);
44         this.omAttr = attrib;
45         this.ownerElement = owner;
46     }
47     
48     /**
49      * Method getSpecified
50      * Returns true if this attribute value is set by user in the original document,
51      * if so far user didn't set some value to this OR if the user removed this
52      * attribute (may be by calling removeAttribute() on owner element) the specified
53      * value returned should be false
54      * @see org.w3c.dom.Attr#getSpecified()
55      */

56     public boolean getSpecified() {
57         return specified;
58     }
59     
60     /**
61      * Method setSpecified
62      * This method sets the value of the private datamember <code>specified</code>
63      * equals to that of the passed input parameter <code>val</code> and returns the
64      * final value of <code>specified</code> flag
65      * @param val
66      * @return boolean
67      */

68     public boolean setSpecified(boolean val) {
69         this.specified = val;
70         return specified;
71     }
72
73     /**
74      * Method getName
75      * returns the localName of the attribute
76      * @return String
77      * @see org.w3c.dom.Attr#getName()
78      */

79     public String JavaDoc getName() {
80         return omAttr.getLocalName();
81     }
82
83     /**
84      * Method getOwnerElement
85      * returns the <code>Element</code> object to which this attribute is attached
86      * @return Element
87      * @see org.w3c.dom.Attr#getOwnerElement()
88      */

89     public Element JavaDoc getOwnerElement() {
90         return ownerElement;
91     }
92
93     /**
94      * Method getValue
95      * returns the value of this attribute
96      * @return String
97      */

98     public String JavaDoc getValue() {
99         return omAttr.getValue();
100     }
101     
102     /**
103      * Method setValue
104      * This method sets the value of this attribute to the provided input
105      * <code>value</code>
106      * @param value
107      * @return
108      */

109     public void setValue(String JavaDoc value) {
110         omAttr.setValue(value);
111         setSpecified(true);
112     }
113 }
114
Popular Tags