AttrImpl.java revision 72735c62aba8fd2a9420a0f9f83d22543e3c164f
1/*
2 * Copyright (C) 2007 Esmertec AG.
3 * Copyright (C) 2007 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18package com.android.mms.dom;
19
20import org.w3c.dom.Attr;
21import org.w3c.dom.DOMException;
22import org.w3c.dom.Element;
23import org.w3c.dom.Node;
24
25public class AttrImpl extends NodeImpl implements Attr {
26    private String mName;
27    private String mValue;
28
29	/*
30     * Internal methods
31     */
32
33	protected AttrImpl(DocumentImpl owner, String name) {
34		super(owner);
35		mName = name;
36	}
37
38    /*
39     * Attr Interface Methods
40     */
41
42	public String getName() {
43		return mName;
44	}
45
46	public Element getOwnerElement() {
47		// TODO Auto-generated method stub
48		return null;
49	}
50
51	public boolean getSpecified() {
52		return mValue != null;
53	}
54
55	public String getValue() {
56		return mValue;
57	}
58
59	// Instead of setting a <code>Text></code> with the content of the
60	// String value as defined in the specs,  we directly set here the
61	// internal mValue member.
62	public void setValue(String value) throws DOMException {
63		mValue = value;
64	}
65
66    /*
67     * Node Interface Methods
68     */
69
70	@Override
71	public String getNodeName() {
72		return mName;
73	}
74
75	@Override
76	public short getNodeType() {
77		return Node.ATTRIBUTE_NODE;
78	}
79
80	@Override
81	public Node getParentNode() {
82		return null;
83	}
84
85	@Override
86	public Node getPreviousSibling() {
87		return null;
88	}
89
90	@Override
91	public Node getNextSibling() {
92		return null;
93	}
94
95	@Override
96	public void setNodeValue(String nodeValue) throws DOMException {
97        setValue(nodeValue);
98    }
99}
100