src/share/jaxws_classes/com/sun/xml/internal/fastinfoset/stax/events/AttributeBase.java

Wed, 27 Apr 2016 01:27:09 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:27:09 +0800
changeset 0
373ffda63c9a
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/jaxws/
changeset: 657:d47a47f961ee
tag: jdk8u25-b17

     1 /*
     2  * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
     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  */
    28 package com.sun.xml.internal.fastinfoset.stax.events;
    30 import javax.xml.namespace.QName;
    31 import javax.xml.stream.events.Attribute;
    35 public class AttributeBase extends EventBase implements Attribute
    37 {
    38     //an Attribute consists of a qualified name and value
    39     private QName _QName;
    40     private String _value;
    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;
    47     public AttributeBase(){
    48         super(ATTRIBUTE);
    49     }
    51     public AttributeBase(String name, String value) {
    52         super(ATTRIBUTE);
    53         _QName = new QName(name);
    54         _value = value;
    55     }
    57     public AttributeBase(QName qname, String value) {
    58         _QName = qname;
    59         _value = value;
    60     }
    62     public AttributeBase(String prefix, String localName, String value) {
    63         this(prefix, null,localName, value, null);
    64     }
    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     }
    75     public void setName(QName name){
    76         _QName = name ;
    77     }
    79   /**
    80    * Returns the QName for this attribute
    81    */
    82     public QName getName() {
    83         return _QName;
    84     }
    86     public void setValue(String value){
    87         _value = value;
    88     }
    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     }
   100     public void setAttributeType(String attributeType){
   101         _attributeType = attributeType ;
   102     }
   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     }
   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     }
   123     public void setSpecified(boolean isSpecified){
   124         _specified = isSpecified ;
   125     }
   128     public String toString() {
   129         String prefix = _QName.getPrefix();
   130         if (!Util.isEmptyString(prefix))
   131             return prefix + ":" + _QName.getLocalPart() + "='" + _value + "'";
   133         return _QName.getLocalPart() + "='" + _value + "'";
   134     }
   137 }

mercurial