franta-hg@54: /**
franta-hg@54: * Alt2XML
franta-hg@54: * Copyright © 2014 František Kučera (frantovo.cz)
franta-hg@54: *
franta-hg@54: * This program is free software: you can redistribute it and/or modify
franta-hg@54: * it under the terms of the GNU General Public License as published by
franta-hg@111: * the Free Software Foundation, version 3 of the License.
franta-hg@54: *
franta-hg@54: * This program is distributed in the hope that it will be useful,
franta-hg@54: * but WITHOUT ANY WARRANTY; without even the implied warranty of
franta-hg@54: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
franta-hg@54: * GNU General Public License for more details.
franta-hg@54: *
franta-hg@54: * You should have received a copy of the GNU General Public License
franta-hg@54: * along with this program. If not, see .
franta-hg@54: */
franta-hg@54: package cz.frantovo.alt2xml.cli;
franta-hg@54:
franta-hg@54: import java.util.ArrayList;
franta-hg@54: import java.util.Collection;
franta-hg@54: import java.util.Collections;
franta-hg@54:
franta-hg@54: /**
franta-hg@54: *
franta-hg@54: * @author Ing. František Kučera (frantovo.cz)
franta-hg@54: */
franta-hg@54: public class InvalidOptionsException extends Exception {
franta-hg@54:
franta-hg@54: private final Collection problems = new ArrayList<>();
franta-hg@54:
franta-hg@54: public Collection getProblems() {
franta-hg@54: return Collections.unmodifiableCollection(problems);
franta-hg@54: }
franta-hg@54:
franta-hg@54: public void addProblem(OptionProblem p) {
franta-hg@54: problems.add(p);
franta-hg@54: }
franta-hg@54:
franta-hg@54: public boolean hasProblems() {
franta-hg@54: return !problems.isEmpty();
franta-hg@54: }
franta-hg@54:
franta-hg@54: public static class OptionProblem {
franta-hg@54:
franta-hg@54: private String description;
franta-hg@54: private Throwable exception;
franta-hg@54:
franta-hg@54: public OptionProblem(String description) {
franta-hg@54: this.description = description;
franta-hg@54: }
franta-hg@54:
franta-hg@54: public OptionProblem(String description, Throwable exception) {
franta-hg@54: this.description = description;
franta-hg@54: this.exception = exception;
franta-hg@54: }
franta-hg@54:
franta-hg@54: public String getDescription() {
franta-hg@54: return description;
franta-hg@54: }
franta-hg@54:
franta-hg@54: public Throwable getException() {
franta-hg@54: return exception;
franta-hg@54: }
franta-hg@54: }
franta-hg@54: }