01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
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.
16: */
17:
18: package org.apache.xerces.impl.dtd.models;
19:
20: import org.apache.xerces.impl.dtd.XMLContentSpec;
21:
22: /**
23: * Content model Uni-Op node.
24: *
25: * @xerces.internal
26: *
27: * @version $Id: CMUniOp.java 572057 2007-09-02 18:03:20Z mrglavas $
28: */
29: public class CMUniOp extends CMNode {
30: // -------------------------------------------------------------------
31: // Constructors
32: // -------------------------------------------------------------------
33: public CMUniOp(int type, CMNode childNode) {
34: super (type);
35:
36: // Insure that its one of the types we require
37: if ((type() != XMLContentSpec.CONTENTSPECNODE_ZERO_OR_ONE)
38: && (type() != XMLContentSpec.CONTENTSPECNODE_ZERO_OR_MORE)
39: && (type() != XMLContentSpec.CONTENTSPECNODE_ONE_OR_MORE)) {
40: throw new RuntimeException("ImplementationMessages.VAL_UST");
41: }
42:
43: // Store the node and init any data that needs it
44: fChild = childNode;
45: }
46:
47: // -------------------------------------------------------------------
48: // Package, final methods
49: // -------------------------------------------------------------------
50: final CMNode getChild() {
51: return fChild;
52: }
53:
54: // -------------------------------------------------------------------
55: // Package, inherited methods
56: // -------------------------------------------------------------------
57: public boolean isNullable() {
58: //
59: // For debugging purposes, make sure we got rid of all non '*'
60: // repetitions. Otherwise, '*' style nodes are always nullable.
61: //
62: if (type() == XMLContentSpec.CONTENTSPECNODE_ONE_OR_MORE)
63: return fChild.isNullable();
64: else
65: return true;
66: }
67:
68: // -------------------------------------------------------------------
69: // Protected, inherited methods
70: // -------------------------------------------------------------------
71: protected void calcFirstPos(CMStateSet toSet) {
72: // Its just based on our child node's first pos
73: toSet.setTo(fChild.firstPos());
74: }
75:
76: protected void calcLastPos(CMStateSet toSet) {
77: // Its just based on our child node's last pos
78: toSet.setTo(fChild.lastPos());
79: }
80:
81: // -------------------------------------------------------------------
82: // Private data members
83: //
84: // fChild
85: // This is the reference to the one child that we have for this
86: // unary operation.
87: // -------------------------------------------------------------------
88: private final CMNode fChild;
89: };
|