1 /* 2 * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved. 3 */ 4 /* 5 * Licensed to the Apache Software Foundation (ASF) under one or more 6 * contributor license agreements. See the NOTICE file distributed with 7 * this work for additional information regarding copyright ownership. 8 * The ASF licenses this file to You under the Apache License, Version 2.0 9 * (the "License"); you may not use this file except in compliance with 10 * the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20 21 package com.sun.org.apache.xerces.internal.impl.xs.models; 22 23 import com.sun.org.apache.xerces.internal.impl.xs.SubstitutionGroupHandler; 24 import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaException; 25 import com.sun.org.apache.xerces.internal.xni.QName; 26 import java.util.List; 27 28 /** 29 * Note: State of the content model is stored in the validator 30 * 31 * @xerces.internal 32 * 33 * @author Sandy Gao, IBM 34 * @author Elena Litani, IBM 35 * @LastModified: Oct 2017 36 */ 37 public interface XSCMValidator { 38 39 40 public static final short FIRST_ERROR = -1; 41 42 // on subsequent errors the validator should not report 43 // an error 44 // 45 public static final short SUBSEQUENT_ERROR = -2; 46 47 /** 48 * This methods to be called on entering a first element whose type 49 * has this content model. It will return the initial state of the content model 50 * 51 * @return Start state of the content model 52 */ 53 public int[] startContentModel(); 54 55 56 /** 57 * The method corresponds to one transaction in the content model. 58 * 59 * @param elementName 60 * @param state Current state 61 * @return element decl or wildcard decl that 62 * corresponds to the element from the Schema grammar 63 */ 64 public Object oneTransition (QName elementName, int[] state, SubstitutionGroupHandler subGroupHandler); 65 66 67 /** 68 * The method indicates the end of list of children 69 * 70 * @param state Current state of the content model 71 * @return true if the last state was a valid final state 72 */ 73 public boolean endContentModel (int[] state); 74 75 /** 76 * check whether this content violates UPA constraint. 77 * 78 * @param subGroupHandler the substitution group handler 79 * @return true if this content model contains other or list wildcard 80 */ 81 public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException; 82 83 /** 84 * Check which elements are valid to appear at this point. This method also 85 * works if the state is in error, in which case it returns what should 86 * have been seen. 87 * 88 * @param state the current state 89 * @return a list whose entries are instances of 90 * either XSWildcardDecl or XSElementDecl. 91 */ 92 public List<Object> whatCanGoHere(int[] state); 93 94 /** 95 * Used by constant space algorithm for a{n,m} for n > 1 and 96 * m <= unbounded. Called by a validator if validation of 97 * countent model succeeds after subsuming a{n,m} to a* 98 * (or a+) to check the n and m bounds. 99 * 100 * @return <code>null</code> if validation of bounds is 101 * successful. Returns a list of strings with error info 102 * if not. Even entries in list returned are error codes 103 * (used to look up properties) and odd entries are parameters 104 * to be passed when formatting error message. Each parameter 105 * is associated with the error code that proceeds it in 106 * the list. 107 */ 108 public List<String> checkMinMaxBounds(); 109 110 /** 111 * <p>Returns an array containing information about the current repeating term 112 * or <code>null</code> if no occurrence counting was being performed at the 113 * current state.</p> 114 * 115 * <p>If an array is returned it will have a length == 4 and will contain: 116 * <ul> 117 * <li>a[0] :: min occurs</li> 118 * <li>a[1] :: max occurs</li> 119 * <li>a[2] :: current value of the counter</li> 120 * <li>a[3] :: identifier for the repeating term</li> 121 * </ul> 122 * </p> 123 * 124 * @param state the current state 125 * @return an array containing information about the current repeating term 126 */ 127 public int [] occurenceInfo(int[] state); 128 129 /** 130 * Returns the name of the term (element or wildcard) for the given identifier. 131 * 132 * @param termId identifier for the element declaration or wildcard 133 * @return the name of the element declaration or wildcard 134 */ 135 public String getTermName(int termId); 136 137 /** 138 * Checks if this content model has had its min/maxOccurs values reduced for 139 * purposes of speeding up UPA. If so, this content model should not be used 140 * for any purpose other than checking unique particle attribution 141 * 142 * @return a boolean that says whether this content has been compacted for UPA 143 */ 144 public boolean isCompactedForUPA(); 145 } // XSCMValidator