Save This Page
Home » xmlbeans-2.4.0-src » org.apache.xmlbeans.impl.schema » [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   
   16   package org.apache.xmlbeans.impl.schema;
   17   
   18   import org.apache.xmlbeans.SchemaAttributeModel;
   19   import org.apache.xmlbeans.SchemaGlobalAttribute;
   20   import org.apache.xmlbeans.QNameSet;
   21   import org.apache.xmlbeans.QNameSetBuilder;
   22   import org.apache.xmlbeans.SchemaLocalAttribute;
   23   import javax.xml.namespace.QName;
   24   
   25   import java.util.Map;
   26   import java.util.LinkedHashMap;
   27   
   28   public class SchemaAttributeModelImpl implements SchemaAttributeModel
   29   {
   30       private Map attrMap;
   31       private QNameSet wcSet;
   32       private int wcProcess;
   33   
   34       public SchemaAttributeModelImpl()
   35       {
   36           attrMap = new LinkedHashMap();
   37           wcSet = null;
   38           wcProcess = NONE;
   39       }
   40   
   41       public SchemaAttributeModelImpl(SchemaAttributeModel sam)
   42       {
   43           attrMap = new LinkedHashMap();
   44           if (sam == null)
   45           {
   46               wcSet = null;
   47               wcProcess = NONE;
   48           }
   49           else
   50           {
   51               SchemaLocalAttribute[] attrs = sam.getAttributes();
   52               for (int i = 0; i < attrs.length; i++)
   53               {
   54                   attrMap.put(attrs[i].getName(), attrs[i]);
   55               }
   56   
   57               if (sam.getWildcardProcess() != SchemaAttributeModel.NONE)
   58               {
   59                   wcSet = sam.getWildcardSet();
   60                   wcProcess = sam.getWildcardProcess();
   61               }
   62           }
   63       }
   64       
   65       private static final SchemaLocalAttribute[] EMPTY_SLA_ARRAY = new SchemaLocalAttribute[0];
   66   
   67       public SchemaLocalAttribute[] getAttributes()
   68       {
   69           return (SchemaLocalAttribute[])attrMap.values().toArray(EMPTY_SLA_ARRAY);
   70       }
   71   
   72       public SchemaLocalAttribute getAttribute(QName name)
   73       {
   74           return (SchemaLocalAttribute)attrMap.get(name);
   75       }
   76   
   77       public void addAttribute(SchemaLocalAttribute attruse)
   78       {
   79           attrMap.put(attruse.getName(), attruse);
   80       }
   81       
   82       public void removeProhibitedAttribute(QName name)
   83       {
   84           attrMap.remove(name);
   85       }
   86   
   87       public QNameSet getWildcardSet()
   88       {
   89           return wcSet == null ? QNameSet.EMPTY : wcSet;
   90       }
   91   
   92       public void setWildcardSet(QNameSet set)
   93       {
   94           wcSet = set;
   95       }
   96   
   97       public int getWildcardProcess()
   98       {
   99           return wcProcess;
  100       }
  101   
  102       public void setWildcardProcess(int proc)
  103       {
  104           wcProcess = proc;
  105       }
  106   }

Save This Page
Home » xmlbeans-2.4.0-src » org.apache.xmlbeans.impl.schema » [javadoc | source]