KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > impl > dtd > models > CMUniOp


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.dtd.models;
18
19 import org.apache.xerces.impl.dtd.XMLContentSpec;
20
21 /**
22  * Content model Uni-Op node.
23  *
24  * @xerces.internal
25  *
26  * @version $Id: CMUniOp.java,v 1.4 2004/10/04 22:00:42 mrglavas Exp $
27  */

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