From torque-dev-return-9491-apmail-db-torque-dev-archive=db.apache.org@db.apache.org Sat Mar 06 09:47:09 2010 Return-Path: Delivered-To: apmail-db-torque-dev-archive@www.apache.org Received: (qmail 81134 invoked from network); 6 Mar 2010 09:47:09 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 6 Mar 2010 09:47:09 -0000 Received: (qmail 96426 invoked by uid 500); 6 Mar 2010 09:46:52 -0000 Delivered-To: apmail-db-torque-dev-archive@db.apache.org Received: (qmail 96334 invoked by uid 500); 6 Mar 2010 09:46:52 -0000 Mailing-List: contact torque-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Apache Torque Developers List" Reply-To: "Apache Torque Developers List" Delivered-To: mailing list torque-dev@db.apache.org Received: (qmail 96326 invoked by uid 500); 6 Mar 2010 09:46:51 -0000 Received: (qmail 96323 invoked by uid 99); 6 Mar 2010 09:46:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 06 Mar 2010 09:46:51 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 06 Mar 2010 09:46:49 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 10C5C23889B2; Sat, 6 Mar 2010 09:46:28 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r919726 - /db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/template/velocity/TorqueGfVelocity.java Date: Sat, 06 Mar 2010 09:46:28 -0000 To: torque-commits@db.apache.org From: tfischer@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100306094628.10C5C23889B2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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