bdi4jade
Changes
bdi-jade/src/bdi4jade/util/package-info.java 29(+29 -0)
Details
bdi-jade/src/bdi4jade/util/package-info.java 29(+29 -0)
diff --git a/bdi-jade/src/bdi4jade/util/package-info.java b/bdi-jade/src/bdi4jade/util/package-info.java
new file mode 100644
index 0000000..5bfc8d0
--- /dev/null
+++ b/bdi-jade/src/bdi4jade/util/package-info.java
@@ -0,0 +1,29 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2011 Ingrid Nunes
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// To contact the authors:
+// http://inf.ufrgs.br/prosoft/bdi4jade/
+//
+//----------------------------------------------------------------------------
+
+/**
+ * This package contains utility classes.
+ *
+ * @author Ingrid Nunes
+ *
+ */
+package bdi4jade.util;
\ No newline at end of file
diff --git a/bdi-jade/src/bdi4jade/util/ReflectionUtils.java b/bdi-jade/src/bdi4jade/util/ReflectionUtils.java
index bb32dc0..13bf193 100644
--- a/bdi-jade/src/bdi4jade/util/ReflectionUtils.java
+++ b/bdi-jade/src/bdi4jade/util/ReflectionUtils.java
@@ -16,7 +16,7 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// To contact the authors:
-// http://inf.ufrgs.br/~ingridnunes/bdi4jade/
+// http://inf.ufrgs.br/prosoft/bdi4jade/
//
//----------------------------------------------------------------------------
@@ -31,9 +31,12 @@ import bdi4jade.annotation.Parameter;
import bdi4jade.annotation.Parameter.Direction;
import bdi4jade.exception.ParameterException;
import bdi4jade.goal.Goal;
-import bdi4jade.plan.PlanBody;
+import bdi4jade.plan.planbody.PlanBody;
/**
+ * This is a utility class that provides many methods that use reflection for
+ * different purposes.
+ *
* @author Ingrid Nunes
*
*/
@@ -52,7 +55,7 @@ public abstract class ReflectionUtils {
}
}
- protected static boolean isGetter(Method method) {
+ private static boolean isGetter(Method method) {
if (!method.getName().startsWith(GETTER_PREFIX))
return false;
if (method.getParameterTypes().length != 0)
@@ -71,7 +74,7 @@ public abstract class ReflectionUtils {
return false;
}
- protected static boolean isSetter(Method method) {
+ private static boolean isSetter(Method method) {
if (!method.getName().startsWith(SETTER_PREFIX))
return false;
if (method.getParameterTypes().length != 1)
@@ -81,16 +84,27 @@ public abstract class ReflectionUtils {
return true;
}
- protected static String methodToPropertyName(String prefix, Method method) {
+ private static String methodToPropertyName(String prefix, Method method) {
String property = method.getName().substring(prefix.length());
return property.substring(0, 1).toLowerCase() + property.substring(1);
}
- protected static String propertyToMethodName(String prefix, String property) {
+ private static String propertyToMethodName(String prefix, String property) {
return prefix + property.substring(0, 1).toUpperCase()
+ property.substring(1);
}
+ /**
+ * Sets the input parameters of a plan body based on the parameters passed
+ * in the goal that triggered its execution.
+ *
+ * @param planBody
+ * the plan body to have its input parameters set.
+ * @param goal
+ * the goal that has input parameters.
+ * @throws ParameterException
+ * if an exception occurs in this setting process.
+ */
public static void setPlanBodyInput(PlanBody planBody, Goal goal)
throws ParameterException {
setupParameters(planBody, new Direction[] { Direction.IN,
@@ -98,6 +112,17 @@ public abstract class ReflectionUtils {
Direction.INOUT });
}
+ /**
+ * Sets the output parameters of a goal based on the output generated by the
+ * plan body whose execution was triggered by this goal.
+ *
+ * @param planBody
+ * the plan body generated the output parameters.
+ * @param goal
+ * the goal to have its output parameters set.
+ * @throws ParameterException
+ * if an exception occurs in this setting process.
+ */
public static void setPlanBodyOutput(PlanBody planBody, Goal goal)
throws ParameterException {
setupParameters(goal,
@@ -105,6 +130,19 @@ public abstract class ReflectionUtils {
new Direction[] { Direction.OUT, Direction.INOUT });
}
+ /**
+ * Sets the input parameters of goal based on the output parameters of
+ * another goal. This is useful when goals are executed sequentially, and
+ * the input of a goal is the output of another.
+ *
+ * @param goalOut
+ * the goal that has output parameters that are input of the
+ * goalIn.
+ * @param goalIn
+ * the goal to have its input parameters set.
+ * @throws ParameterException
+ * if an exception occurs in this setting process.
+ */
public static void setupParameters(Goal goalOut, Goal goalIn)
throws ParameterException {
setupParameters(goalIn,