diff --git a/.externalToolBuilders/ant XMCDA-java.jar.launch b/.externalToolBuilders/ant XMCDA-java.jar.launch index 1701f69385110fcda4f5158ed8a3c5067d113ac2..78f8499f53a93db74748897870d1c376fd6e255b 100644 --- a/.externalToolBuilders/ant XMCDA-java.jar.launch +++ b/.externalToolBuilders/ant XMCDA-java.jar.launch @@ -13,8 +13,9 @@ <stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> <booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/> <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="XMCDA-java"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/XMCDA-NG/build.xml}"/> +<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="true"/> +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/XMCDA-java/build.xml}"/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/> <booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/XMCDA-NG}"/> +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/XMCDA-java}"/> </launchConfiguration> diff --git a/CHANGES b/CHANGES new file mode 100644 index 0000000000000000000000000000000000000000..432f780d6820a273dc114305d4fcaf56e96bc5ff --- /dev/null +++ b/CHANGES @@ -0,0 +1,12 @@ +v2016.10-1 +---------- +- ProgramExecutionResult.Status.exitStatus() semantic changes:it now + returns 0 for both OK and WARNING status, 1 for ERROR and 2 for + TERMINATED. + This allows programs to use it as their own return status, + considering that both OK and WARNING status indicates a valid + execution. + +v2016.10 +-------- +First public release. diff --git a/src/org/xmcda/ProgramExecutionResult.java b/src/org/xmcda/ProgramExecutionResult.java index 33fdc3555f6ffcce89a8ac46267ef13b1a234bb2..e40ff00672f0443b26a75520a6fcc9f4fb6a0899 100644 --- a/src/org/xmcda/ProgramExecutionResult.java +++ b/src/org/xmcda/ProgramExecutionResult.java @@ -8,7 +8,7 @@ import java.util.ArrayList; * <li>its global {@link #getStatus()} status,</li> * <li>a list of @{link {@link Message messages}.</li> * </ul> - * Its status is normally deduced when the object is built: + * Its status is normally deduced during the lifespan of this object: * <ul> * <li>it starts with the default value OK;</li> * <li>its seriouness is elevated to WARNING as soon as a warning message is added;</li> @@ -19,7 +19,7 @@ import java.util.ArrayList; * this: {@code OK < WARNING < ERROR < TERMINATED}; its value always goes up, e.g. from OK to ERROR but never fall * back to a smaller value.<br/> * <br/> - *The TERMINIATED value has a special behaviour: it can only be set (or replaced by an other status) by using + * The TERMINATED value has a special behaviour: it can only be set (or replaced by an other status) by using * {@link #forceStatus(Status)}. It is intended to signal that the program has been terminated by an external * mean, when possible (for example after receiving a signal from the operating system, or terminated by the user, * etc.). @@ -32,15 +32,18 @@ public class ProgramExecutionResult extends ArrayList<Message> implements HasDescription, CommonAttributes, java.io.Serializable, XMCDARootElement { - /** This enumerates the statuses that a program execution result - * {@link ProgramExecutionResult#getStatus() can have}. + /** + * This enumerates the statuses that a program execution result {@link ProgramExecutionResult#getStatus() can have}. + * A program can use this to determine its own return status code. Both status {@code OK} and {@code WARNING} means + * that a program's execution is successful, even if a {@code WARNING} status tells that the user may have to + * check the outputs and/or the warning messages issued by the program. */ public static enum Status { /** Status OK means that neither {@link #addWarning(String)} nor {@link #addError(String)} have been called */ OK, /** Status WARNING means that at least a warning has been signaled with {@link #addWarning(String)}, but that - * no {@link #addError(String) errors} have been signalled. */ + * no {@link #addError(String) errors} have been signaled. */ WARNING, /** Status ERROR means that at least an error has been signaled with {@link #addError(String)}. */ ERROR, @@ -48,11 +51,30 @@ public class ProgramExecutionResult * {@link #forceStatus(Status) forceStatus(Status.TERMINATED)} */ TERMINATED; + /** + * Returns the exit status corresponding to this status. A program typically use this for returning its own exit + * status. + * <ul> + * <li>{@code OK} and {@WARNING} status represents a successful execution, hence the return code is {@code 0} + * (zero), + * <li>{@code ERROR} returns 1, + * <li>{@code TERMINATED} return 2. + * + * @return 0 for {@code OK} and {@code WARNING}, 1 for {@code ERROR} and 2 for {@code TERMINATED}. + */ public int exitStatus() { - return this.ordinal(); + switch (this) + { + case OK: + case WARNING: return 0; + case ERROR: return 1; + case TERMINATED: return 2; + default: + throw new RuntimeException("Unknown status :" + this.toString()); + } } - }; + } private static final long serialVersionUID = 1L;