author | joehw |
Mon, 13 Oct 2014 14:09:03 -0700 | |
changeset 27111 | 7a491d709b83 |
parent 25868 | 686eef1e7a79 |
permissions | -rw-r--r-- |
6 | 1 |
/* |
27111
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
2 |
* Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved. |
6 | 3 |
*/ |
4 |
/* |
|
27111
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
5 |
* Licensed to the Apache Software Foundation (ASF) under one or more |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
6 |
* contributor license agreements. See the NOTICE file distributed with |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
7 |
* this work for additional information regarding copyright ownership. |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
8 |
* The ASF licenses this file to You under the Apache License, Version 2.0 |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
9 |
* (the "License"); you may not use this file except in compliance with |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
10 |
* the License. You may obtain a copy of the License at |
6 | 11 |
* |
27111
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
12 |
* http://www.apache.org/licenses/LICENSE-2.0 |
6 | 13 |
* |
27111
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
14 |
* Unless required by applicable law or agreed to in writing, software |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
15 |
* distributed under the License is distributed on an "AS IS" BASIS, |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
16 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
17 |
* See the License for the specific language governing permissions and |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
18 |
* limitations under the License. |
6 | 19 |
*/ |
20 |
||
21 |
package com.sun.org.apache.xerces.internal.impl.dtd.models; |
|
22 |
||
23 |
/** |
|
24 |
* A content model node. |
|
25 |
* |
|
26 |
* @xerces.internal |
|
27 |
* |
|
28 |
*/ |
|
29 |
public abstract class CMNode |
|
30 |
{ |
|
31 |
// ------------------------------------------------------------------- |
|
32 |
// Constructors |
|
33 |
// ------------------------------------------------------------------- |
|
34 |
public CMNode(int type) |
|
35 |
{ |
|
36 |
fType = type; |
|
37 |
} |
|
38 |
||
39 |
||
40 |
// ------------------------------------------------------------------- |
|
41 |
// Package, abstract methods |
|
42 |
// ------------------------------------------------------------------- |
|
43 |
// made this public so it could be implemented and used outside this package -neilg. |
|
44 |
public abstract boolean isNullable() ; |
|
45 |
||
46 |
||
47 |
// ------------------------------------------------------------------- |
|
48 |
// Package final methods |
|
49 |
// ------------------------------------------------------------------- |
|
50 |
public final int type() |
|
51 |
{ |
|
52 |
return fType; |
|
53 |
} |
|
54 |
||
55 |
// made this public so it could be implemented and used outside this package -neilg. |
|
56 |
public final CMStateSet firstPos() |
|
57 |
{ |
|
58 |
if (fFirstPos == null) |
|
59 |
{ |
|
60 |
fFirstPos = new CMStateSet(fMaxStates); |
|
61 |
calcFirstPos(fFirstPos); |
|
62 |
} |
|
63 |
return fFirstPos; |
|
64 |
} |
|
65 |
||
66 |
// made this public so it could be implemented and used outside this package -neilg. |
|
67 |
public final CMStateSet lastPos() |
|
68 |
{ |
|
69 |
if (fLastPos == null) |
|
70 |
{ |
|
71 |
fLastPos = new CMStateSet(fMaxStates); |
|
72 |
calcLastPos(fLastPos); |
|
73 |
} |
|
74 |
return fLastPos; |
|
75 |
} |
|
76 |
||
77 |
final void setFollowPos(CMStateSet setToAdopt) |
|
78 |
{ |
|
79 |
fFollowPos = setToAdopt; |
|
80 |
} |
|
81 |
||
82 |
public final void setMaxStates(int maxStates) |
|
83 |
{ |
|
84 |
fMaxStates = maxStates; |
|
85 |
} |
|
86 |
||
27111
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
87 |
public boolean isCompactedForUPA() { |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
88 |
return fCompactedForUPA; |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
89 |
} |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
90 |
|
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
91 |
public void setIsCompactUPAModel(boolean value) { |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
92 |
fCompactedForUPA = value; |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
93 |
} |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
94 |
|
6 | 95 |
/** |
96 |
* Allows the user to set arbitrary data on this content model |
|
97 |
* node. This is used by the a{n,m} optimization that runs |
|
98 |
* in constant space. |
|
99 |
*/ |
|
100 |
public void setUserData(Object userData) { |
|
101 |
fUserData = userData; |
|
102 |
} |
|
103 |
||
104 |
/** |
|
105 |
* Allows the user to get arbitrary data set on this content |
|
106 |
* model node. This is used by the a{n,m} optimization that runs |
|
107 |
* in constant space. |
|
108 |
*/ |
|
109 |
public Object getUserData() { |
|
110 |
return fUserData; |
|
111 |
} |
|
112 |
||
113 |
// ------------------------------------------------------------------- |
|
114 |
// Protected, abstract methods |
|
115 |
// ------------------------------------------------------------------- |
|
116 |
protected abstract void calcFirstPos(CMStateSet toSet) ; |
|
117 |
||
118 |
protected abstract void calcLastPos(CMStateSet toSet) ; |
|
119 |
||
120 |
||
121 |
// ------------------------------------------------------------------- |
|
122 |
// Private data members |
|
123 |
// |
|
124 |
// fType |
|
125 |
// The type of node. This indicates whether its a leaf or an |
|
126 |
// operation. Though we also do derived classes for these types, |
|
127 |
// it is too expensive to use runtime typing to find this out. |
|
128 |
// This is one of the ContentSpecNode.NODE_XXX types. |
|
129 |
// |
|
130 |
// fFirstPos |
|
131 |
// The set of NFA states that represent the entry states of this |
|
132 |
// node in the DFA. |
|
133 |
// |
|
134 |
// fFollowPos |
|
135 |
// The set of NFA states that can be gotten to from from this |
|
136 |
// node in the DFA. |
|
137 |
// |
|
138 |
// fLastPos |
|
139 |
// The set of NFA states that represent the final states of this |
|
140 |
// node in the DFA. |
|
141 |
// |
|
142 |
// fMaxStates |
|
143 |
// The maximum number of states that the NFA has, which means the |
|
144 |
// max number of NFA states that have to be traced in the state |
|
145 |
// sets during the building of the DFA. Its unfortunate that it |
|
146 |
// has to be stored redundantly, but we need to fault in the |
|
147 |
// state set members and they have to be sized to this size. We |
|
148 |
// init to to -1 so it will cause an error if its used without |
|
149 |
// being initialized. |
|
150 |
// ------------------------------------------------------------------- |
|
27111
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
151 |
private final int fType; |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
152 |
private CMStateSet fFirstPos = null; |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
153 |
private CMStateSet fFollowPos = null; |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
154 |
private CMStateSet fLastPos = null; |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
155 |
private int fMaxStates = -1; |
6 | 156 |
private Object fUserData = null; |
27111
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
157 |
/* |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
158 |
* This boolean is true if the model represented by the CMNode does not represent |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
159 |
* the true model from the schema, but has had its min/maxOccurs modified for a |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
160 |
* more compact representation (for purposes of UPA). |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
161 |
*/ |
7a491d709b83
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
25868
diff
changeset
|
162 |
private boolean fCompactedForUPA = false; |
6 | 163 |
}; |