KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > schema > AttributeDeclaration


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 Universite de Versailles Saint-Quentin.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
18  * You can also get it at http://www.gnu.org/licenses/lgpl.html
19  *
20  * For more information on this software, see http://www.xquark.org.
21  */

22
23  package org.xquark.schema;
24 /**
25  * class for Attribute Declaration.
26  *
27  * <p>This is the implementation of the Attribute Declaration.
28  * The following properties are defined:</p>
29  * <p> 1. name : a NCName, defined in SchemaComponent.</p>
30  * <p> 2. target namespace : null or a namespace name, defined in SchemaComponent.</p>
31  * <p> 3. type defintion : a simple type defintion, defined in Declaration.</p>
32  * <p> 4. scope : either null (means gloabal) or a complex type defintion, defined in Declaration. </p>
33  * <p> 5. value constraint : optional. Either a defaultValue or a fixedValue, defined in Declaration. </p>
34  *
35  * <p>See XML Schema Part 1: Structures 3.2
36  * W3C Recommendation 2 May 2001</p>
37  *
38  * @see org.xquark.xml.schema.SchemaComponent
39  * @see org.xquark.xml.schema.Declaration
40  */

41 public class AttributeDeclaration extends Declaration implements SchemaConstants {
42 private static final String JavaDoc RCSRevision = "$Revision: 1.1 $";
43 private static final String JavaDoc RCSName = "$Name: $";
44   
45   // schema 2001-05
46
// use = optional, prohibited, required : optional
47
private int use = OPTIONAL;
48   
49   /**
50    * Create a new AttributeDeclaration.
51    *
52    * @param schema The schema which contains this attribute declaration.
53    * @param name The attribute declaration name, a NCName.
54    * @param scope The scope, null if the attribute declaration is in a group,
55    * or a complex type which contains this attribute declaration.
56    */

57   public AttributeDeclaration(Schema schema, String JavaDoc name, SchemaScope scope) {
58     super(schema, name, scope);
59   }
60
61   public void accept(SchemaVisitor visitor) throws SchemaException {
62     visitor.visit(this);
63   }
64
65   public int getUse() { return this.use; }
66   
67   public String JavaDoc getUseString() {
68     switch( use ) {
69       case OPTIONAL: return OPTIONAL_VALUE;
70       case PROHIBITED: return PROHIBITED_VALUE;
71       case REQUIRED: return REQUIRED_VALUE;
72     }
73     return OPTIONAL_VALUE;
74   }
75   
76   public void setUse(int use) {
77     this.use = use;
78   }
79   
80 }
81
82
83
Popular Tags