aoqi@0: /* aoqi@0: * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: * THIS FILE WAS MODIFIED BY SUN MICROSYSTEMS, INC. aoqi@0: */ aoqi@0: aoqi@0: package com.sun.xml.internal.fastinfoset.stax.events; aoqi@0: aoqi@0: import javax.xml.namespace.QName; aoqi@0: import javax.xml.stream.events.Attribute; aoqi@0: aoqi@0: aoqi@0: aoqi@0: public class AttributeBase extends EventBase implements Attribute aoqi@0: aoqi@0: { aoqi@0: //an Attribute consists of a qualified name and value aoqi@0: private QName _QName; aoqi@0: private String _value; aoqi@0: aoqi@0: private String _attributeType = null; aoqi@0: //A flag indicating whether this attribute was actually specified in the start-tag aoqi@0: //of its element or was defaulted from the schema. aoqi@0: private boolean _specified = false; aoqi@0: aoqi@0: public AttributeBase(){ aoqi@0: super(ATTRIBUTE); aoqi@0: } aoqi@0: aoqi@0: public AttributeBase(String name, String value) { aoqi@0: super(ATTRIBUTE); aoqi@0: _QName = new QName(name); aoqi@0: _value = value; aoqi@0: } aoqi@0: aoqi@0: public AttributeBase(QName qname, String value) { aoqi@0: _QName = qname; aoqi@0: _value = value; aoqi@0: } aoqi@0: aoqi@0: public AttributeBase(String prefix, String localName, String value) { aoqi@0: this(prefix, null,localName, value, null); aoqi@0: } aoqi@0: aoqi@0: public AttributeBase(String prefix, String namespaceURI, String localName, aoqi@0: String value, String attributeType) { aoqi@0: if (prefix == null) prefix = ""; aoqi@0: _QName = new QName(namespaceURI, localName,prefix); aoqi@0: _value = value; aoqi@0: _attributeType = (attributeType == null) ? "CDATA":attributeType; aoqi@0: } aoqi@0: aoqi@0: aoqi@0: public void setName(QName name){ aoqi@0: _QName = name ; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Returns the QName for this attribute aoqi@0: */ aoqi@0: public QName getName() { aoqi@0: return _QName; aoqi@0: } aoqi@0: aoqi@0: public void setValue(String value){ aoqi@0: _value = value; aoqi@0: } aoqi@0: aoqi@0: public String getLocalName() { aoqi@0: return _QName.getLocalPart(); aoqi@0: } aoqi@0: /** aoqi@0: * Gets the normalized value of this attribute aoqi@0: */ aoqi@0: public String getValue() { aoqi@0: return _value; aoqi@0: } aoqi@0: aoqi@0: public void setAttributeType(String attributeType){ aoqi@0: _attributeType = attributeType ; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Gets the type of this attribute, default is aoqi@0: * the String "CDATA" aoqi@0: * @return the type as a String, default is "CDATA" aoqi@0: */ aoqi@0: public String getDTDType() { aoqi@0: return _attributeType; aoqi@0: } aoqi@0: aoqi@0: aoqi@0: /** aoqi@0: * A flag indicating whether this attribute was actually aoqi@0: * specified in the start-tag of its element, or was defaulted from the schema. aoqi@0: * @return returns true if this was specified in the start element aoqi@0: */ aoqi@0: public boolean isSpecified() { aoqi@0: return _specified ; aoqi@0: } aoqi@0: aoqi@0: public void setSpecified(boolean isSpecified){ aoqi@0: _specified = isSpecified ; aoqi@0: } aoqi@0: aoqi@0: aoqi@0: public String toString() { aoqi@0: String prefix = _QName.getPrefix(); aoqi@0: if (!Util.isEmptyString(prefix)) aoqi@0: return prefix + ":" + _QName.getLocalPart() + "='" + _value + "'"; aoqi@0: aoqi@0: return _QName.getLocalPart() + "='" + _value + "'"; aoqi@0: } aoqi@0: aoqi@0: aoqi@0: }