KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright 2000-2002,2004,2005 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 /**
21  * Content model any node.
22  *
23  * @xerces.internal
24  *
25  * @version $Id: CMAny.java,v 1.6 2005/03/08 05:40:15 mrglavas Exp $
26  */

27 public class CMAny
28     extends CMNode {
29
30     //
31
// Data
32
//
33

34     /**
35      * The any content model type. This value is one of the following:
36      * XMLContentSpec.CONTENTSPECNODE_ANY,
37      * XMLContentSpec.CONTENTSPECNODE_ANY_OTHER,
38      * XMLContentSpec.CONTENTSPECNODE_ANY_LOCAL.
39      */

40     private int fType;
41
42     /**
43      * URI of the any content model. This value is set if the type is
44      * of the following:
45      * XMLContentSpec.CONTENTSPECNODE_ANY,
46      * XMLContentSpec.CONTENTSPECNODE_ANY_OTHER.
47      */

48     private String JavaDoc fURI;
49
50     /**
51      * Part of the algorithm to convert a regex directly to a DFA
52      * numbers each leaf sequentially. If its -1, that means its an
53      * epsilon node. Zero and greater are non-epsilon positions.
54      */

55     private int fPosition = -1;
56
57     //
58
// Constructors
59
//
60

61     /** Constructs a content model any. */
62     public CMAny(int type, String JavaDoc uri, int position) {
63         super(type);
64
65         // Store the information
66
fType = type;
67         fURI = uri;
68         fPosition = position;
69     }
70
71     //
72
// Package methods
73
//
74

75     final int getType() {
76         return fType;
77     }
78
79     final String JavaDoc getURI() {
80         return fURI;
81     }
82
83     final int getPosition()
84     {
85         return fPosition;
86     }
87
88     final void setPosition(int newPosition)
89     {
90         fPosition = newPosition;
91     }
92
93     //
94
// CMNode methods
95
//
96

97     // package
98

99     public boolean isNullable()
100     {
101         // Leaf nodes are never nullable unless its an epsilon node
102
return (fPosition == -1);
103     }
104
105     public String JavaDoc toString()
106     {
107         StringBuffer JavaDoc strRet = new StringBuffer JavaDoc();
108         strRet.append("(");
109         strRet.append("##any:uri=");
110         strRet.append(fURI);
111         strRet.append(')');
112         if (fPosition >= 0)
113         {
114             strRet.append
115             (
116                 " (Pos:"
117                 + Integer.toString(fPosition)
118                 + ")"
119             );
120         }
121         return strRet.toString();
122     }
123
124     // protected
125

126     protected void calcFirstPos(CMStateSet toSet)
127     {
128         // If we are an epsilon node, then the first pos is an empty set
129
if (fPosition == -1)
130             toSet.zeroBits();
131
132         // Otherwise, its just the one bit of our position
133
else
134             toSet.setBit(fPosition);
135     }
136
137     protected void calcLastPos(CMStateSet toSet)
138     {
139         // If we are an epsilon node, then the last pos is an empty set
140
if (fPosition == -1)
141             toSet.zeroBits();
142
143         // Otherwise, its just the one bit of our position
144
else
145             toSet.setBit(fPosition);
146     }
147
148 } // class CMAny
149

150
Popular Tags