KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > impl > dtd > models > CMNode


1 /*
2  * Copyright 1999-2002,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.dtd.models;
18
19 /**
20  * A content model node.
21  *
22  * @xerces.internal
23  *
24  * @version $Id: CMNode.java,v 1.4 2004/10/04 22:00:42 mrglavas Exp $
25  */

26 public abstract class CMNode
27 {
28     // -------------------------------------------------------------------
29
// Constructors
30
// -------------------------------------------------------------------
31
public CMNode(int type)
32     {
33         fType = type;
34     }
35
36
37     // -------------------------------------------------------------------
38
// Package, abstract methods
39
// -------------------------------------------------------------------
40
// made this public so it could be implemented and used outside this package -neilg.
41
public abstract boolean isNullable() ;
42
43
44     // -------------------------------------------------------------------
45
// Package final methods
46
// -------------------------------------------------------------------
47
public final int type()
48     {
49         return fType;
50     }
51
52     // made this public so it could be implemented and used outside this package -neilg.
53
public final CMStateSet firstPos()
54     {
55         if (fFirstPos == null)
56         {
57             fFirstPos = new CMStateSet(fMaxStates);
58             calcFirstPos(fFirstPos);
59         }
60         return fFirstPos;
61     }
62
63     // made this public so it could be implemented and used outside this package -neilg.
64
public final CMStateSet lastPos()
65     {
66         if (fLastPos == null)
67         {
68             fLastPos = new CMStateSet(fMaxStates);
69             calcLastPos(fLastPos);
70         }
71         return fLastPos;
72     }
73
74     final void setFollowPos(CMStateSet setToAdopt)
75     {
76         fFollowPos = setToAdopt;
77     }
78
79     public final void setMaxStates(int maxStates)
80     {
81         fMaxStates = maxStates;
82     }
83
84
85     // -------------------------------------------------------------------
86
// Protected, abstract methods
87
// -------------------------------------------------------------------
88
protected abstract void calcFirstPos(CMStateSet toSet) ;
89
90     protected abstract void calcLastPos(CMStateSet toSet) ;
91
92
93     // -------------------------------------------------------------------
94
// Private data members
95
//
96
// fType
97
// The type of node. This indicates whether its a leaf or an
98
// operation. Though we also do derived classes for these types,
99
// it is too expensive to use runtime typing to find this out.
100
// This is one of the ContentSpecNode.NODE_XXX types.
101
//
102
// fFirstPos
103
// The set of NFA states that represent the entry states of this
104
// node in the DFA.
105
//
106
// fFollowPos
107
// The set of NFA states that can be gotten to from from this
108
// node in the DFA.
109
//
110
// fLastPos
111
// The set of NFA states that represent the final states of this
112
// node in the DFA.
113
//
114
// fMaxStates
115
// The maximum number of states that the NFA has, which means the
116
// max number of NFA states that have to be traced in the state
117
// sets during the building of the DFA. Its unfortunate that it
118
// has to be stored redundantly, but we need to fault in the
119
// state set members and they have to be sized to this size. We
120
// init to to -1 so it will cause an error if its used without
121
// being initialized.
122
// -------------------------------------------------------------------
123
private int fType;
124     private CMStateSet fFirstPos = null;
125     private CMStateSet fFollowPos = null;
126     private CMStateSet fLastPos = null;
127     private int fMaxStates = -1;
128 };
129
130
131
Popular Tags