1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 package org.apache.openoffice.ooxml.parser; 23 24 import java.util.HashSet; 25 import java.util.Set; 26 27 /** List of all accepting states. 28 * 29 * The accepting status of states is important when a closing tag is seen. 30 * It denotes the end of the input stream for the state machine of the currently 31 * processed element. It is an error when the current state is not accepting 32 * when a closing tag is processed. 33 */ 34 public class AcceptingStateTable 35 { AcceptingStateTable(final Iterable<String[]> aData)36 public AcceptingStateTable (final Iterable<String[]> aData) 37 { 38 maAcceptingStates = new HashSet<>(); 39 40 for (final String[] aLine : aData) 41 { 42 // Create new transition. 43 final int nStateId = Integer.parseInt(aLine[1]); 44 45 maAcceptingStates.add(nStateId); 46 } 47 } 48 49 50 51 Contains(final int nStateId)52 public boolean Contains (final int nStateId) 53 { 54 return maAcceptingStates.contains(nStateId); 55 } 56 57 58 59 GetAcceptingStateCount()60 public int GetAcceptingStateCount () 61 { 62 return maAcceptingStates.size(); 63 } 64 65 66 67 68 private final Set<Integer> maAcceptingStates; 69 } 70