Browse Source

javadoc + linelength

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277453 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 21 years ago
parent
commit
e242d1094c
3 changed files with 40 additions and 15 deletions
  1. +13
    -1
      src/main/org/apache/tools/ant/dispatch/DispatchTask.java
  2. +20
    -11
      src/main/org/apache/tools/ant/dispatch/DispatchUtils.java
  3. +7
    -3
      src/main/org/apache/tools/ant/dispatch/Dispatchable.java

+ 13
- 1
src/main/org/apache/tools/ant/dispatch/DispatchTask.java View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2004 The Apache Software Foundation
* Copyright 2004-2005 The Apache Software Foundation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -32,14 +32,26 @@ import org.apache.tools.ant.Task;
public abstract class DispatchTask extends Task implements Dispatchable { public abstract class DispatchTask extends Task implements Dispatchable {
private String action; private String action;


/**
* Get the action parameter name.
* @return the <code>String</code> "action" by default (can be overridden).
*/
public String getActionParameterName() { public String getActionParameterName() {
return "action"; return "action";
} }


/**
* Set the action.
* @param action the method name.
*/
public void setAction(String action) { public void setAction(String action) {
this.action = action; this.action = action;
} }


/**
* Get the action.
* @return the action.
*/
public String getAction() { public String getAction() {
return action; return action;
} }


+ 20
- 11
src/main/org/apache/tools/ant/dispatch/DispatchUtils.java View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2004 The Apache Software Foundation
* Copyright 2004-2005 The Apache Software Foundation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -24,11 +24,13 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;


/** /**
* Determines and Executes the action method for the task
* Determines and Executes the action method for the task.
*/ */
public class DispatchUtils { public class DispatchUtils {
/** /**
* Determines and Executes the action method for the task
* Determines and Executes the action method for the task.
* @param task the task to execute.
* @throws BuildException on error.
*/ */
public static final void execute(Object task) throws BuildException { public static final void execute(Object task) throws BuildException {
String methodName = "execute"; String methodName = "execute";
@@ -39,7 +41,9 @@ public class DispatchUtils {
} else if (task instanceof UnknownElement) { } else if (task instanceof UnknownElement) {
UnknownElement ue = (UnknownElement) task; UnknownElement ue = (UnknownElement) task;
Object realThing = ue.getRealThing(); Object realThing = ue.getRealThing();
if (realThing != null && realThing instanceof Dispatchable && realThing instanceof Task) {
if (realThing != null
&& realThing instanceof Dispatchable
&& realThing instanceof Task) {
dispatchable = (Dispatchable) realThing; dispatchable = (Dispatchable) realThing;
} }
} }
@@ -61,9 +65,11 @@ public class DispatchUtils {
if (s != null && s.trim().length() > 0) { if (s != null && s.trim().length() > 0) {
methodName = s.trim(); methodName = s.trim();
Method executeM = null; Method executeM = null;
executeM = dispatchable.getClass().getMethod(methodName, new Class[0]);
executeM = dispatchable.getClass().getMethod(
methodName, new Class[0]);
if (executeM == null) { if (executeM == null) {
throw new BuildException("No public " + methodName + "() in "
throw new BuildException(
"No public " + methodName + "() in "
+ dispatchable.getClass()); + dispatchable.getClass());
} }
executeM.invoke(dispatchable, (Object[]) null); executeM.invoke(dispatchable, (Object[]) null);
@@ -71,16 +77,19 @@ public class DispatchUtils {
((UnknownElement) task).setRealThing(null); ((UnknownElement) task).setRealThing(null);
} }
} else { } else {
throw new BuildException("Dispatchable Task attribute '" + name.trim()
+ "' not set or value is empty.");
throw new BuildException(
"Dispatchable Task attribute '" + name.trim()
+ "' not set or value is empty.");
} }
} else { } else {
throw new BuildException("Dispatchable Task attribute '" + name.trim()
+ "' not set or value is empty.");
throw new BuildException(
"Dispatchable Task attribute '" + name.trim()
+ "' not set or value is empty.");
} }
} }
} else { } else {
throw new BuildException("Action Parameter Name must not be empty for Dispatchable Task.");
throw new BuildException(
"Action Parameter Name must not be empty for Dispatchable Task.");
} }
} catch (NoSuchMethodException nsme) { } catch (NoSuchMethodException nsme) {
throw new BuildException("No public " + mName + "() in " + task.getClass()); throw new BuildException("No public " + mName + "() in " + task.getClass());


+ 7
- 3
src/main/org/apache/tools/ant/dispatch/Dispatchable.java View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2004 The Apache Software Foundation
* Copyright 2004-2005 The Apache Software Foundation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -22,5 +22,9 @@ package org.apache.tools.ant.dispatch;
* of the task's method to execute. * of the task's method to execute.
*/ */
public interface Dispatchable { public interface Dispatchable {
public String getActionParameterName();
}
/**
* Get the name of the parameter.
* @return the name of the parameter that contains the name of the method.
*/
String getActionParameterName();
}

Loading…
Cancel
Save