2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
18
package org.apache.xerces.impl.dtd.models;
20
import org.apache.xerces.impl.dtd.XMLContentSpec;
21
import org.apache.xerces.xni.QName;
24
* Content model leaf node.
28
* @version $Id: CMLeaf.java,v 1.2 2009/12/10 03:18:46 matthewoliver Exp $
37
/** This is the element that this leaf represents. */
38
private final QName fElement = new QName();
41
* Part of the algorithm to convert a regex directly to a DFA
42
* numbers each leaf sequentially. If its -1, that means its an
43
* epsilon node. Zero and greater are non-epsilon positions.
45
private int fPosition = -1;
51
/** Constructs a content model leaf. */
52
public CMLeaf(QName element, int position) {
53
super(XMLContentSpec.CONTENTSPECNODE_LEAF);
55
// Store the element index and position
56
fElement.setValues(element);
60
/** Constructs a content model leaf. */
61
public CMLeaf(QName element) {
62
super(XMLContentSpec.CONTENTSPECNODE_LEAF);
64
// Store the element index and position
65
fElement.setValues(element);
72
final QName getElement()
77
final int getPosition()
82
final void setPosition(int newPosition)
84
fPosition = newPosition;
93
public boolean isNullable()
95
// Leaf nodes are never nullable unless its an epsilon node
96
return (fPosition == -1);
99
public String toString()
101
StringBuffer strRet = new StringBuffer(fElement.toString());
103
strRet.append(fElement.uri);
105
strRet.append(fElement.localpart);
107
if (fPosition >= 0) {
108
strRet.append(" (Pos:")
109
.append(Integer.toString(fPosition))
112
return strRet.toString();
117
protected void calcFirstPos(CMStateSet toSet)
119
// If we are an epsilon node, then the first pos is an empty set
123
// Otherwise, its just the one bit of our position
125
toSet.setBit(fPosition);
128
protected void calcLastPos(CMStateSet toSet)
130
// If we are an epsilon node, then the last pos is an empty set
134
// Otherwise, its just the one bit of our position
136
toSet.setBit(fPosition);