KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.util.HashSet JavaDoc;
26
27 public final class Facet implements Cloneable JavaDoc {
28 private static final String JavaDoc RCSRevision = "$Revision: 1.1 $";
29 private static final String JavaDoc RCSName = "$Name: $";
30     String JavaDoc name;
31     String JavaDoc value;
32     boolean fixed = false;
33     
34     // enumeration facet : special
35
HashSet JavaDoc enumFacets = new HashSet JavaDoc();
36     
37   // contructor for facet other than enumeation
38
public Facet(String JavaDoc name, String JavaDoc value, String JavaDoc fixed) {
39         this.name = name;
40         this.value = value;
41         if ( "true".equals(fixed) ) this.fixed = true;
42   }
43     
44   // contructor only for facet enumeation
45
Facet(String JavaDoc name) {
46         this.name = name;
47   }
48   
49   public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
50     Facet result = null;
51     result = (Facet)super.clone();
52     result.enumFacets = new HashSet JavaDoc();
53     java.util.Iterator JavaDoc it = enumFacets.iterator();
54     while ( it.hasNext() ) {
55       String JavaDoc value = new String JavaDoc((String JavaDoc)it.next());
56       result.enumFacets.add(value);
57     }
58     return result;
59   }
60   
61     // add a new value to enumeation hashset
62
public void addFacet(String JavaDoc value) {
63         enumFacets.add(value);
64   }
65
66   public void setFacet(String JavaDoc name, String JavaDoc value, String JavaDoc fixed) {
67         this.name = name;
68         this.value = value;
69         if ( "true".equals(fixed) ) this.fixed = true;
70   }
71     
72   public void setValue(String JavaDoc value) {
73         this.value = value;
74   }
75     
76   public String JavaDoc getName() {
77         return this.name;
78   }
79     
80   public String JavaDoc getValue() {
81         return this.value;
82   }
83     
84   public boolean isFixed() {
85         return this.fixed;
86   }
87     
88   public HashSet JavaDoc getEnumFacets() {
89         return enumFacets;
90   }
91   
92   public String JavaDoc toString() {
93         return this.name;
94   }
95
96 }
97
Popular Tags