/** * Add Digester rules for all <state> element attributes. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param customActions The list of custom actions this digester needs * to be able to process * @param pr The PathResolver * @param scxml The root document, if this one is src'ed in */ private static void addStatePropertiesRules(final String xp, final ExtendedBaseRules scxmlRules, final List customActions, final PathResolver pr, final SCXML scxml) { scxmlRules.add(xp, new SetPropertiesRule(new String[] {"id", "final"}, new String[] {"id", "isFinal"})); scxmlRules.add(xp, new DigestSrcAttributeRule(scxml, customActions, pr)); }
/** * Add Digester rules for all <datamodel> elements. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param pr The PathResolver * @param scxml The parent SCXML document (or null) */ private static void addDatamodelRules(final String xp, final ExtendedBaseRules scxmlRules, final SCXML scxml, final PathResolver pr) { scxmlRules.add(xp, new ObjectCreateRule(Datamodel.class)); scxmlRules.add(xp + XPF_DATA, new ObjectCreateRule(Data.class)); scxmlRules.add(xp + XPF_DATA, new SetPropertiesRule()); scxmlRules.add(xp + XPF_DATA, new SetCurrentNamespacesRule()); scxmlRules.add(xp + XPF_DATA, new SetNextRule("addData")); try { scxmlRules.add(xp + XPF_DATA, new ParseDataRule(pr)); } catch (ParserConfigurationException pce) { org.apache.commons.logging.Log log = LogFactory. getLog(SCXMLParser.class); log.error(ERR_PARSER_CFG_DATA, pce); } scxmlRules.add(xp, new SetNextRule("setDatamodel")); }
/** * Add Digester rules for all <datamodel> elements. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param pr The PathResolver * @param scxml The parent SCXML document (or null) */ private static void addDatamodelRules(final String xp, final ExtendedBaseRules scxmlRules, final SCXML scxml, final PathResolver pr) { scxmlRules.add(xp, new ObjectCreateRule(Datamodel.class)); scxmlRules.add(xp + XPF_DATA, new ObjectCreateRule(Data.class)); scxmlRules.add(xp + XPF_DATA, new SetPropertiesRule()); scxmlRules.add(xp + XPF_DATA, new SetCurrentNamespacesRule()); scxmlRules.add(xp + XPF_DATA, new SetNextRule("addData")); try { scxmlRules.add(xp + XPF_DATA, new ParseDataRule(pr)); } catch (ParserConfigurationException pce) { org.apache.commons.logging.Log log = LogFactory. getLog(SCXMLDigester.class); log.error(ERR_PARSER_CFG_DATA, pce); } scxmlRules.add(xp, new SetNextRule("setDatamodel")); }
/** * Add Digester rules for all pseudo state (initial, history) element * attributes. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param customActions The list of custom actions this digester needs * to be able to process * @param pr The PathResolver * @param scxml The root document, if this one is src'ed in */ private static void addPseudoStatePropertiesRules(final String xp, final ExtendedBaseRules scxmlRules, final List customActions, final PathResolver pr, final SCXML scxml) { scxmlRules.add(xp, new SetPropertiesRule(new String[] {"id"}, new String[] {"id"})); scxmlRules.add(xp, new DigestSrcAttributeRule(scxml, customActions, pr)); }
/** * Add Digester rules for all <state> element attributes. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param customActions The list of custom actions this digester needs * to be able to process * @param pr The PathResolver * @param scxml The root document, if this one is src'ed in */ private static void addStatePropertiesRules(final String xp, final ExtendedBaseRules scxmlRules, final List customActions, final PathResolver pr, final SCXML scxml) { scxmlRules.add(xp, new SetPropertiesRule( new String[] {"id", "final", "initial"}, new String[] {"id", "final", "first"})); scxmlRules.add(xp, new DigestSrcAttributeRule(scxml, customActions, pr)); }
/** * Add the run of the mill Digester rules for any element. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param klass The class in the Java object model to be instantiated * in the ObjectCreateRule for this action * @param args The attributes to be mapped into the object model * @param props The properties that args get mapped to * @param addMethod The method that the SetNextRule should call */ private static void addSimpleRulesTuple(final String xp, final ExtendedBaseRules scxmlRules, final Class klass, final String[] args, final String[] props, final String addMethod) { scxmlRules.add(xp, new ObjectCreateRule(klass)); if (args == null) { scxmlRules.add(xp, new SetPropertiesRule()); } else { scxmlRules.add(xp, new SetPropertiesRule(args, props)); } scxmlRules.add(xp, new SetNextRule(addMethod)); }
/** * Add the run of the mill Digester rules for any element. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param klass The class in the Java object model to be instantiated * in the ObjectCreateRule for this action * @param args The attributes to be mapped into the object model * @param props The properties that args get mapped to * @param addMethod The method that the SetNextRule should call */ private static void addSimpleRulesTuple(final String xp, final ExtendedBaseRules scxmlRules, final Class klass, final String[] args, final String[] props, final String addMethod) { scxmlRules.add(xp, new ObjectCreateRule(klass)); if (args == null) { scxmlRules.add(xp, new SetPropertiesRule()); } else { scxmlRules.add(xp, new SetPropertiesRule(args, props)); } scxmlRules.add(xp, new SetNextRule(addMethod)); }
/** * Add Digester rules that are common across all actions elements. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param klass The class in the Java object model to be instantiated * in the ObjectCreateRule for this action */ private static void addActionRulesTuple(final String xp, final ExtendedBaseRules scxmlRules, final Class klass) { addSimpleRulesTuple(xp, scxmlRules, klass, null, null, "addAction"); scxmlRules.add(xp, new SetExecutableParentRule()); scxmlRules.add(xp, new SetCurrentNamespacesRule()); }
/** * Add Digester rules that are common across all actions elements. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param klass The class in the Java object model to be instantiated * in the ObjectCreateRule for this action */ private static void addActionRulesTuple(final String xp, final ExtendedBaseRules scxmlRules, final Class klass) { addSimpleRulesTuple(xp, scxmlRules, klass, null, null, "addAction"); scxmlRules.add(xp, new SetExecutableParentRule()); scxmlRules.add(xp, new SetCurrentNamespacesRule()); }
/** * Add Digester rules that are specific to the <send> action * element. * * @param xp The Digester style XPath expression of <send> element * @param scxmlRules The rule set to be used for digestion */ private static void addSendRulesTuple(final String xp, final ExtendedBaseRules scxmlRules) { addActionRulesTuple(xp, scxmlRules, Send.class); try { scxmlRules.add(xp, new ParseExternalContentRule()); } catch (ParserConfigurationException pce) { org.apache.commons.logging.Log log = LogFactory. getLog(SCXMLDigester.class); log.error(ERR_PARSER_CFG_SEND, pce); } }
/** * Add Digester rules for a simple custom action (no body content). * * @param xp The path to the custom action element * @param scxmlRules The rule set to be used for digestion * @param klass The <code>Action</code> class implementing the custom * action. * @param bodyContent Whether the custom rule has body content * that should be parsed using * <code>NodeCreateRule</code> */ private static void addCustomActionRulesTuple(final String xp, final ExtendedBaseRules scxmlRules, final Class klass, final boolean bodyContent) { addActionRulesTuple(xp, scxmlRules, klass); if (bodyContent) { try { scxmlRules.add(xp, new ParseExternalContentRule()); } catch (ParserConfigurationException pce) { org.apache.commons.logging.Log log = LogFactory. getLog(SCXMLDigester.class); log.error(ERR_PARSER_CFG_CUSTOM, pce); } } }
/** * Add Digester rules that are specific to the <send> action * element. * * @param xp The Digester style XPath expression of <send> element * @param scxmlRules The rule set to be used for digestion */ private static void addSendRulesTuple(final String xp, final ExtendedBaseRules scxmlRules) { addActionRulesTuple(xp, scxmlRules, Send.class); try { scxmlRules.add(xp, new ParseExternalContentRule()); } catch (ParserConfigurationException pce) { org.apache.commons.logging.Log log = LogFactory. getLog(SCXMLParser.class); log.error(ERR_PARSER_CFG_SEND, pce); } }
/** * Add Digester rules for all pseudo state (initial, history) element * attributes. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param customActions The list of custom actions this digester needs * to be able to process * @param pr The PathResolver * @param scxml The root document, if this one is src'ed in */ private static void addPseudoStatePropertiesRules(final String xp, final ExtendedBaseRules scxmlRules, final List customActions, final PathResolver pr, final SCXML scxml) { scxmlRules.add(xp, new SetPropertiesRule(new String[] {"id"}, new String[] {"id"})); scxmlRules.add(xp, new DigestSrcAttributeRule(scxml, customActions, pr)); addParentRule(xp, scxmlRules, 1); }
/** * Add Digester rules for all <onentry> and <onexit> * elements. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param pr The {@link PathResolver} for this document * @param customActions The list of custom actions this digester needs * to be able to process */ private static void addHandlerRules(final String xp, final ExtendedBaseRules scxmlRules, final PathResolver pr, final List customActions) { scxmlRules.add(xp + XPF_ONEN, new ObjectCreateRule(OnEntry.class)); addActionRules(xp + XPF_ONEN, scxmlRules, pr, customActions); scxmlRules.add(xp + XPF_ONEN, new SetNextRule("setOnEntry")); scxmlRules.add(xp + XPF_ONEX, new ObjectCreateRule(OnExit.class)); addActionRules(xp + XPF_ONEX, scxmlRules, pr, customActions); scxmlRules.add(xp + XPF_ONEX, new SetNextRule("setOnExit")); }
/** * Add Digester rules for all <onentry> and <onexit> * elements. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param pr The {@link PathResolver} for this document * @param customActions The list of custom actions this digester needs * to be able to process */ private static void addHandlerRules(final String xp, final ExtendedBaseRules scxmlRules, final PathResolver pr, final List customActions) { scxmlRules.add(xp + XPF_ONEN, new ObjectCreateRule(OnEntry.class)); addActionRules(xp + XPF_ONEN, scxmlRules, pr, customActions); scxmlRules.add(xp + XPF_ONEN, new SetNextRule("setOnEntry")); scxmlRules.add(xp + XPF_ONEX, new ObjectCreateRule(OnExit.class)); addActionRules(xp + XPF_ONEX, scxmlRules, pr, customActions); scxmlRules.add(xp + XPF_ONEX, new SetNextRule("setOnExit")); }
/** * Add Digester rules for all <history> elements. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param customActions The list of custom actions this digester needs * to be able to process * @param pr The PathResolver * @param scxml The parent SCXML document (or null) */ private static void addHistoryRules(final String xp, final ExtendedBaseRules scxmlRules, final List customActions, final PathResolver pr, final SCXML scxml) { scxmlRules.add(xp, new ObjectCreateRule(History.class)); addPseudoStatePropertiesRules(xp, scxmlRules, customActions, pr, scxml); scxmlRules.add(xp, new UpdateModelRule(scxml)); scxmlRules.add(xp, new SetPropertiesRule(new String[] {"type"}, new String[] {"type"})); addTransitionRules(xp + XPF_TR, scxmlRules, "setTransition", pr, customActions); scxmlRules.add(xp, new SetNextRule("addHistory")); }
/** * Add Digester rules for all <history> elements. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param customActions The list of custom actions this digester needs * to be able to process * @param pr The PathResolver * @param scxml The parent SCXML document (or null) */ private static void addHistoryRules(final String xp, final ExtendedBaseRules scxmlRules, final List customActions, final PathResolver pr, final SCXML scxml) { scxmlRules.add(xp, new ObjectCreateRule(History.class)); addPseudoStatePropertiesRules(xp, scxmlRules, customActions, pr, scxml); scxmlRules.add(xp, new UpdateModelRule(scxml)); scxmlRules.add(xp, new SetPropertiesRule(new String[] {"type"}, new String[] {"type"})); addTransitionRules(xp + XPF_TR, scxmlRules, "setTransition", pr, customActions); scxmlRules.add(xp, new SetNextRule("addHistory")); }
/** * Add Digester rules for all <initial> elements. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param customActions The list of custom actions this digester needs * to be able to process * @param pr The PathResolver * @param scxml The parent SCXML document (or null) */ private static void addInitialRules(final String xp, final ExtendedBaseRules scxmlRules, final List customActions, final PathResolver pr, final SCXML scxml) { scxmlRules.add(xp, new ObjectCreateRule(Initial.class)); addPseudoStatePropertiesRules(xp, scxmlRules, customActions, pr, scxml); scxmlRules.add(xp, new UpdateModelRule(scxml)); addTransitionRules(xp + XPF_TR, scxmlRules, "setTransition", pr, customActions); scxmlRules.add(xp, new SetNextRule("setInitial")); }
/** * Add Digester rules for all <final> elements. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param customActions The list of custom actions this digester needs * to be able to process * @param scxml The parent SCXML document (or null) * @param pr The {@link PathResolver} for this document */ private static void addFinalRules(final String xp, final ExtendedBaseRules scxmlRules, final List customActions, final SCXML scxml, final PathResolver pr) { addSimpleRulesTuple(xp, scxmlRules, Final.class, null, null, "addChild"); addHandlerRules(xp, scxmlRules, pr, customActions); scxmlRules.add(xp, new UpdateModelRule(scxml)); }
/** * Add Digester rules for all <parallel> elements. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param customActions The list of custom actions this digester needs * to be able to process * @param pr The {@link PathResolver} for this document * @param scxml The parent SCXML document (or null) */ private static void addParallelRules(final String xp, final ExtendedBaseRules scxmlRules, final PathResolver pr, final List customActions, final SCXML scxml) { addSimpleRulesTuple(xp, scxmlRules, Parallel.class, null, null, "setParallel"); addHandlerRules(xp, scxmlRules, pr, customActions); addParentRule(xp, scxmlRules, 1); scxmlRules.add(xp, new UpdateModelRule(scxml)); }