Home » xmlbeans-2.5.0-src » org.apache.xmlbeans.impl » inst2xsd » util » [javadoc | source]

    1   /*   Copyright 2004 The Apache Software Foundation
    2    *
    3    *   Licensed under the Apache License, Version 2.0 (the "License");
    4    *   you may not use this file except in compliance with the License.
    5    *   You may obtain a copy of the License at
    6    *
    7    *       http://www.apache.org/licenses/LICENSE-2.0
    8    *
    9    *   Unless required by applicable law or agreed to in writing, software
   10    *   distributed under the License is distributed on an "AS IS" BASIS,
   11    *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   12    *   See the License for the specific language governing permissions and
   13    *  limitations under the License.
   14    */
   15   package org.apache.xmlbeans.impl.inst2xsd.util;
   16   
   17   import javax.xml.namespace.QName;
   18   
   19   /**
   20    * @author Cezar Andrei (cezar.andrei at bea.com) Date: Jul 18, 2004
   21    */
   22   public class Attribute
   23   {
   24       private QName _name;
   25       private Type _type;
   26       private Attribute _ref = null;
   27       private boolean _isGlobal = false;
   28       private boolean _isOptional = false;
   29   
   30       public QName getName()
   31       {
   32           return _name;
   33       }
   34   
   35       public void setName(QName name)
   36       {
   37           _name = name;
   38       }
   39   
   40       public Type getType()
   41       {
   42           return isRef() ? getRef().getType() : _type;
   43       }
   44   
   45       public void setType(Type type)
   46       {
   47           assert !isRef();
   48           _type = type;
   49       }
   50   
   51       public boolean isRef()
   52       {
   53           return _ref!=null;
   54       }
   55   
   56       public Attribute getRef()
   57       {
   58           return _ref;
   59       }
   60   
   61       public void setRef(Attribute ref)
   62       {
   63           assert !isGlobal();
   64           _ref = ref;
   65           _type = null;
   66       }
   67   
   68       public boolean isGlobal()
   69       {
   70           return _isGlobal;
   71       }
   72   
   73       public void setGlobal(boolean isGlobal)
   74       {
   75           _isGlobal = isGlobal;
   76       }
   77   
   78       public boolean isOptional()
   79       {
   80           return _isOptional;
   81       }
   82   
   83       public void setOptional(boolean isOptional)
   84       {
   85           assert isOptional && !isGlobal() : "Global attributes cannot be optional.";
   86           _isOptional = isOptional;
   87       }
   88   
   89       public String toString()
   90       {
   91           return "\n    Attribute{" +
   92               "_name=" + _name +
   93               ", _type=" + _type +
   94               ", _ref=" + (_ref!=null) +
   95               ", _isGlobal=" + _isGlobal +
   96               ", _isOptional=" + _isOptional +
   97               "}";
   98       }
   99   }

Home » xmlbeans-2.5.0-src » org.apache.xmlbeans.impl » inst2xsd » util » [javadoc | source]