author | mkos |
Sun, 30 Dec 2012 00:00:00 +0100 | |
changeset 22678 | ac1ea46be942 |
parent 12009 | 4abb694f273a |
permissions | -rw-r--r-- |
12009 | 1 |
/* |
22678
ac1ea46be942
8029237: Update copyright year to match last edit in jaxws repository for 2012
mkos
parents:
12009
diff
changeset
|
2 |
* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. |
12009 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
* |
|
25 |
* THIS FILE WAS MODIFIED BY SUN MICROSYSTEMS, INC. |
|
26 |
*/ |
|
27 |
||
28 |
package com.sun.xml.internal.fastinfoset.stax.events; |
|
29 |
||
30 |
import javax.xml.namespace.QName; |
|
31 |
import javax.xml.stream.events.Attribute; |
|
32 |
||
33 |
||
34 |
||
35 |
public class AttributeBase extends EventBase implements Attribute |
|
36 |
||
37 |
{ |
|
38 |
//an Attribute consists of a qualified name and value |
|
39 |
private QName _QName; |
|
40 |
private String _value; |
|
41 |
||
42 |
private String _attributeType = null; |
|
43 |
//A flag indicating whether this attribute was actually specified in the start-tag |
|
44 |
//of its element or was defaulted from the schema. |
|
45 |
private boolean _specified = false; |
|
46 |
||
47 |
public AttributeBase(){ |
|
48 |
super(ATTRIBUTE); |
|
49 |
} |
|
50 |
||
51 |
public AttributeBase(String name, String value) { |
|
52 |
super(ATTRIBUTE); |
|
53 |
_QName = new QName(name); |
|
54 |
_value = value; |
|
55 |
} |
|
56 |
||
57 |
public AttributeBase(QName qname, String value) { |
|
58 |
_QName = qname; |
|
59 |
_value = value; |
|
60 |
} |
|
61 |
||
62 |
public AttributeBase(String prefix, String localName, String value) { |
|
63 |
this(prefix, null,localName, value, null); |
|
64 |
} |
|
65 |
||
66 |
public AttributeBase(String prefix, String namespaceURI, String localName, |
|
67 |
String value, String attributeType) { |
|
68 |
if (prefix == null) prefix = ""; |
|
69 |
_QName = new QName(namespaceURI, localName,prefix); |
|
70 |
_value = value; |
|
71 |
_attributeType = (attributeType == null) ? "CDATA":attributeType; |
|
72 |
} |
|
73 |
||
74 |
||
75 |
public void setName(QName name){ |
|
76 |
_QName = name ; |
|
77 |
} |
|
78 |
||
79 |
/** |
|
80 |
* Returns the QName for this attribute |
|
81 |
*/ |
|
82 |
public QName getName() { |
|
83 |
return _QName; |
|
84 |
} |
|
85 |
||
86 |
public void setValue(String value){ |
|
87 |
_value = value; |
|
88 |
} |
|
89 |
||
90 |
public String getLocalName() { |
|
91 |
return _QName.getLocalPart(); |
|
92 |
} |
|
93 |
/** |
|
94 |
* Gets the normalized value of this attribute |
|
95 |
*/ |
|
96 |
public String getValue() { |
|
97 |
return _value; |
|
98 |
} |
|
99 |
||
100 |
public void setAttributeType(String attributeType){ |
|
101 |
_attributeType = attributeType ; |
|
102 |
} |
|
103 |
||
104 |
/** |
|
105 |
* Gets the type of this attribute, default is |
|
106 |
* the String "CDATA" |
|
107 |
* @return the type as a String, default is "CDATA" |
|
108 |
*/ |
|
109 |
public String getDTDType() { |
|
110 |
return _attributeType; |
|
111 |
} |
|
112 |
||
113 |
||
114 |
/** |
|
115 |
* A flag indicating whether this attribute was actually |
|
116 |
* specified in the start-tag of its element, or was defaulted from the schema. |
|
117 |
* @return returns true if this was specified in the start element |
|
118 |
*/ |
|
119 |
public boolean isSpecified() { |
|
120 |
return _specified ; |
|
121 |
} |
|
122 |
||
123 |
public void setSpecified(boolean isSpecified){ |
|
124 |
_specified = isSpecified ; |
|
125 |
} |
|
126 |
||
127 |
||
128 |
public String toString() { |
|
129 |
String prefix = _QName.getPrefix(); |
|
130 |
if (!Util.isEmptyString(prefix)) |
|
131 |
return prefix + ":" + _QName.getLocalPart() + "='" + _value + "'"; |
|
132 |
||
133 |
return _QName.getLocalPart() + "='" + _value + "'"; |
|
134 |
} |
|
135 |
||
136 |
||
137 |
} |