Author: rahul Date: Mon Oct 2 09:53:06 2006 New Revision: 452118 URL: http://svn.apache.org/viewvc?view=rev&rev=452118 Log: Deprecate ErrorReporter fields.
SCXML-25 Added: jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/semantics/ErrorConstants.java (with props) Modified: jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/ErrorReporter.java jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLHelper.java jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/env/SimpleErrorReporter.java jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Assign.java jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Send.java jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLHelperTest.java Modified: jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/ErrorReporter.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/ErrorReporter.java?view=diff&rev=452118&r1=452117&r2=452118 ============================================================================== --- jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/ErrorReporter.java (original) +++ jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/ErrorReporter.java Mon Oct 2 09:53:06 2006 @@ -1,6 +1,6 @@ /* * - * Copyright 2005 The Apache Software Foundation. + * Copyright 2005-2006 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,9 @@ */ package org.apache.commons.scxml; +// Used for suggesting replacement in deprecation warnings +import org.apache.commons.scxml.semantics.ErrorConstants; + /** * An interface for reporting SCXML errors to the host environment, * containing the definition of commonly occuring errors while executing @@ -39,10 +42,12 @@ void onError(String errCode, String errDetail, Object errCtx); /** - * Missing initial state for a composite state or for the smxml root. + * Missing initial state for a composite state or for the scxml root. * * @see org.apache.commons.scxml.model.SCXML#getInitialState() * @see org.apache.commons.scxml.model.State#getInitial() + * + * @deprecated Use [EMAIL PROTECTED] ErrorConstants#NO_INITIAL} instead. */ String NO_INITIAL = "NO_INITIAL"; @@ -50,12 +55,15 @@ * An initial state for a composite state whose Transition does not. * Map to a descendant of the composite state. * + * @deprecated Use [EMAIL PROTECTED] ErrorConstants#ILLEGAL_INITIAL} instead. */ String ILLEGAL_INITIAL = "ILLEGAL_INITIAL"; /** * Unknown action - unsupported executable content. List of supported. * actions: assign, cancel, elseif, else, if, log, send, var + * + * @deprecated Use [EMAIL PROTECTED] ErrorConstants#UNKNOWN_ACTION} instead. */ String UNKNOWN_ACTION = "UNKNOWN_ACTION"; @@ -63,22 +71,30 @@ * Illegal state machine configuration. * Either a parallel exists which does not have all its AND sub-states * active or there are multiple enabled OR states on the same level. + * + * @deprecated Use [EMAIL PROTECTED] ErrorConstants#ILLEGAL_CONFIG} instead. */ String ILLEGAL_CONFIG = "ILLEGAL_CONFIG"; /** * Non-deterministic situation has occured - there are more than * one enabled transitions in conflict. + * + * @deprecated Use [EMAIL PROTECTED] ErrorConstants#NON_DETERMINISTIC} instead. */ String NON_DETERMINISTIC = "NON_DETERMINISTIC"; /** * A variable referred to by assign name attribute is undefined. + * + * @deprecated Use [EMAIL PROTECTED] ErrorConstants#UNDEFINED_VARIABLE} instead. */ String UNDEFINED_VARIABLE = "UNDEFINED_VARIABLE"; /** * An expression language error. + * + * @deprecated Use [EMAIL PROTECTED] ErrorConstants#EXPRESSION_ERROR} instead. */ String EXPRESSION_ERROR = "EXPRESSION_ERROR"; Modified: jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLHelper.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLHelper.java?view=diff&rev=452118&r1=452117&r2=452118 ============================================================================== --- jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLHelper.java (original) +++ jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLHelper.java Mon Oct 2 09:53:06 2006 @@ -1,6 +1,6 @@ /* * - * Copyright 2005 The Apache Software Foundation. + * Copyright 2005-2006 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ import org.apache.commons.scxml.model.State; import org.apache.commons.scxml.model.Transition; import org.apache.commons.scxml.model.TransitionTarget; +import org.apache.commons.scxml.semantics.ErrorConstants; import org.w3c.dom.CharacterData; import org.w3c.dom.Node; import org.w3c.dom.Text; @@ -153,14 +154,14 @@ if (tt instanceof Parallel) { Parallel p = (Parallel) tt; if (count.size() < p.getStates().size()) { - errRep.onError(ErrorReporter.ILLEGAL_CONFIG, + errRep.onError(ErrorConstants.ILLEGAL_CONFIG, "Not all AND states active for parallel " + p.getId(), entry); legalConfig = false; } } else { if (count.size() > 1) { - errRep.onError(ErrorReporter.ILLEGAL_CONFIG, + errRep.onError(ErrorConstants.ILLEGAL_CONFIG, "Multiple OR states active for state " + tt.getId(), entry); legalConfig = false; @@ -169,7 +170,7 @@ count.clear(); //cleanup } if (scxmlCount.size() > 1) { - errRep.onError(ErrorReporter.ILLEGAL_CONFIG, + errRep.onError(ErrorConstants.ILLEGAL_CONFIG, "Multiple top-level OR states active!", scxmlCount); } //cleanup Modified: jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/env/SimpleErrorReporter.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/env/SimpleErrorReporter.java?view=diff&rev=452118&r1=452117&r2=452118 ============================================================================== --- jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/env/SimpleErrorReporter.java (original) +++ jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/env/SimpleErrorReporter.java Mon Oct 2 09:53:06 2006 @@ -1,6 +1,6 @@ /* * - * Copyright 2005 The Apache Software Foundation. + * Copyright 2005-2006 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,12 +24,12 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.apache.commons.scxml.ErrorReporter; import org.apache.commons.scxml.model.SCXML; import org.apache.commons.scxml.model.State; import org.apache.commons.scxml.model.Transition; import org.apache.commons.scxml.model.TransitionTarget; +import org.apache.commons.scxml.semantics.ErrorConstants; /** * Custom error reporter that log execution errors. @@ -57,7 +57,7 @@ StringBuffer msg = new StringBuffer(); msg.append(errCode).append(" ("); msg.append(errDetail).append("): "); - if (errCode == ErrorReporter.NO_INITIAL) { + if (errCode == ErrorConstants.NO_INITIAL) { if (errCtx instanceof SCXML) { //determineInitialStates msg.append("<SCXML>"); @@ -66,10 +66,10 @@ //determineTargetStates msg.append("State " + LogUtils.getTTPath((State) errCtx)); } - } else if (errCode == ErrorReporter.UNKNOWN_ACTION) { + } else if (errCode == ErrorConstants.UNKNOWN_ACTION) { //executeActionList msg.append("Action: " + errCtx.getClass().getName()); - } else if (errCode == ErrorReporter.NON_DETERMINISTIC) { + } else if (errCode == ErrorConstants.NON_DETERMINISTIC) { //filterTransitionSet msg.append(" ["); if (errCtx instanceof HashSet) { @@ -83,7 +83,7 @@ } } msg.append(']'); - } else if (errCode == ErrorReporter.ILLEGAL_CONFIG) { + } else if (errCode == ErrorConstants.ILLEGAL_CONFIG) { //isLegalConfig if (errCtx instanceof Map.Entry) { TransitionTarget tt = (TransitionTarget) Modified: jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Assign.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Assign.java?view=diff&rev=452118&r1=452117&r2=452118 ============================================================================== --- jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Assign.java (original) +++ jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Assign.java Mon Oct 2 09:53:06 2006 @@ -1,6 +1,6 @@ /* * - * Copyright 2005 The Apache Software Foundation. + * Copyright 2005-2006 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ import org.apache.commons.scxml.SCXMLExpressionException; import org.apache.commons.scxml.SCXMLHelper; import org.apache.commons.scxml.TriggerEvent; +import org.apache.commons.scxml.semantics.ErrorConstants; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -214,7 +215,7 @@ } else { // lets try "name" (usage as in Sep '05 WD, useful with <var>) if (!ctx.has(name)) { - errRep.onError(ErrorReporter.UNDEFINED_VARIABLE, name + errRep.onError(ErrorConstants.UNDEFINED_VARIABLE, name + " = null", parentState); } else { Object varObj = null; Modified: jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Send.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Send.java?view=diff&rev=452118&r1=452117&r2=452118 ============================================================================== --- jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Send.java (original) +++ jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Send.java Mon Oct 2 09:53:06 2006 @@ -33,6 +33,7 @@ import org.apache.commons.scxml.SCXMLExpressionException; import org.apache.commons.scxml.SCXMLHelper; import org.apache.commons.scxml.TriggerEvent; +import org.apache.commons.scxml.semantics.ErrorConstants; /** * The class in this SCXML object model that corresponds to the @@ -298,7 +299,7 @@ Object varObj = ctx.get(varName); if (varObj == null) { //considered as a warning here - errRep.onError(ErrorReporter.UNDEFINED_VARIABLE, + errRep.onError(ErrorConstants.UNDEFINED_VARIABLE, varName + " = null", parentState); } params.put(varName, varObj); Added: jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/semantics/ErrorConstants.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/semantics/ErrorConstants.java?view=auto&rev=452118 ============================================================================== --- jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/semantics/ErrorConstants.java (added) +++ jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/semantics/ErrorConstants.java Mon Oct 2 09:53:06 2006 @@ -0,0 +1,79 @@ +/* + * + * Copyright 2006 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.commons.scxml.semantics; + +/** + * Errors reported by the default SCXMLSemantics implementation. + * + */ +public class ErrorConstants { + + /** + * Missing initial state for a composite state or for the scxml root. + * + * @see org.apache.commons.scxml.model.SCXML#getInitialState() + * @see org.apache.commons.scxml.model.State#getInitial() + */ + public static String NO_INITIAL = "NO_INITIAL"; + + /** + * An initial state for a composite state whose Transition does not. + * Map to a descendant of the composite state. + * + */ + public static String ILLEGAL_INITIAL = "ILLEGAL_INITIAL"; + + /** + * Unknown action - unsupported executable content. List of supported. + * actions: assign, cancel, elseif, else, if, log, send, var + */ + public static String UNKNOWN_ACTION = "UNKNOWN_ACTION"; + + /** + * Illegal state machine configuration. + * Either a parallel exists which does not have all its AND sub-states + * active or there are multiple enabled OR states on the same level. + */ + public static String ILLEGAL_CONFIG = "ILLEGAL_CONFIG"; + + /** + * Non-deterministic situation has occured - there are more than + * one enabled transitions in conflict. + */ + public static String NON_DETERMINISTIC = "NON_DETERMINISTIC"; + + /** + * A variable referred to by assign name attribute is undefined. + */ + public static String UNDEFINED_VARIABLE = "UNDEFINED_VARIABLE"; + + /** + * An expression language error. + */ + public static String EXPRESSION_ERROR = "EXPRESSION_ERROR"; + + //---------------------------------------------- STATIC CONSTANTS ONLY + + /** + * Discourage instantiation. + */ + private ErrorConstants() { + super(); // humor checkstyle + } + +} Propchange: jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/semantics/ErrorConstants.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/semantics/ErrorConstants.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Modified: jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java?view=diff&rev=452118&r1=452117&r2=452118 ============================================================================== --- jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java (original) +++ jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java Mon Oct 2 09:53:06 2006 @@ -114,7 +114,7 @@ throws ModelException { State tmp = input.getInitialState(); if (tmp == null) { - errRep.onError(ErrorReporter.NO_INITIAL, + errRep.onError(ErrorConstants.NO_INITIAL, "SCXML initialstate is missing!", input); } else { states.add(tmp); @@ -168,7 +168,7 @@ errRep, scInstance, appLog, internalEvents); } } catch (SCXMLExpressionException e) { - errRep.onError(ErrorReporter.EXPRESSION_ERROR, e.getMessage(), + errRep.onError(ErrorConstants.EXPRESSION_ERROR, e.getMessage(), oe); } // check if invoke is active in this state @@ -200,7 +200,7 @@ errRep, scInstance, appLog, internalEvents); } } catch (SCXMLExpressionException e) { - errRep.onError(ErrorReporter.EXPRESSION_ERROR, + errRep.onError(ErrorConstants.EXPRESSION_ERROR, e.getMessage(), t); } nr.fireOnTransition(t, t.getParent(), t.getRuntimeTarget(), t); @@ -218,7 +218,7 @@ errRep, scInstance, appLog, internalEvents); } } catch (SCXMLExpressionException e) { - errRep.onError(ErrorReporter.EXPRESSION_ERROR, e.getMessage(), + errRep.onError(ErrorConstants.EXPRESSION_ERROR, e.getMessage(), oe); } nr.fireOnEntry(tt, tt); @@ -359,7 +359,7 @@ step.getAfterStatus().getEvents()); } } catch (SCXMLExpressionException e) { - errRep.onError(ErrorReporter.EXPRESSION_ERROR, + errRep.onError(ErrorConstants.EXPRESSION_ERROR, e.getMessage(), fn); } } @@ -389,7 +389,7 @@ getContext(t.getParent()), t.getCond()); } catch (SCXMLExpressionException e) { rslt = Boolean.FALSE; - errRep.onError(ErrorReporter.EXPRESSION_ERROR, e + errRep.onError(ErrorConstants.EXPRESSION_ERROR, e .getMessage(), t); } } @@ -439,7 +439,7 @@ // check if all non-deterministic situations have been resolved nonDeterm.removeAll(removeList); if (nonDeterm.size() > 0) { - errRep.onError(ErrorReporter.NON_DETERMINISTIC, + errRep.onError(ErrorConstants.NON_DETERMINISTIC, "Multiple conflicting transitions enabled.", nonDeterm); } // apply global transition filter @@ -529,14 +529,14 @@ // composite state Initial ini = st.getInitial(); if (ini == null) { - errRep.onError(ErrorReporter.NO_INITIAL, + errRep.onError(ErrorConstants.NO_INITIAL, "Initial pseudostate is missing!", st); } else { // If we are here, transition target must be a State // or History Transition initialTransition = ini.getTransition(); if (initialTransition == null) { - errRep.onError(ErrorReporter.ILLEGAL_INITIAL, + errRep.onError(ErrorConstants.ILLEGAL_INITIAL, "Initial transition is null!", st); } else { TransitionTarget init = initialTransition. @@ -545,7 +545,7 @@ || !(init instanceof State || init instanceof History)) { - errRep.onError(ErrorReporter.ILLEGAL_INITIAL, + errRep.onError(ErrorConstants.ILLEGAL_INITIAL, "Initial not pointing to a State or History!", st); } else { @@ -764,7 +764,7 @@ srcObj = eval.eval(ctx, srcexpr); src = String.valueOf(srcObj); } catch (SCXMLExpressionException see) { - errRep.onError(ErrorReporter.EXPRESSION_ERROR, + errRep.onError(ErrorConstants.EXPRESSION_ERROR, see.getMessage(), i); } } @@ -797,7 +797,7 @@ try { argValue = eval.eval(ctx, argExpr); } catch (SCXMLExpressionException see) { - errRep.onError(ErrorReporter.EXPRESSION_ERROR, + errRep.onError(ErrorConstants.EXPRESSION_ERROR, see.getMessage(), i); } } Modified: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLHelperTest.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLHelperTest.java?view=diff&rev=452118&r1=452117&r2=452118 ============================================================================== --- jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLHelperTest.java (original) +++ jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLHelperTest.java Mon Oct 2 09:53:06 2006 @@ -18,15 +18,16 @@ import java.util.HashSet; import java.util.Set; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + import org.apache.commons.scxml.env.MockErrorReporter; import org.apache.commons.scxml.env.SimpleErrorReporter; import org.apache.commons.scxml.model.Parallel; import org.apache.commons.scxml.model.State; import org.apache.commons.scxml.model.TransitionTarget; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; +import org.apache.commons.scxml.semantics.ErrorConstants; public class SCXMLHelperTest extends TestCase { @@ -155,7 +156,7 @@ MockErrorReporter errorReporter = new MockErrorReporter(); assertFalse(SCXMLHelper.isLegalConfig(states, errorReporter)); - assertEquals(ErrorReporter.ILLEGAL_CONFIG, errorReporter.getErrCode()); + assertEquals(ErrorConstants.ILLEGAL_CONFIG, errorReporter.getErrCode()); assertEquals("Not all AND states active for parallel 4", errorReporter.getErrDetail()); } @@ -173,7 +174,7 @@ MockErrorReporter errorReporter = new MockErrorReporter(); assertTrue(SCXMLHelper.isLegalConfig(states, errorReporter)); - assertEquals(ErrorReporter.ILLEGAL_CONFIG, errorReporter.getErrCode()); + assertEquals(ErrorConstants.ILLEGAL_CONFIG, errorReporter.getErrCode()); assertEquals("Multiple top-level OR states active!", errorReporter.getErrDetail()); } @@ -198,7 +199,7 @@ MockErrorReporter errorReporter = new MockErrorReporter(); assertFalse(SCXMLHelper.isLegalConfig(states, errorReporter)); - assertEquals(ErrorReporter.ILLEGAL_CONFIG, errorReporter.getErrCode()); + assertEquals(ErrorConstants.ILLEGAL_CONFIG, errorReporter.getErrCode()); assertEquals("Multiple OR states active for state parentid", errorReporter.getErrDetail()); } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]