1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/fastinfoset/stax/events/AttributeBase.java Wed Apr 27 01:27:09 2016 +0800 1.3 @@ -0,0 +1,137 @@ 1.4 +/* 1.5 + * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + * 1.28 + * THIS FILE WAS MODIFIED BY SUN MICROSYSTEMS, INC. 1.29 + */ 1.30 + 1.31 +package com.sun.xml.internal.fastinfoset.stax.events; 1.32 + 1.33 +import javax.xml.namespace.QName; 1.34 +import javax.xml.stream.events.Attribute; 1.35 + 1.36 + 1.37 + 1.38 +public class AttributeBase extends EventBase implements Attribute 1.39 + 1.40 +{ 1.41 + //an Attribute consists of a qualified name and value 1.42 + private QName _QName; 1.43 + private String _value; 1.44 + 1.45 + private String _attributeType = null; 1.46 + //A flag indicating whether this attribute was actually specified in the start-tag 1.47 + //of its element or was defaulted from the schema. 1.48 + private boolean _specified = false; 1.49 + 1.50 + public AttributeBase(){ 1.51 + super(ATTRIBUTE); 1.52 + } 1.53 + 1.54 + public AttributeBase(String name, String value) { 1.55 + super(ATTRIBUTE); 1.56 + _QName = new QName(name); 1.57 + _value = value; 1.58 + } 1.59 + 1.60 + public AttributeBase(QName qname, String value) { 1.61 + _QName = qname; 1.62 + _value = value; 1.63 + } 1.64 + 1.65 + public AttributeBase(String prefix, String localName, String value) { 1.66 + this(prefix, null,localName, value, null); 1.67 + } 1.68 + 1.69 + public AttributeBase(String prefix, String namespaceURI, String localName, 1.70 + String value, String attributeType) { 1.71 + if (prefix == null) prefix = ""; 1.72 + _QName = new QName(namespaceURI, localName,prefix); 1.73 + _value = value; 1.74 + _attributeType = (attributeType == null) ? "CDATA":attributeType; 1.75 + } 1.76 + 1.77 + 1.78 + public void setName(QName name){ 1.79 + _QName = name ; 1.80 + } 1.81 + 1.82 + /** 1.83 + * Returns the QName for this attribute 1.84 + */ 1.85 + public QName getName() { 1.86 + return _QName; 1.87 + } 1.88 + 1.89 + public void setValue(String value){ 1.90 + _value = value; 1.91 + } 1.92 + 1.93 + public String getLocalName() { 1.94 + return _QName.getLocalPart(); 1.95 + } 1.96 + /** 1.97 + * Gets the normalized value of this attribute 1.98 + */ 1.99 + public String getValue() { 1.100 + return _value; 1.101 + } 1.102 + 1.103 + public void setAttributeType(String attributeType){ 1.104 + _attributeType = attributeType ; 1.105 + } 1.106 + 1.107 + /** 1.108 + * Gets the type of this attribute, default is 1.109 + * the String "CDATA" 1.110 + * @return the type as a String, default is "CDATA" 1.111 + */ 1.112 + public String getDTDType() { 1.113 + return _attributeType; 1.114 + } 1.115 + 1.116 + 1.117 + /** 1.118 + * A flag indicating whether this attribute was actually 1.119 + * specified in the start-tag of its element, or was defaulted from the schema. 1.120 + * @return returns true if this was specified in the start element 1.121 + */ 1.122 + public boolean isSpecified() { 1.123 + return _specified ; 1.124 + } 1.125 + 1.126 + public void setSpecified(boolean isSpecified){ 1.127 + _specified = isSpecified ; 1.128 + } 1.129 + 1.130 + 1.131 + public String toString() { 1.132 + String prefix = _QName.getPrefix(); 1.133 + if (!Util.isEmptyString(prefix)) 1.134 + return prefix + ":" + _QName.getLocalPart() + "='" + _value + "'"; 1.135 + 1.136 + return _QName.getLocalPart() + "='" + _value + "'"; 1.137 + } 1.138 + 1.139 + 1.140 +}