1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * The Apache Software License, Version 1.1
   7  *
   8  *
   9  * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  10  * reserved.
  11  *
  12  * Redistribution and use in source and binary forms, with or without
  13  * modification, are permitted provided that the following conditions
  14  * are met:
  15  *
  16  * 1. Redistributions of source code must retain the above copyright
  17  *    notice, this list of conditions and the following disclaimer.
  18  *
  19  * 2. Redistributions in binary form must reproduce the above copyright
  20  *    notice, this list of conditions and the following disclaimer in
  21  *    the documentation and/or other materials provided with the
  22  *    distribution.
  23  *
  24  * 3. The end-user documentation included with the redistribution,
  25  *    if any, must include the following acknowledgment:
  26  *       "This product includes software developed by the
  27  *        Apache Software Foundation (http://www.apache.org/)."
  28  *    Alternately, this acknowledgment may appear in the software itself,
  29  *    if and wherever such third-party acknowledgments normally appear.
  30  *
  31  * 4. The names "Xerces" and "Apache Software Foundation" must
  32  *    not be used to endorse or promote products derived from this
  33  *    software without prior written permission. For written
  34  *    permission, please contact apache@apache.org.
  35  *
  36  * 5. Products derived from this software may not be called "Apache",
  37  *    nor may "Apache" appear in their name, without prior written
  38  *    permission of the Apache Software Foundation.
  39  *
  40  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  41  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  42  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  43  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  44  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  45  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  46  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  47  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  48  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  49  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  50  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  51  * SUCH DAMAGE.
  52  * ====================================================================
  53  *
  54  * This software consists of voluntary contributions made by many
  55  * individuals on behalf of the Apache Software Foundation and was
  56  * originally based on software copyright (c) 1999, International
  57  * Business Machines, Inc., http://www.apache.org.  For more
  58  * information on the Apache Software Foundation, please see
  59  * <http://www.apache.org/>.
  60  */
  61 
  62 package com.sun.org.apache.xerces.internal.impl.dtd.models;
  63 
  64 import com.sun.org.apache.xerces.internal.impl.dtd.XMLContentSpec;
  65 
  66 /**
  67  * Content model Uni-Op node.
  68  *
  69  * @xerces.internal
  70  *
  71  */
  72 public class CMUniOp extends CMNode
  73 {
  74     // -------------------------------------------------------------------
  75     //  Constructors
  76     // -------------------------------------------------------------------
  77     public CMUniOp(int type, CMNode childNode)
  78     {
  79         super(type);
  80 
  81         // Insure that its one of the types we require
  82         if ((type() != XMLContentSpec.CONTENTSPECNODE_ZERO_OR_ONE)
  83         &&  (type() != XMLContentSpec.CONTENTSPECNODE_ZERO_OR_MORE)
  84         &&  (type() != XMLContentSpec.CONTENTSPECNODE_ONE_OR_MORE))
  85         {
  86             throw new RuntimeException("ImplementationMessages.VAL_UST");
  87         }
  88 
  89         // Store the node and init any data that needs it
  90         fChild = childNode;
  91     }
  92 
  93 
  94     // -------------------------------------------------------------------
  95     //  Package, final methods
  96     // -------------------------------------------------------------------
  97     final CMNode getChild()
  98     {
  99         return fChild;
 100     }
 101 
 102 
 103     // -------------------------------------------------------------------
 104     //  Package, inherited methods
 105     // -------------------------------------------------------------------
 106     public boolean isNullable()
 107     {
 108         //
 109         //  For debugging purposes, make sure we got rid of all non '*'
 110         //  repetitions. Otherwise, '*' style nodes are always nullable.
 111         //
 112         if (type() == XMLContentSpec.CONTENTSPECNODE_ONE_OR_MORE)
 113             return fChild.isNullable();
 114         else
 115             return true;
 116     }
 117 
 118 
 119     // -------------------------------------------------------------------
 120     //  Protected, inherited methods
 121     // -------------------------------------------------------------------
 122     protected void calcFirstPos(CMStateSet toSet)
 123     {
 124         // Its just based on our child node's first pos
 125         toSet.setTo(fChild.firstPos());
 126     }
 127 
 128     protected void calcLastPos(CMStateSet toSet)
 129     {
 130         // Its just based on our child node's last pos
 131         toSet.setTo(fChild.lastPos());
 132     }
 133 
 134 
 135     // -------------------------------------------------------------------
 136     //  Private data members
 137     //
 138     //  fChild
 139     //      This is the reference to the one child that we have for this
 140     //      unary operation.
 141     // -------------------------------------------------------------------
 142     private CMNode  fChild;
 143 };