summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/Argument.java
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:36:13 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:36:13 +0000
commitd6de3b8d165b29ba6f6a0a629dc83ca01b60dde1 (patch)
treea4a9f3482bb0895d43b816bb528afb5d1f0efdcd /pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/Argument.java
parent5698134700d2d13ca5021f7f0516b9cd9ebfe852 (diff)
downloadpdf-over-d6de3b8d165b29ba6f6a0a629dc83ca01b60dde1.tar.gz
pdf-over-d6de3b8d165b29ba6f6a0a629dc83ca01b60dde1.tar.bz2
pdf-over-d6de3b8d165b29ba6f6a0a629dc83ca01b60dde1.zip
Handle argument help localization correctly
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@406 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/Argument.java')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/Argument.java129
1 files changed, 129 insertions, 0 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/Argument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/Argument.java
new file mode 100644
index 00000000..761e5dc3
--- /dev/null
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/Argument.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://joinup.ec.europa.eu/software/page/eupl
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ */
+package at.asit.pdfover.gui.cliarguments;
+
+import at.asit.pdfover.gui.exceptions.InitializationException;
+import at.asit.pdfover.gui.utils.Messages;
+import at.asit.pdfover.gui.workflow.ConfigOverlayManipulator;
+import at.asit.pdfover.gui.workflow.StateMachine;
+import at.asit.pdfover.gui.workflow.Status;
+
+/**
+ * CLI Argument base class
+ */
+public abstract class Argument {
+
+ private String helpTextKey = null;
+
+ private String[] commandOptions = null;
+
+ private StateMachine stateMachine;
+
+ /**
+ * @param commandOptions
+ * @param helpTextKey
+ */
+ protected Argument(String[] commandOptions, String helpTextKey) {
+ this.helpTextKey = helpTextKey;
+ this.commandOptions = commandOptions;
+ }
+
+ /**
+ * Set the state machine
+ * Used for configuration overlay manipulator and status
+ * @param stateMachine the state machine
+ */
+ protected void setStateMachine(StateMachine stateMachine) {
+ this.stateMachine = stateMachine;
+ }
+
+ /**
+ * Get the configuration overlay manipulator
+ * @return the configuration overlay manipulator
+ */
+ protected ConfigOverlayManipulator getConfiguration() {
+ return this.stateMachine.getConfigOverlayManipulator();
+ }
+
+ /**
+ * Get the status
+ * @return the status
+ */
+ protected Status getStatus() {
+ return this.stateMachine.getStatus();
+ }
+
+ /**
+ * Set help text key
+ * @param key
+ */
+ protected void setHelpTextKey(String key) {
+ this.helpTextKey = key;
+ }
+
+ /**
+ * Gets help text
+ * @return help text
+ */
+ public String getHelpText() {
+ return Messages.getString(this.helpTextKey);
+ }
+
+ /**
+ * Set the command option in format: -...
+ *
+ * Examples: -h
+ *
+ * @param value
+ */
+ protected void setCommandOptions(String[] value) {
+ this.commandOptions = value;
+ }
+
+ /**
+ * Get the command option
+ *
+ * Examples: -h
+ * @return the command option
+ */
+ public String[] getCommandOptions() {
+ return this.commandOptions;
+ }
+
+ /**
+ * Invokes the argument to set stuff within the stateMachine
+ *
+ * It should return the offset within the args array where the last used argument of this Argument was used.
+ *
+ * Example:
+ * args[] = { "-h", "-b", "LOCAL" }
+ *
+ * Help Argument call:
+ * offset = 0
+ * returns 0
+ *
+ * BKU Argument call:
+ * offset = 1
+ * returns 2
+ *
+ * @param args
+ * @param argOffset
+ * @param handler
+ * @return returns the argumentOffset ending the section of this Argument
+ * @throws InitializationException
+ */
+ public abstract int handleArgument(String[] args, int argOffset, ArgumentHandler handler) throws InitializationException;
+}