View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements. See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership. The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License. You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied. See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.ws.commons.schema;
21  
22  import org.apache.ws.commons.schema.constants.Constants;
23  
24  import javax.xml.namespace.QName;
25  
26  /**
27   * Class for attribute types. Represents the World Wide Web Consortium
28   * (W3C) attribute element.
29   */
30  
31  // October 15th - momo - initial implementation
32  
33  public class XmlSchemaAttribute extends XmlSchemaAnnotated {
34  
35      Object attributeType;
36      String defaultValue, fixedValue, name;
37      XmlSchemaForm form;
38      XmlSchemaSimpleType schemaType;
39      QName schemaTypeName, qualifiedName, refName;
40      XmlSchemaUse use;
41  
42      /**
43       * Creates new XmlSchemaAttribute
44       */
45      public XmlSchemaAttribute() {
46          form = new XmlSchemaForm(XmlSchemaForm.NONE);
47          use = new XmlSchemaUse(Constants.BlockConstants.NONE);
48      }
49  
50      public Object getAttributeType() {
51          return attributeType;
52      }
53  
54      public String getDefaultValue() {
55          return defaultValue;
56      }
57  
58      public void setDefaultValue(String defaultValue) {
59          this.defaultValue = defaultValue;
60      }
61  
62      public String getFixedValue() {
63          return fixedValue;
64      }
65  
66      public void setFixedValue(String fixedValue) {
67          this.fixedValue = fixedValue;
68      }
69  
70      public XmlSchemaForm getForm() {
71          return form;
72      }
73  
74      public void setSchemaForm(XmlSchemaForm form) {
75          this.form = form;
76      }
77  
78      public QName getQName() {
79          return qualifiedName;
80      }
81  
82      public void setQName(QName qualifiedName) {
83          this.qualifiedName = qualifiedName;
84      }
85  
86      public String getName() {
87          return name;
88      }
89  
90      public void setName(String name) {
91          this.name = name;
92      }
93  
94      public QName getRefName() {
95          return refName;
96      }
97  
98      public void setRefName(QName refName) {
99          this.refName = refName;
100     }
101 
102     public XmlSchemaSimpleType getSchemaType() {
103         return schemaType;
104     }
105 
106     public void setSchemaType(XmlSchemaSimpleType schemaType) {
107         this.schemaType = schemaType;
108     }
109 
110     public QName getSchemaTypeName() {
111         return schemaTypeName;
112     }
113 
114     public void setSchemaTypeName(QName schemaTypeName) {
115         this.schemaTypeName = schemaTypeName;
116     }
117 
118     public XmlSchemaUse getUse() {
119         return use;
120     }
121 
122     public void setUse(XmlSchemaUse use) {
123         this.use = use;
124     }
125 
126     public String toString(String prefix, int tab) {
127         String xml = new String();
128 
129         if (!prefix.equals("") && prefix.indexOf(":") == -1)
130             prefix += ":";
131 
132         for (int i = 0; i < tab; i++)
133             xml += "\t";
134 
135         xml += "<" + prefix + "attribute name=\"" + name + "\" type=\"" + schemaTypeName + "\"/>\n";
136 
137         return xml;
138     }
139 }