KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > impl > xs > models > XSCMUniOp


1 /*
2  * Copyright 1999-2002,2004 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.xs.models;
18
19 import org.apache.xerces.impl.dtd.models.CMNode;
20 import org.apache.xerces.impl.dtd.models.CMStateSet;
21 import org.apache.xerces.impl.xs.XSParticleDecl;
22
23 /**
24  *
25  * Content model Uni-Op node.
26  *
27  * @xerces.internal
28  *
29  * @author Neil Graham, IBM
30  * @version $$
31  */

32 public class XSCMUniOp extends CMNode {
33     // -------------------------------------------------------------------
34
// Constructors
35
// -------------------------------------------------------------------
36
public XSCMUniOp(int type, CMNode childNode) {
37         super(type);
38
39         // Insure that its one of the types we require
40
if ((type() != XSParticleDecl.PARTICLE_ZERO_OR_ONE)
41         && (type() != XSParticleDecl.PARTICLE_ZERO_OR_MORE)
42         && (type() != XSParticleDecl.PARTICLE_ONE_OR_MORE)) {
43             throw new RuntimeException JavaDoc("ImplementationMessages.VAL_UST");
44         }
45
46         // Store the node and init any data that needs it
47
fChild = childNode;
48     }
49
50
51     // -------------------------------------------------------------------
52
// Package, final methods
53
// -------------------------------------------------------------------
54
final CMNode getChild() {
55         return fChild;
56     }
57
58
59     // -------------------------------------------------------------------
60
// Package, inherited methods
61
// -------------------------------------------------------------------
62
public boolean isNullable() {
63         //
64
// For debugging purposes, make sure we got rid of all non '*'
65
// repetitions. Otherwise, '*' style nodes are always nullable.
66
//
67
if (type() == XSParticleDecl.PARTICLE_ONE_OR_MORE)
68             return fChild.isNullable();
69         else
70             return true;
71     }
72
73
74     // -------------------------------------------------------------------
75
// Protected, inherited methods
76
// -------------------------------------------------------------------
77
protected void calcFirstPos(CMStateSet toSet) {
78         // Its just based on our child node's first pos
79
toSet.setTo(fChild.firstPos());
80     }
81
82     protected void calcLastPos(CMStateSet toSet) {
83         // Its just based on our child node's last pos
84
toSet.setTo(fChild.lastPos());
85     }
86
87
88     // -------------------------------------------------------------------
89
// Private data members
90
//
91
// fChild
92
// This is the reference to the one child that we have for this
93
// unary operation.
94
// -------------------------------------------------------------------
95
private CMNode fChild;
96 } // XSCMUniOp
97

98
Popular Tags