Author: tfischer
Date: Sat Mar 6 09:46:27 2010
New Revision: 919726
URL: http://svn.apache.org/viewvc?rev=919726&view=rev
Log:
- added method intOption()
- altered setVariable method such that the scope can be set as string
Modified:
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/template/velocity/TorqueGfVelocity.java
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/template/velocity/TorqueGfVelocity.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/template/velocity/TorqueGfVelocity.java?rev=919726&r1=919725&r2=919726&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/template/velocity/TorqueGfVelocity.java
(original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/template/velocity/TorqueGfVelocity.java
Sat Mar 6 09:46:27 2010
@@ -23,6 +23,7 @@
import java.util.Date;
import java.util.List;
+import org.apache.commons.lang.StringUtils;
import org.apache.torque.gf.control.ControllerState;
import org.apache.torque.gf.generator.GeneratorException;
import org.apache.torque.gf.source.SourceElement;
@@ -205,6 +206,35 @@
}
/**
+ * Returns the option with the given key as int value.
+ * The key can either be a name prefixed with a namespace,
+ * or a name without namespace, in which case the namespace of the
+ * generator is used.
+ *
+ * In the case that the option is not set in this namespace, the parent
+ * namespaces are searched recursively. If the option is not set in any
+ * of the parent namespaces or empty, 0 is returned.
+ *
+ * @param key the key for the option to retrieve.
+ * @return the option for the given key, converted to a boolean
+ */
+ public int intOption(String key)
+ {
+ Object optionValue = controllerState.getOption(key);
+ if (optionValue == null)
+ {
+ return 0;
+ }
+ String optionString = optionValue.toString();
+ if (StringUtils.isBlank(optionString))
+ {
+ return 0;
+ }
+
+ return Integer.parseInt(optionString);
+ }
+
+ /**
* Returns the variable with the given key. The key can either be a name
* prefixed with a namespace, or a name without namespace, in which case
* the namespace of the generator is used.
@@ -250,9 +280,10 @@
* @throws NullPointerException if key or scope is null.
* @throws IllegalArgumentException if the key is no valid QualifiedName.
*/
- public void setVariable(String key, Object value, Variable.Scope scope)
+ public void setVariable(String key, Object value, String scope)
{
- generator.setVariable(key, value, scope, controllerState);
+ Variable.Scope scopeValue = Variable.Scope.valueOf(scope);
+ generator.setVariable(key, value, scopeValue, controllerState);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org
|