View Javadoc

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