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.xs.models;
19:
20: import org.apache.xerces.impl.dtd.models.CMNode;
21: import org.apache.xerces.impl.dtd.models.CMStateSet;
22: import org.apache.xerces.impl.xs.XSParticleDecl;
23:
24: /**
25: *
26: * Content model Uni-Op node.
27: *
28: * @xerces.internal
29: *
30: * @author Neil Graham, IBM
31: * @version $Id: XSCMUniOp.java 476309 2006-11-17 20:49:31Z mrglavas $
32: */
33: public class XSCMUniOp extends CMNode {
34: // -------------------------------------------------------------------
35: // Constructors
36: // -------------------------------------------------------------------
37: public XSCMUniOp(int type, CMNode childNode) {
38: super (type);
39:
40: // Insure that its one of the types we require
41: if ((type() != XSParticleDecl.PARTICLE_ZERO_OR_ONE)
42: && (type() != XSParticleDecl.PARTICLE_ZERO_OR_MORE)
43: && (type() != XSParticleDecl.PARTICLE_ONE_OR_MORE)) {
44: throw new RuntimeException("ImplementationMessages.VAL_UST");
45: }
46:
47: // Store the node and init any data that needs it
48: fChild = childNode;
49: }
50:
51: // -------------------------------------------------------------------
52: // Package, final methods
53: // -------------------------------------------------------------------
54: final CMNode getChild() {
55: return fChild;
56: }
57:
58: // -------------------------------------------------------------------
59: // Package, inherited methods
60: // -------------------------------------------------------------------
61: public boolean isNullable() {
62: //
63: // For debugging purposes, make sure we got rid of all non '*'
64: // repetitions. Otherwise, '*' style nodes are always nullable.
65: //
66: if (type() == XSParticleDecl.PARTICLE_ONE_OR_MORE)
67: return fChild.isNullable();
68: else
69: return true;
70: }
71:
72: // -------------------------------------------------------------------
73: // Protected, inherited methods
74: // -------------------------------------------------------------------
75: protected void calcFirstPos(CMStateSet toSet) {
76: // Its just based on our child node's first pos
77: toSet.setTo(fChild.firstPos());
78: }
79:
80: protected void calcLastPos(CMStateSet toSet) {
81: // Its just based on our child node's last pos
82: toSet.setTo(fChild.lastPos());
83: }
84:
85: // -------------------------------------------------------------------
86: // Private data members
87: //
88: // fChild
89: // This is the reference to the one child that we have for this
90: // unary operation.
91: // -------------------------------------------------------------------
92: private CMNode fChild;
93: } // XSCMUniOp
|