Author: rahul
Date: Wed Jan 9 13:06:02 2008
New Revision: 610563
URL: http://svn.apache.org/viewvc?rev=610563&view=rev
Log:
Type safety improvements, remove unnecessary casts.
Modified:
commons/proper/scxml/branches/J5/src/main/java/org/apache/commons/scxml/io/SCXMLDigester.java
commons/proper/scxml/branches/J5/src/main/java/org/apache/commons/scxml/io/SCXMLParser.java
Modified:
commons/proper/scxml/branches/J5/src/main/java/org/apache/commons/scxml/io/SCXMLDigester.java
URL:
http://svn.apache.org/viewvc/commons/proper/scxml/branches/J5/src/main/java/org/apache/commons/scxml/io/SCXMLDigester.java?rev=610563&r1=610562&r2=610563&view=diff
==============================================================================
---
commons/proper/scxml/branches/J5/src/main/java/org/apache/commons/scxml/io/SCXMLDigester.java
(original)
+++
commons/proper/scxml/branches/J5/src/main/java/org/apache/commons/scxml/io/SCXMLDigester.java
Wed Jan 9 13:06:02 2008
@@ -224,7 +224,7 @@
* @see PathResolver
*/
public static SCXML digest(final URL scxmlURL,
- final ErrorHandler errHandler, final List customActions)
+ final ErrorHandler errHandler, final List<CustomAction>
customActions)
throws IOException, SAXException, ModelException {
SCXML scxml = null;
@@ -281,7 +281,7 @@
*/
public static SCXML digest(final String documentRealPath,
final ErrorHandler errHandler, final PathResolver pathResolver,
- final List customActions)
+ final List<CustomAction> customActions)
throws IOException, SAXException, ModelException {
if (documentRealPath == null) {
@@ -344,7 +344,7 @@
* @see ErrorHandler
*/
public static SCXML digest(final InputSource documentInputSource,
- final ErrorHandler errHandler, final List customActions)
+ final ErrorHandler errHandler, final List<CustomAction>
customActions)
throws IOException, SAXException, ModelException {
Digester scxmlDigester = SCXMLDigester.newInstance(null, null,
@@ -460,7 +460,7 @@
* @see SCXMLDigester#updateSCXML(SCXML)
*/
public static Digester newInstance(final SCXML scxml,
- final PathResolver pr, final List customActions) {
+ final PathResolver pr, final List<CustomAction> customActions) {
Digester digester = new Digester();
digester.setNamespaceAware(true);
@@ -666,7 +666,7 @@
* @return scxmlRules The rule set to be used for digestion
*/
private static ExtendedBaseRules initRules(final SCXML scxml,
- final PathResolver pr, final List customActions) {
+ final PathResolver pr, final List<CustomAction> customActions) {
ExtendedBaseRules scxmlRules = new ExtendedBaseRules();
scxmlRules.setNamespaceURI(NAMESPACE_SCXML);
@@ -724,7 +724,7 @@
* state on the Digester stack
*/
private static void addStateRules(final String xp,
- final ExtendedBaseRules scxmlRules, final List customActions,
+ final ExtendedBaseRules scxmlRules, final List<CustomAction>
customActions,
final SCXML scxml, final PathResolver pr, final int parent) {
scxmlRules.add(xp, new ObjectCreateRule(State.class));
addStatePropertiesRules(xp, scxmlRules, customActions, pr, scxml);
@@ -752,7 +752,7 @@
*/
private static void addParallelRules(final String xp,
final ExtendedBaseRules scxmlRules, final PathResolver pr,
- final List customActions, final SCXML scxml) {
+ final List<CustomAction> customActions, final SCXML scxml) {
addSimpleRulesTuple(xp, scxmlRules, Parallel.class, null, null,
"setParallel");
addHandlerRules(xp, scxmlRules, pr, customActions);
@@ -772,7 +772,7 @@
* @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 ExtendedBaseRules scxmlRules, final List<CustomAction>
customActions,
final PathResolver pr, final SCXML scxml) {
scxmlRules.add(xp, new SetPropertiesRule(new String[] {"id", "final"},
new String[] {"id", "isFinal"}));
@@ -819,7 +819,7 @@
* @param scxml The parent SCXML document (or null)
*/
private static void addInvokeRules(final String xp,
- final ExtendedBaseRules scxmlRules, final List customActions,
+ final ExtendedBaseRules scxmlRules, final List<CustomAction>
customActions,
final PathResolver pr, final SCXML scxml) {
scxmlRules.add(xp, new ObjectCreateRule(Invoke.class));
scxmlRules.add(xp, new SetPropertiesRule());
@@ -848,7 +848,7 @@
* @param scxml The parent SCXML document (or null)
*/
private static void addInitialRules(final String xp,
- final ExtendedBaseRules scxmlRules, final List customActions,
+ final ExtendedBaseRules scxmlRules, final List<CustomAction>
customActions,
final PathResolver pr, final SCXML scxml) {
scxmlRules.add(xp, new ObjectCreateRule(Initial.class));
addPseudoStatePropertiesRules(xp, scxmlRules, customActions, pr,
@@ -871,7 +871,7 @@
* @param scxml The parent SCXML document (or null)
*/
private static void addHistoryRules(final String xp,
- final ExtendedBaseRules scxmlRules, final List customActions,
+ final ExtendedBaseRules scxmlRules, final List<CustomAction>
customActions,
final PathResolver pr, final SCXML scxml) {
scxmlRules.add(xp, new ObjectCreateRule(History.class));
addPseudoStatePropertiesRules(xp, scxmlRules, customActions, pr,
@@ -897,7 +897,7 @@
* @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 ExtendedBaseRules scxmlRules, final List<CustomAction>
customActions,
final PathResolver pr, final SCXML scxml) {
scxmlRules.add(xp, new SetPropertiesRule(new String[] {"id"},
new String[] {"id"}));
@@ -947,7 +947,7 @@
*/
private static void addTransitionRules(final String xp,
final ExtendedBaseRules scxmlRules, final String setNextMethod,
- final PathResolver pr, final List customActions) {
+ final PathResolver pr, final List<CustomAction> customActions) {
scxmlRules.add(xp, new ObjectCreateRule(Transition.class));
scxmlRules.add(xp, new SetPropertiesRule(
new String[] {"event", "cond", "target"},
@@ -979,7 +979,7 @@
*/
private static void addHandlerRules(final String xp,
final ExtendedBaseRules scxmlRules, final PathResolver pr,
- final List customActions) {
+ final List<CustomAction> 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"));
@@ -1000,7 +1000,7 @@
*/
private static void addActionRules(final String xp,
final ExtendedBaseRules scxmlRules, final PathResolver pr,
- final List customActions) {
+ final List<CustomAction> customActions) {
addActionRulesTuple(xp + XPF_ASN, scxmlRules, Assign.class);
scxmlRules.add(xp + XPF_ASN, new SetPathResolverRule(pr));
addActionRulesTuple(xp + XPF_VAR, scxmlRules, Var.class);
@@ -1021,18 +1021,17 @@
* to be able to process
*/
private static void addCustomActionRules(final String xp,
- final ExtendedBaseRules scxmlRules, final List customActions) {
+ final ExtendedBaseRules scxmlRules, final List<CustomAction>
customActions) {
if (customActions == null || customActions.size() == 0) {
return;
}
for (int i = 0; i < customActions.size(); i++) {
- Object item = customActions.get(i);
- if (item == null || !(item instanceof CustomAction)) {
+ CustomAction ca = customActions.get(i);
+ if (ca == null) {
org.apache.commons.logging.Log log = LogFactory.
getLog(SCXMLDigester.class);
log.warn(ERR_CUSTOM_ACTION_TYPE);
} else {
- CustomAction ca = (CustomAction) item;
scxmlRules.setNamespaceURI(ca.getNamespaceURI());
String xpfLocalName = STR_SLASH + ca.getLocalName();
Class klass = ca.getActionClass();
@@ -1106,7 +1105,7 @@
*/
private static void addIfRules(final String xp,
final ExtendedBaseRules scxmlRules, final PathResolver pr,
- final List customActions) {
+ final List<CustomAction> customActions) {
addActionRulesTuple(xp, scxmlRules, If.class);
addActionRules(xp, scxmlRules, pr, customActions);
addActionRulesTuple(xp + XPF_EIF, scxmlRules, ElseIf.class);
@@ -1372,7 +1371,7 @@
* processing (and hence, the child should be, by transitivity).
* @see CustomAction
*/
- private List customActions;
+ private List<CustomAction> customActions;
/**
* Constructor.
@@ -1385,7 +1384,7 @@
*
* TODO: Remove in v1.0
*/
- public DigestSrcAttributeRule(final List customActions,
+ public DigestSrcAttributeRule(final List<CustomAction> customActions,
final PathResolver pr) {
super();
this.customActions = customActions;
@@ -1403,7 +1402,7 @@
* @see CustomAction
*/
public DigestSrcAttributeRule(final SCXML root,
- final List customActions, final PathResolver pr) {
+ final List<CustomAction> customActions, final PathResolver pr)
{
super();
this.root = root;
this.customActions = customActions;
Modified:
commons/proper/scxml/branches/J5/src/main/java/org/apache/commons/scxml/io/SCXMLParser.java
URL:
http://svn.apache.org/viewvc/commons/proper/scxml/branches/J5/src/main/java/org/apache/commons/scxml/io/SCXMLParser.java?rev=610563&r1=610562&r2=610563&view=diff
==============================================================================
---
commons/proper/scxml/branches/J5/src/main/java/org/apache/commons/scxml/io/SCXMLParser.java
(original)
+++
commons/proper/scxml/branches/J5/src/main/java/org/apache/commons/scxml/io/SCXMLParser.java
Wed Jan 9 13:06:02 2008
@@ -244,7 +244,7 @@
* @see PathResolver
*/
public static SCXML parse(final URL scxmlURL,
- final ErrorHandler errHandler, final List customActions)
+ final ErrorHandler errHandler, final List<CustomAction>
customActions)
throws IOException, SAXException, ModelException {
SCXML scxml = null;
@@ -301,7 +301,7 @@
*/
public static SCXML parse(final String documentRealPath,
final ErrorHandler errHandler, final PathResolver pathResolver,
- final List customActions)
+ final List<CustomAction> customActions)
throws IOException, SAXException, ModelException {
if (documentRealPath == null) {
@@ -364,7 +364,7 @@
* @see ErrorHandler
*/
public static SCXML parse(final InputSource documentInputSource,
- final ErrorHandler errHandler, final List customActions)
+ final ErrorHandler errHandler, final List<CustomAction>
customActions)
throws IOException, SAXException, ModelException {
Digester scxmlParser = SCXMLParser.newInstance(null, null,
@@ -480,7 +480,7 @@
* @see SCXMLParser#updateSCXML(SCXML)
*/
public static Digester newInstance(final SCXML scxml,
- final PathResolver pr, final List customActions) {
+ final PathResolver pr, final List<CustomAction> customActions) {
Digester digester = new Digester();
digester.setNamespaceAware(true);
@@ -691,7 +691,7 @@
* @return scxmlRules The rule set to be used for digestion
*/
private static ExtendedBaseRules initRules(final SCXML scxml,
- final PathResolver pr, final List customActions) {
+ final PathResolver pr, final List<CustomAction> customActions) {
ExtendedBaseRules scxmlRules = new ExtendedBaseRules();
scxmlRules.setNamespaceURI(NAMESPACE_SCXML);
@@ -753,7 +753,7 @@
* @param pr The PathResolver
*/
private static void addStateRules(final String xp,
- final ExtendedBaseRules scxmlRules, final List customActions,
+ final ExtendedBaseRules scxmlRules, final List<CustomAction>
customActions,
final SCXML scxml, final PathResolver pr) {
scxmlRules.add(xp, new ObjectCreateRule(State.class));
addStatePropertiesRules(xp, scxmlRules, customActions, pr, scxml);
@@ -780,7 +780,7 @@
* @param scxml The parent SCXML document (or null)
*/
private static void addParallelRules(final String xp,
- final ExtendedBaseRules scxmlRules, final List customActions,
+ final ExtendedBaseRules scxmlRules, final List<CustomAction>
customActions,
final SCXML scxml, final PathResolver pr) {
addSimpleRulesTuple(xp, scxmlRules, Parallel.class, null, null,
"addChild");
@@ -801,7 +801,7 @@
* @param pr The [EMAIL PROTECTED] PathResolver} for this document
*/
private static void addFinalRules(final String xp,
- final ExtendedBaseRules scxmlRules, final List customActions,
+ final ExtendedBaseRules scxmlRules, final List<CustomAction>
customActions,
final SCXML scxml, final PathResolver pr) {
addSimpleRulesTuple(xp, scxmlRules, Final.class, null, null,
"addChild");
@@ -821,7 +821,7 @@
* @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 ExtendedBaseRules scxmlRules, final List<CustomAction>
customActions,
final PathResolver pr, final SCXML scxml) {
scxmlRules.add(xp, new SetPropertiesRule());
scxmlRules.add(xp, new DigestSrcAttributeRule(scxml,
@@ -867,7 +867,7 @@
* @param scxml The parent SCXML document (or null)
*/
private static void addInvokeRules(final String xp,
- final ExtendedBaseRules scxmlRules, final List customActions,
+ final ExtendedBaseRules scxmlRules, final List<CustomAction>
customActions,
final PathResolver pr, final SCXML scxml) {
scxmlRules.add(xp, new ObjectCreateRule(Invoke.class));
scxmlRules.add(xp, new SetPropertiesRule());
@@ -896,7 +896,7 @@
* @param scxml The parent SCXML document (or null)
*/
private static void addInitialRules(final String xp,
- final ExtendedBaseRules scxmlRules, final List customActions,
+ final ExtendedBaseRules scxmlRules, final List<CustomAction>
customActions,
final PathResolver pr, final SCXML scxml) {
scxmlRules.add(xp, new ObjectCreateRule(Initial.class));
addPseudoStatePropertiesRules(xp, scxmlRules, customActions, pr,
@@ -919,7 +919,7 @@
* @param scxml The parent SCXML document (or null)
*/
private static void addHistoryRules(final String xp,
- final ExtendedBaseRules scxmlRules, final List customActions,
+ final ExtendedBaseRules scxmlRules, final List<CustomAction>
customActions,
final PathResolver pr, final SCXML scxml) {
scxmlRules.add(xp, new ObjectCreateRule(History.class));
addPseudoStatePropertiesRules(xp, scxmlRules, customActions, pr,
@@ -945,7 +945,7 @@
* @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 ExtendedBaseRules scxmlRules, final List<CustomAction>
customActions,
final PathResolver pr, final SCXML scxml) {
scxmlRules.add(xp, new SetPropertiesRule(new String[] {"id"},
new String[] {"id"}));
@@ -967,7 +967,7 @@
*/
private static void addTransitionRules(final String xp,
final ExtendedBaseRules scxmlRules, final String setNextMethod,
- final PathResolver pr, final List customActions) {
+ final PathResolver pr, final List<CustomAction> customActions) {
scxmlRules.add(xp, new ObjectCreateRule(Transition.class));
scxmlRules.add(xp, new SetPropertiesRule(
new String[] {"event", "cond", "target"},
@@ -1003,7 +1003,7 @@
*/
private static void addHandlerRules(final String xp,
final ExtendedBaseRules scxmlRules, final PathResolver pr,
- final List customActions) {
+ final List<CustomAction> 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"));
@@ -1024,7 +1024,7 @@
*/
private static void addActionRules(final String xp,
final ExtendedBaseRules scxmlRules, final PathResolver pr,
- final List customActions) {
+ final List<CustomAction> customActions) {
// Actions in SCXML namespace
addActionRulesTuple(xp + XPF_ASN, scxmlRules, Assign.class);
scxmlRules.add(xp + XPF_ASN, new SetPathResolverRule(pr));
@@ -1053,18 +1053,17 @@
* to be able to process
*/
private static void addCustomActionRules(final String xp,
- final ExtendedBaseRules scxmlRules, final List customActions) {
+ final ExtendedBaseRules scxmlRules, final List<CustomAction>
customActions) {
if (customActions == null || customActions.size() == 0) {
return;
}
for (int i = 0; i < customActions.size(); i++) {
- Object item = customActions.get(i);
- if (item == null || !(item instanceof CustomAction)) {
+ CustomAction ca = customActions.get(i);
+ if (ca == null) {
org.apache.commons.logging.Log log = LogFactory.
getLog(SCXMLParser.class);
log.warn(ERR_CUSTOM_ACTION_TYPE);
} else {
- CustomAction ca = (CustomAction) item;
scxmlRules.setNamespaceURI(ca.getNamespaceURI());
String xpfLocalName = STR_SLASH + ca.getLocalName();
Class klass = ca.getActionClass();
@@ -1138,7 +1137,7 @@
*/
private static void addIfRules(final String xp,
final ExtendedBaseRules scxmlRules, final PathResolver pr,
- final List customActions) {
+ final List<CustomAction> customActions) {
addActionRulesTuple(xp, scxmlRules, If.class);
addActionRules(xp, scxmlRules, pr, customActions);
addActionRulesTuple(xp + XPF_EIF, scxmlRules, ElseIf.class);
@@ -1394,7 +1393,7 @@
* processing (and hence, the child should be, by transitivity).
* @see CustomAction
*/
- private List customActions;
+ private List<CustomAction> customActions;
/**
* Constructor.
@@ -1405,7 +1404,7 @@
* @see PathResolver
* @see CustomAction
*/
- DigestSrcAttributeRule(final List customActions,
+ DigestSrcAttributeRule(final List<CustomAction> customActions,
final PathResolver pr) {
super();
this.customActions = customActions;
@@ -1423,7 +1422,7 @@
* @see CustomAction
*/
DigestSrcAttributeRule(final SCXML root,
- final List customActions, final PathResolver pr) {
+ final List<CustomAction> customActions, final PathResolver pr)
{
super();
this.root = root;
this.customActions = customActions;