1 38 39 package com.sun.xml.fastinfoset.stax.events; 40 41 import javax.xml.namespace.QName ; 42 import javax.xml.stream.XMLStreamConstants; 43 import javax.xml.stream.events.Attribute; 44 import java.io.Writer ; 45 import com.sun.xml.fastinfoset.util.Util; 46 47 48 public class AttributeBase extends EventBase implements Attribute 49 50 { 51 private QName _QName; 53 private String _value; 54 55 private String _attributeType = null; 56 private boolean _specified = false; 59 60 public AttributeBase(){ 61 super(ATTRIBUTE); 62 } 63 64 public AttributeBase(String name, String value) { 65 super(ATTRIBUTE); 66 _QName = new QName (name); 67 _value = value; 68 } 69 70 public AttributeBase(QName qname, String value) { 71 _QName = qname; 72 _value = value; 73 } 74 75 public AttributeBase(String prefix, String localName, String value) { 76 this(prefix, null,localName, value, null); 77 } 78 79 public AttributeBase(String prefix, String namespaceURI, String localName, 80 String value, String attributeType) { 81 if (prefix == null) prefix = ""; 82 _QName = new QName (namespaceURI, localName,prefix); 83 _value = value; 84 _attributeType = (attributeType == null) ? "CDATA":attributeType; 85 } 86 87 88 public void setName(QName name){ 89 _QName = name ; 90 } 91 92 95 public QName getName() { 96 return _QName; 97 } 98 99 public void setValue(String value){ 100 _value = value; 101 } 102 103 public String getLocalName() { 104 return _QName.getLocalPart(); 105 } 106 109 public String getValue() { 110 return _value; 111 } 112 113 public void setAttributeType(String attributeType){ 114 _attributeType = attributeType ; 115 } 116 117 122 public String getDTDType() { 123 return _attributeType; 124 } 125 126 127 132 public boolean isSpecified() { 133 return _specified ; 134 } 135 136 public void setSpecified(boolean isSpecified){ 137 _specified = isSpecified ; 138 } 139 140 141 public String toString() { 142 String prefix = _QName.getPrefix(); 143 if (!Util.isEmptyString(prefix)) 144 return prefix + ":" + _QName.getLocalPart() + "='" + _value + "'"; 145 146 return _QName.getLocalPart() + "='" + _value + "'"; 147 } 148 149 150 } 151 152 | Popular Tags |