2 * Copyright (c) 2012, Takeyuki Nagao
5 * Redistribution and use in source and binary forms, with or
6 * without modification, are permitted provided that the
7 * following conditions are met:
9 * * Redistributions of source code must retain the above
10 * copyright notice, this list of conditions and the
11 * following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the
14 * following disclaimer in the documentation and/or other
15 * materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
18 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
19 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
29 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
33 package jp.sourceforge.dvibrowser.dvi2epub.cmd;
35 import java.util.ArrayList;
36 import java.util.Arrays;
37 import java.util.List;
39 public class ParserState {
40 private final String[] args;
41 private List<String> list = new ArrayList<String>();
42 private Throwable throwable;
43 private boolean stop = false;
44 private String optionName;
45 private String optionParameter;
47 public ParserState(String [] args) {
49 this.list.addAll(Arrays.asList(args));
52 public String[] getOriginalArgs() {
56 public List<String> getList() {
60 public String shift() {
62 if (list.size() > 0) {
68 public void unshift(String value) {
72 public boolean wantStop() {
76 public void wantStop(boolean stop) {
80 public void setError(Throwable ex) {
84 public void stopWithError(Throwable ex) {
89 public Throwable getThrowable() {
90 return this.throwable;
93 public boolean hasError() {
94 return getThrowable() != null;
97 public String getOptionParameter() {
98 return optionParameter;
101 public void setOptionParameter(String optionParameter) {
102 this.optionParameter = optionParameter;
105 public String getOptionName() {
109 public void setOptionName(String optionName) {
110 this.optionName = optionName;