1/*
2 * reserved comment block
3 * DO NOT REMOVE OR ALTER!
4 */
5/*
6 * Licensed to the Apache Software Foundation (ASF) under one or more
7 * contributor license agreements.  See the NOTICE file distributed with
8 * this work for additional information regarding copyright ownership.
9 * The ASF licenses this file to You under the Apache License, Version 2.0
10 * (the "License"); you may not use this file except in compliance with
11 * the License.  You may obtain a copy of the License at
12 *
13 *      http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22package com.sun.org.apache.xerces.internal.impl.dtd.models;
23
24import com.sun.org.apache.xerces.internal.impl.dtd.XMLContentSpec;
25
26/**
27 * Content model Uni-Op node.
28 *
29 * @xerces.internal
30 *
31 */
32public class CMUniOp extends CMNode
33{
34    // -------------------------------------------------------------------
35    //  Constructors
36    // -------------------------------------------------------------------
37    public CMUniOp(int type, CMNode childNode)
38    {
39        super(type);
40
41        // Insure that its one of the types we require
42        if ((type() != XMLContentSpec.CONTENTSPECNODE_ZERO_OR_ONE)
43        &&  (type() != XMLContentSpec.CONTENTSPECNODE_ZERO_OR_MORE)
44        &&  (type() != XMLContentSpec.CONTENTSPECNODE_ONE_OR_MORE))
45        {
46            throw new RuntimeException("ImplementationMessages.VAL_UST");
47        }
48
49        // Store the node and init any data that needs it
50        fChild = childNode;
51    }
52
53
54    // -------------------------------------------------------------------
55    //  Package, final methods
56    // -------------------------------------------------------------------
57    final CMNode getChild()
58    {
59        return fChild;
60    }
61
62
63    // -------------------------------------------------------------------
64    //  Package, inherited methods
65    // -------------------------------------------------------------------
66    public boolean isNullable()
67    {
68        //
69        //  For debugging purposes, make sure we got rid of all non '*'
70        //  repetitions. Otherwise, '*' style nodes are always nullable.
71        //
72        if (type() == XMLContentSpec.CONTENTSPECNODE_ONE_OR_MORE)
73            return fChild.isNullable();
74        else
75            return true;
76    }
77
78
79    // -------------------------------------------------------------------
80    //  Protected, inherited methods
81    // -------------------------------------------------------------------
82    protected void calcFirstPos(CMStateSet toSet)
83    {
84        // Its just based on our child node's first pos
85        toSet.setTo(fChild.firstPos());
86    }
87
88    protected void calcLastPos(CMStateSet toSet)
89    {
90        // Its just based on our child node's last pos
91        toSet.setTo(fChild.lastPos());
92    }
93
94
95    // -------------------------------------------------------------------
96    //  Private data members
97    //
98    //  fChild
99    //      This is the reference to the one child that we have for this
100    //      unary operation.
101    // -------------------------------------------------------------------
102    private CMNode  fChild;
103};
104