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 22 package com.sun.org.apache.xerces.internal.impl.xs.models; 23 24 import com.sun.org.apache.xerces.internal.impl.dtd.models.CMNode; 25 import com.sun.org.apache.xerces.internal.impl.dtd.models.CMStateSet; 26 import com.sun.org.apache.xerces.internal.impl.xs.XSParticleDecl; 27 28 /** 29 * 30 * Content model Uni-Op node. 31 * 32 * @xerces.internal 33 * 34 * @author Neil Graham, IBM 35 * @version $$ 36 */ 37 public class XSCMUniOp extends CMNode { 38 // ------------------------------------------------------------------- 39 // Constructors 40 // ------------------------------------------------------------------- 41 public XSCMUniOp(int type, CMNode childNode) { 42 super(type); 43 44 // Insure that its one of the types we require 45 if ((type() != XSParticleDecl.PARTICLE_ZERO_OR_ONE) 46 && (type() != XSParticleDecl.PARTICLE_ZERO_OR_MORE) 47 && (type() != XSParticleDecl.PARTICLE_ONE_OR_MORE)) { 48 throw new RuntimeException("ImplementationMessages.VAL_UST"); 49 } 50 51 // Store the node and init any data that needs it 52 fChild = childNode; 53 } 54 55 56 // ------------------------------------------------------------------- 57 // Package, final methods 58 // ------------------------------------------------------------------- 59 final CMNode getChild() { 60 return fChild; 61 } 62 63 64 // ------------------------------------------------------------------- 65 // Package, inherited methods 66 // ------------------------------------------------------------------- 67 public boolean isNullable() { 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() == XSParticleDecl.PARTICLE_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 // Its just based on our child node's first pos 84 toSet.setTo(fChild.firstPos()); 85 } 86 87 protected void calcLastPos(CMStateSet toSet) { 88 // Its just based on our child node's last pos 89 toSet.setTo(fChild.lastPos()); 90 } 91 92 /** 93 * Allows the user to set arbitrary data on this content model 94 * node. This is used by the a{n,m} optimization that runs 95 * in constant space. For convenience, set user data in 96 * children node too. 97 */ 98 @Override 99 public void setUserData(Object userData) { 100 super.setUserData(userData); 101 fChild.setUserData(userData); 102 } 103 104 105 // ------------------------------------------------------------------- 106 // Private data members 107 // 108 // fChild 109 // This is the reference to the one child that we have for this 110 // unary operation. 111 // ------------------------------------------------------------------- 112 private CMNode fChild; 113 } // XSCMUniOp