KickJava   Java API By Example, From Geeks To Geeks.

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


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 public final class ContentModel implements SchemaConstants, SchemaVisitable {
26 private static final String JavaDoc RCSRevision = "$Revision: 1.1 $";
27 private static final String JavaDoc RCSName = "$Name: $";
28   
29   private Object JavaDoc model = null;
30   private int contentType;
31
32   public ContentModel() {
33     contentType = EMPTY;
34     model = null;
35   }
36
37   public ContentModel(int type) {
38     contentType = type;
39     model = null;
40   }
41
42   public ContentModel(SimpleType model) {
43     contentType = TEXT_ONLY;
44     setModel(model);
45   }
46   
47   public ContentModel(Particle model) {
48     this(model, ELEMENT_ONLY);
49   }
50   
51   public ContentModel(Particle model, int contentType) {
52     this.contentType = contentType;
53     setModel(model);
54   }
55
56   public void accept(SchemaVisitor visitor) throws SchemaException {
57     visitor.visit(this);
58   }
59
60   public int getContentType() {
61     return contentType;
62   }
63   
64   public void setContentType(int contentType) {
65     this.contentType = contentType;
66   }
67
68   public Object JavaDoc getModel() {
69     return model;
70   }
71
72   public void setModel(Object JavaDoc model) {
73     this.model = model;
74   }
75
76   void initModel(Object JavaDoc model) {
77     this.model = model;
78         /*
79     Particle particle;
80     switch (contentType) {
81     case TEXT_ONLY:
82       this.model = model;
83       break;
84     case ELEMENT_ONLY:
85       SequenceModelGroup seq = new SequenceModelGroup();
86       seq.add(model);
87       particle = new Particle(seq);
88       particle.setMinOccurs(1);
89       particle.setMaxOccurs(1);
90       this.model = particle;
91       break;
92     case MIXED:
93       ChoiceModelGroup choice = new ChoiceModelGroup();
94       choice.add(model);
95       particle = new Particle(choice);
96       particle.setMinOccurs(0);
97       particle.setMaxOccursUnbounded();
98       this.model = particle;
99       break;
100     }
101          */

102   }
103   
104 }
105
Popular Tags