All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sun.msv.reader.ChoiceState Maven / Gradle / Ivy

There is a newer version: 2.2.5.1
Show newest version
/*
 * @(#)$Id: ChoiceState.java,v 1.6 2003/06/09 20:37:23 kk122374 Exp $
 *
 * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
 * 
 * This software is the proprietary information of Sun Microsystems, Inc.  
 * Use is subject to license terms.
 * 
 */
package com.sun.msv.reader;

import com.sun.msv.grammar.Expression;

/**
 * state that creates ChoiceExp.
 * 
 * @author Kohsuke KAWAGUCHI
 */
public class ChoiceState extends ExpressionWithChildState {
    public ChoiceState() {
        this(false);
    }
    public ChoiceState( boolean allowEmptyChoice ) {
        this.allowEmptyChoice = allowEmptyChoice;
    }
    
    protected boolean allowEmptyChoice;
    
    protected Expression initialExpression() {
        return allowEmptyChoice?Expression.nullSet:null;
    }
    
    protected Expression castExpression( Expression exp, Expression child ) {
        // first one.
        if( exp==null )    return child;
        else            return reader.pool.createChoice(exp,child);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy