KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > impl > xs > models > XSEmptyCM


1 /*
2  * Copyright 2001-2004 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.xerces.impl.xs.models;
18
19 import org.apache.xerces.xni.QName;
20 import org.apache.xerces.impl.xs.SubstitutionGroupHandler;
21 import org.apache.xerces.impl.xs.XMLSchemaException;
22
23 import java.util.Vector JavaDoc;
24
25 /**
26  * XSEmptyCM is a derivative of the abstract content model base class that
27  * handles a content model with no chilren (elements).
28  *
29  * This model validated on the way in.
30  *
31  * @xerces.internal
32  *
33  * @author Elena Litani, Lisa Martin
34  * @author IBM
35  * @version $Id: XSEmptyCM.java,v 1.9 2004/10/06 15:14:53 mrglavas Exp $
36  */

37 public class XSEmptyCM implements XSCMValidator {
38
39     //
40
// Constants
41
//
42

43     // start the content model: did not see any children
44
private static final short STATE_START = 0;
45     
46     private static final Vector JavaDoc EMPTY = new Vector JavaDoc(0);
47
48     //
49
// Data
50
//
51

52     //
53
// XSCMValidator methods
54
//
55

56     /**
57      * This methods to be called on entering a first element whose type
58      * has this content model. It will return the initial state of the content model
59      *
60      * @return Start state of the content model
61      */

62     public int[] startContentModel(){
63         return (new int[] {STATE_START});
64     }
65
66
67     /**
68      * The method corresponds to one transaction in the content model.
69      *
70      * @param elementName the qualified name of the element
71      * @param currentState Current state
72      * @param subGroupHandler the substitution group handler
73      * @return element index corresponding to the element from the Schema grammar
74      */

75     public Object JavaDoc oneTransition (QName elementName, int[] currentState, SubstitutionGroupHandler subGroupHandler){
76
77         // error state
78
if (currentState[0] < 0) {
79             currentState[0] = XSCMValidator.SUBSEQUENT_ERROR;
80             return null;
81         }
82
83         currentState[0] = XSCMValidator.FIRST_ERROR;
84         return null;
85     }
86
87
88     /**
89      * The method indicates the end of list of children
90      *
91      * @param currentState Current state of the content model
92      * @return true if the last state was a valid final state
93      */

94     public boolean endContentModel (int[] currentState){
95         boolean isFinal = false;
96         int state = currentState[0];
97
98         // restore content model state:
99

100         // error
101
if (state < 0) {
102             return false;
103         }
104
105
106         return true;
107     }
108
109     /**
110      * check whether this content violates UPA constraint.
111      *
112      * @param subGroupHandler the substitution group handler
113      * @return true if this content model contains other or list wildcard
114      */

115     public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException {
116         return false;
117     }
118
119     /**
120      * Check which elements are valid to appear at this point. This method also
121      * works if the state is in error, in which case it returns what should
122      * have been seen.
123      *
124      * @param state the current state
125      * @return a Vector whose entries are instances of
126      * either XSWildcardDecl or XSElementDecl.
127      */

128     public Vector JavaDoc whatCanGoHere(int[] state) {
129         return EMPTY;
130     }
131     
132 } // class XSEmptyCM
133
Popular Tags