1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.xerces.internal.impl.xs.opti;
  23 
  24 import org.w3c.dom.Attr;
  25 import org.w3c.dom.DOMException;
  26 import org.w3c.dom.Document;
  27 import org.w3c.dom.Element;
  28 import org.w3c.dom.Node;
  29 import org.w3c.dom.TypeInfo;
  30 
  31 /**
  32  * This class represents a single attribute.
  33  *
  34  * @author Rahul Srivastava, Sun Microsystems Inc.
  35  *
  36  * @version $Id: AttrImpl.java,v 1.5 2010-11-01 04:40:01 joehw Exp $
  37  */
  38 public class AttrImpl extends NodeImpl
  39                       implements Attr {
  40 
  41     Element element;
  42     String value;
  43 
  44     /** Default Constructor */
  45     public AttrImpl() {
  46         nodeType = Node.ATTRIBUTE_NODE;
  47     }
  48 
  49     /**
  50      * Constructs an attribute.
  51      *
  52      * @param element Element which owns this attribute
  53      * @param prefix The QName prefix.
  54      * @param localpart The QName localpart.
  55      * @param rawname The QName rawname.
  56      * @param uri The uri binding for the associated prefix.
  57      * @param value The value of the attribute.
  58      */
  59     public AttrImpl(Element element, String prefix, String localpart, String rawname, String uri, String value) {
  60         super(prefix, localpart, rawname, uri, Node.ATTRIBUTE_NODE);
  61         this.element = element;
  62         this.value = value;
  63     }
  64 
  65     public String getName() {
  66         return rawname;
  67     }
  68 
  69     public boolean getSpecified() {
  70         return true;
  71     }
  72 
  73     public String getValue() {
  74         return value;
  75     }
  76 
  77     public String getNodeValue() {
  78         return getValue();
  79     }
  80 
  81     public Element getOwnerElement() {
  82         return element;
  83     }
  84 
  85     public Document getOwnerDocument() {
  86         return element.getOwnerDocument();
  87     }
  88 
  89     public void setValue(String value) throws DOMException {
  90         this.value = value;
  91     }
  92 
  93     /**
  94      * @since DOM Level 3
  95      */
  96     public boolean isId(){
  97         return false;
  98     }
  99 
 100     /**
 101      * Method getSchemaTypeInfo.
 102      * @return TypeInfo
 103      */
 104     public TypeInfo getSchemaTypeInfo(){
 105       return null;
 106     }
 107 
 108     /** NON-DOM method for debugging convenience */
 109     public String toString() {
 110         return getName() + "=" + "\"" + getValue() + "\"";
 111     }
 112 }