286N/A/*
286N/A * reserved comment block
286N/A * DO NOT REMOVE OR ALTER!
286N/A */
286N/A/*
286N/A * Copyright 2001-2004 The Apache Software Foundation.
286N/A *
286N/A * Licensed under the Apache License, Version 2.0 (the "License");
286N/A * you may not use this file except in compliance with the License.
286N/A * You may obtain a copy of the License at
286N/A *
286N/A * http://www.apache.org/licenses/LICENSE-2.0
286N/A *
286N/A * Unless required by applicable law or agreed to in writing, software
286N/A * distributed under the License is distributed on an "AS IS" BASIS,
286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
286N/A * See the License for the specific language governing permissions and
286N/A * limitations under the License.
286N/A */
286N/A
286N/Apackage com.sun.org.apache.xerces.internal.impl.xs.models;
286N/A
286N/Aimport com.sun.org.apache.xerces.internal.xni.QName;
286N/Aimport com.sun.org.apache.xerces.internal.impl.xs.SubstitutionGroupHandler;
286N/Aimport com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaException;
286N/A
286N/Aimport java.util.Vector;
286N/Aimport java.util.ArrayList;
286N/A
286N/A/**
286N/A * XSEmptyCM is a derivative of the abstract content model base class that
286N/A * handles a content model with no chilren (elements).
286N/A *
286N/A * This model validated on the way in.
286N/A *
286N/A * @xerces.internal
286N/A *
286N/A * @author Elena Litani, Lisa Martin
286N/A * @author IBM
286N/A * @version $Id: XSEmptyCM.java,v 1.7 2009/07/28 15:18:11 spericas Exp $
286N/A */
286N/Apublic class XSEmptyCM implements XSCMValidator {
286N/A
286N/A //
286N/A // Constants
286N/A //
286N/A
286N/A // start the content model: did not see any children
286N/A private static final short STATE_START = 0;
286N/A
286N/A private static final Vector EMPTY = new Vector(0);
286N/A
286N/A //
286N/A // Data
286N/A //
286N/A
286N/A //
286N/A // XSCMValidator methods
286N/A //
286N/A
286N/A /**
286N/A * This methods to be called on entering a first element whose type
286N/A * has this content model. It will return the initial state of the content model
286N/A *
286N/A * @return Start state of the content model
286N/A */
286N/A public int[] startContentModel(){
286N/A return (new int[] {STATE_START});
286N/A }
286N/A
286N/A
286N/A /**
286N/A * The method corresponds to one transaction in the content model.
286N/A *
286N/A * @param elementName the qualified name of the element
286N/A * @param currentState Current state
286N/A * @param subGroupHandler the substitution group handler
286N/A * @return element index corresponding to the element from the Schema grammar
286N/A */
286N/A public Object oneTransition (QName elementName, int[] currentState, SubstitutionGroupHandler subGroupHandler){
286N/A
286N/A // error state
286N/A if (currentState[0] < 0) {
286N/A currentState[0] = XSCMValidator.SUBSEQUENT_ERROR;
286N/A return null;
286N/A }
286N/A
286N/A currentState[0] = XSCMValidator.FIRST_ERROR;
286N/A return null;
286N/A }
286N/A
286N/A
286N/A /**
286N/A * The method indicates the end of list of children
286N/A *
286N/A * @param currentState Current state of the content model
286N/A * @return true if the last state was a valid final state
286N/A */
286N/A public boolean endContentModel (int[] currentState){
286N/A boolean isFinal = false;
286N/A int state = currentState[0];
286N/A
286N/A // restore content model state:
286N/A
286N/A // error
286N/A if (state < 0) {
286N/A return false;
286N/A }
286N/A
286N/A
286N/A return true;
286N/A }
286N/A
286N/A /**
286N/A * check whether this content violates UPA constraint.
286N/A *
286N/A * @param subGroupHandler the substitution group handler
286N/A * @return true if this content model contains other or list wildcard
286N/A */
286N/A public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException {
286N/A return false;
286N/A }
286N/A
286N/A /**
286N/A * Check which elements are valid to appear at this point. This method also
286N/A * works if the state is in error, in which case it returns what should
286N/A * have been seen.
286N/A *
286N/A * @param state the current state
286N/A * @return a Vector whose entries are instances of
286N/A * either XSWildcardDecl or XSElementDecl.
286N/A */
286N/A public Vector whatCanGoHere(int[] state) {
286N/A return EMPTY;
286N/A }
286N/A
286N/A public ArrayList checkMinMaxBounds() {
286N/A return null;
286N/A }
286N/A
286N/A} // class XSEmptyCM