You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by ra...@apache.org on 2005/08/10 23:11:40 UTC
svn commit: r231329 [1/13] - in /jakarta/taglibs/proper/rdc/trunk/src:
META-INF/tags/rdc/ org/apache/taglibs/rdc/ org/apache/taglibs/rdc/core/
org/apache/taglibs/rdc/dm/ org/apache/taglibs/rdc/resources/
org/apache/taglibs/rdc/sampleapps/mortgage/ org/...
Author: rahul
Date: Wed Aug 10 14:10:59 2005
New Revision: 231329
URL: http://svn.apache.org/viewcvs?rev=231329&view=rev
Log:
1) Tabs -> spaces
2) Localizing resources used by composites
Modified:
jakarta/taglibs/proper/rdc/trunk/src/META-INF/tags/rdc/creditcardInfo.tag
jakarta/taglibs/proper/rdc/trunk/src/META-INF/tags/rdc/mortgage.tag
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Alpha.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Alphanum.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Color.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Country.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardAmount.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardData.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardExpiry.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardInfo.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardNumber.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardType.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Currency.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Date.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/DateRange.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/DateRangeData.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Digits.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Duration.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/GetConfigElemTag.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/GetDefaultConfigTag.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/GetResourceTag.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/GrammarServlet.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/ISBN.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Mortgage.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/MortgageData.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/MortgageType.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Number.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Pause.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Percent.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/RDCFilter.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/RDCUtils.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/SelectOne.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/SocialSecurityNumber.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Time.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/USMajorCity.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/USState.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/ZipCode.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/BaseModel.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/ComponentModel.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/Constants.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/DialogManager.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/ExpandTag.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/Grammar.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/GroupConfirm.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/GroupModel.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/GroupTag.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/IncludeFSMFragmentTag.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/NBestResults.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/RDCTemplate.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StackPeek.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StackPop.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StackPush.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StrutsErrorsTag.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StrutsSubmitTag.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/dm/Conditions.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/dm/DMUtils.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/dm/DialogManagerImpl.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/dm/RuleBasedDirectedDialog.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/dm/SCXMLDialog.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/dm/SimpleDirectedDialog.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/resources/RDCBundle.properties
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/resources/RDCBundle_en_US.properties
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/MortgageAppBean.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/LoginAction.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/LoginBean.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/MortgageAction.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/MortgageBean.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/ProceedAction.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/ProceedBean.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/AmazonMenuTemplate.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/HTMLMenuLinks.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/MusicStoreAppBean.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/ProactiveHelp.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/ReviewAlbumTemplate.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/AddToCartAction.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/AlbumFilterForm.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/CheckoutAction.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/CheckoutForm.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/IndividualAlbumForm.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/MainMenuAction.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/ReviewAlbumAction.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/ws/Cart.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/ws/CartItem.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/ws/Image.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/ws/Item.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/ws/MusicAlbum.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/ws/MusicStore.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/Context.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/ErrorReporter.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/Evaluator.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/EventDispatcher.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/NotificationRegistry.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/Observable.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/PathResolver.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/SCXMLDigester.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/SCXMLExecutor.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/SCXMLExpressionException.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/SCXMLHelper.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/SCXMLListener.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/SCXMLSemantics.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/Status.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/Step.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/TransitionTargetComparator.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/TriggerEvent.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/env/ELContext.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/env/ELEvaluator.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/env/RootContext.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/env/ServletContextResolver.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/env/SimpleDispatcher.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/env/Standalone.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/env/Tracer.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/env/URLResolver.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/Action.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/Assign.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/Cancel.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/Else.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/ElseIf.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/Executable.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/Exit.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/ExternalNode.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/History.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/If.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/Initial.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/Log.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/ModelException.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/OnEntry.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/OnExit.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/Parallel.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/Path.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/SCXML.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/Send.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/State.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/Transition.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/TransitionTarget.java
jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/Var.java
Modified: jakarta/taglibs/proper/rdc/trunk/src/META-INF/tags/rdc/creditcardInfo.tag
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/META-INF/tags/rdc/creditcardInfo.tag?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/META-INF/tags/rdc/creditcardInfo.tag (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/META-INF/tags/rdc/creditcardInfo.tag Wed Aug 10 14:10:59 2005
@@ -69,23 +69,25 @@
</c:when>
<c:when test="${model.state == constants.FSM_INPUT}">
+ <rdc:get-resource bundle="${model.rdcResourceBundle}" var="defaultConfig"
+ key="rdc.creditcard.info.securitycode.defaultconfig.uri" />
+
<rdc:group id="ccInfoGrp" strategy="org.apache.taglibs.rdc.dm.RuleBasedDirectedDialog"
config="META-INF/tags/rdc/config/cardinfo-rules.xml" submit="${model.submit}">
- <rdc:creditcardType id="ccType" confirm="true" echo="true"
+ <rdc:creditcardType id="ccType" confirm="${model.confirm}" echo="${model.echo}"
locale="${model.locale}" config="${model.configMap.creditcardType}" />
- <rdc:creditcardNumber id="ccNumber" confirm="true" echo="true"
+ <rdc:creditcardNumber id="ccNumber" confirm="${model.confirm}" echo="${model.echo}"
locale="${model.locale}" config="${model.configMap.creditcardNumber}" />
- <rdc:creditcardExpiry id="ccExpiry" confirm="true" echo="true"
+ <rdc:creditcardExpiry id="ccExpiry" confirm="${model.confirm}" echo="${model.echo}"
locale="${model.locale}" config="${model.configMap.creditcardExpiry}" />
<rdc:digits id="ccSecurityCode" minLength="3" maxLength="7"
- locale="${model.locale}" confirm="true" echo="true"
+ locale="${model.locale}" confirm="${model.confirm}" echo="${model.echo}"
config="${not empty model.configMap.creditcardSecurityCode ?
- model.configMap.creditcardSecurityCode :
- 'META-INF/tags/rdc/config/cardsecuritycode.xml' }" />
+ model.configMap.creditcardSecurityCode : defaultConfig }" />
</rdc:group>
</c:when>
Modified: jakarta/taglibs/proper/rdc/trunk/src/META-INF/tags/rdc/mortgage.tag
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/META-INF/tags/rdc/mortgage.tag?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/META-INF/tags/rdc/mortgage.tag (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/META-INF/tags/rdc/mortgage.tag Wed Aug 10 14:10:59 2005
@@ -66,13 +66,18 @@
</c:when>
<c:when test="${model.state == constants.FSM_INPUT}">
- <rdc:group id="mortgage" strategy="org.apache.taglibs.rdc.dm.SimpleDirectedDialog" submit="${model.submit}" >
+ <rdc:group id="mortgage" strategy="org.apache.taglibs.rdc.dm.SimpleDirectedDialog"
+ submit="${model.submit}" >
+
<rdc:mortgageType id="mortgageType" minTerm="10Yfixed" maxTerm="50Yfixed"
- initial="20Yfixed" confirm="true" echo="true" minConfidence="0.4F" numNBest="5"
+ initial="20Yfixed" confirm="${model.confirm}" echo="${model.echo}"
+ minConfidence="0.4F" numNBest="5"
locale="${model.locale}" config="${model.configMap.mortgageType}" />
+
<rdc:percent id="percent" minPercent="5" maxPercent="55" initial="10"
- confirm="true" echo="true" minConfidence="0.4F" numNBest="5"
+ confirm="${model.confirm}" echo="${model.echo}" minConfidence="0.4F" numNBest="5"
locale="${model.locale}" config="${model.configMap.percent}" />
+
</rdc:group>
</c:when>
</c:choose>
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Alpha.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Alpha.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Alpha.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Alpha.java Wed Aug 10 14:10:59 2005
@@ -34,138 +34,138 @@
*/
public class Alpha extends BaseModel {
- // The alpha RDC will be associated with the alphabetical
- // input (spelling), the maximum and minimum length within
- // which the input's length must lie, and a pattern to which
- // the input must conform.
-
- // Maximum allowed length of the input; -1 indicates
- // no constraint on maximum length
- private int minLength;
- // Minimum allowed length of the input; -1 indicates
- // no constraint on minimum length
- private int maxLength;
- // The alpha input must conform to this pattern
- private String pattern;
-
- // Error codes, defined in configuration file
- /**A constant for Error Code stating Invalid apha */
- public static final int ERR_INVALID_ALPHA = 1;
-
- /**A constant for Error Code stating the alpha entered is
- * larger than allowed */
- public static final int ERR_NEED_SHORTER_ALPHA = 2;
-
- /**A constant for Error Code stating the alpha entered is
- * smaller than allowed */
- public static final int ERR_NEED_LONGER_ALPHA = 3;
-
- /**
- * Sets default values for all data members
- */
- public Alpha() {
- super();
- this.minLength = -1;
- this.maxLength = -1;
- // Default pattern allows any combination of alphabets
- this.pattern = "[a-zA-Z ']*";
- }
-
- /**
- * Gets the maximum allowed length of input
- *
- * @return the maximum allowed length of input
- */
- public String getMaxLength() {
- return String.valueOf(maxLength);
- }
-
- /**
- * Sets the maximum allowed length of input
- *
- * @param maxLength the maximum allowed length of input
- */
- public void setMaxLength(String maxLength) {
- if (maxLength != null) {
- try {
- this.maxLength = Integer.parseInt(maxLength);
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException("maxLength attribute " +
- "of \"" + getId() + "\" alpha tag is not a number.");
- }
- }
- }
-
- /**
- * Gets the minimum allowed length of input
- *
- * @return the minimum allowed length of input
- */
- public String getMinLength() {
- return String.valueOf(minLength);
- }
-
- /**
- * Sets the minimum allowed length of input
- *
- * @param minLength the minimum allowed length of input
- */
- public void setMinLength(String minLength) {
- if (minLength != null) {
- try {
- this.minLength = Integer.parseInt(minLength);
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException("minLength attribute " +
- "of \"" + getId() + "\" alpha tag is not a number.");
- }
- }
- }
-
- /**
- * Gets the pattern string
- *
- * @return the pattern string
- */
- public String getPattern() {
- return this.pattern;
- }
-
- /**
- * Sets the pattern string to which the input must conform
- *
- * @param pattern the pattern string to which the input must conform
- */
- public void setPattern(String pattern) {
- if (pattern != null) {
- try {
- Pattern.compile(pattern);
- this.pattern = pattern;
- } catch (PatternSyntaxException e) {
- throw new IllegalArgumentException("pattern attribute " +
- "of \"" + getId() + "\" alpha tag not in proper format.");
- }
- }
- }
-
- /**
- * Validates the input against the given constraints
- *
- * @return TRUE if valid, FALSE otherwise
- */
- protected Boolean validate(Object newValue, boolean setErrorCode) {
-
- if (pattern != null && !(Pattern.matches(pattern, (String)newValue))) {
- if (setErrorCode) setErrorCode(ERR_INVALID_ALPHA);
- return Boolean.FALSE;
- }
- if (maxLength > 0 && ((String) newValue).length() > maxLength) {
- if (setErrorCode) setErrorCode(ERR_NEED_SHORTER_ALPHA);
- return Boolean.FALSE;
- }
- if (minLength > 0 && ((String) newValue).length() < minLength) {
- if (setErrorCode) setErrorCode(ERR_NEED_LONGER_ALPHA);
- return Boolean.FALSE;
- }
- return Boolean.TRUE;
- }
+ // The alpha RDC will be associated with the alphabetical
+ // input (spelling), the maximum and minimum length within
+ // which the input's length must lie, and a pattern to which
+ // the input must conform.
+
+ // Maximum allowed length of the input; -1 indicates
+ // no constraint on maximum length
+ private int minLength;
+ // Minimum allowed length of the input; -1 indicates
+ // no constraint on minimum length
+ private int maxLength;
+ // The alpha input must conform to this pattern
+ private String pattern;
+
+ // Error codes, defined in configuration file
+ /**A constant for Error Code stating Invalid apha */
+ public static final int ERR_INVALID_ALPHA = 1;
+
+ /**A constant for Error Code stating the alpha entered is
+ * larger than allowed */
+ public static final int ERR_NEED_SHORTER_ALPHA = 2;
+
+ /**A constant for Error Code stating the alpha entered is
+ * smaller than allowed */
+ public static final int ERR_NEED_LONGER_ALPHA = 3;
+
+ /**
+ * Sets default values for all data members
+ */
+ public Alpha() {
+ super();
+ this.minLength = -1;
+ this.maxLength = -1;
+ // Default pattern allows any combination of alphabets
+ this.pattern = "[a-zA-Z ']*";
+ }
+
+ /**
+ * Gets the maximum allowed length of input
+ *
+ * @return the maximum allowed length of input
+ */
+ public String getMaxLength() {
+ return String.valueOf(maxLength);
+ }
+
+ /**
+ * Sets the maximum allowed length of input
+ *
+ * @param maxLength the maximum allowed length of input
+ */
+ public void setMaxLength(String maxLength) {
+ if (maxLength != null) {
+ try {
+ this.maxLength = Integer.parseInt(maxLength);
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException("maxLength attribute " +
+ "of \"" + getId() + "\" alpha tag is not a number.");
+ }
+ }
+ }
+
+ /**
+ * Gets the minimum allowed length of input
+ *
+ * @return the minimum allowed length of input
+ */
+ public String getMinLength() {
+ return String.valueOf(minLength);
+ }
+
+ /**
+ * Sets the minimum allowed length of input
+ *
+ * @param minLength the minimum allowed length of input
+ */
+ public void setMinLength(String minLength) {
+ if (minLength != null) {
+ try {
+ this.minLength = Integer.parseInt(minLength);
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException("minLength attribute " +
+ "of \"" + getId() + "\" alpha tag is not a number.");
+ }
+ }
+ }
+
+ /**
+ * Gets the pattern string
+ *
+ * @return the pattern string
+ */
+ public String getPattern() {
+ return this.pattern;
+ }
+
+ /**
+ * Sets the pattern string to which the input must conform
+ *
+ * @param pattern the pattern string to which the input must conform
+ */
+ public void setPattern(String pattern) {
+ if (pattern != null) {
+ try {
+ Pattern.compile(pattern);
+ this.pattern = pattern;
+ } catch (PatternSyntaxException e) {
+ throw new IllegalArgumentException("pattern attribute " +
+ "of \"" + getId() + "\" alpha tag not in proper format.");
+ }
+ }
+ }
+
+ /**
+ * Validates the input against the given constraints
+ *
+ * @return TRUE if valid, FALSE otherwise
+ */
+ protected Boolean validate(Object newValue, boolean setErrorCode) {
+
+ if (pattern != null && !(Pattern.matches(pattern, (String)newValue))) {
+ if (setErrorCode) setErrorCode(ERR_INVALID_ALPHA);
+ return Boolean.FALSE;
+ }
+ if (maxLength > 0 && ((String) newValue).length() > maxLength) {
+ if (setErrorCode) setErrorCode(ERR_NEED_SHORTER_ALPHA);
+ return Boolean.FALSE;
+ }
+ if (minLength > 0 && ((String) newValue).length() < minLength) {
+ if (setErrorCode) setErrorCode(ERR_NEED_LONGER_ALPHA);
+ return Boolean.FALSE;
+ }
+ return Boolean.TRUE;
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Alphanum.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Alphanum.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Alphanum.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Alphanum.java Wed Aug 10 14:10:59 2005
@@ -33,140 +33,140 @@
*/
public class Alphanum extends BaseModel {
- // The alphanum RDC will be associated with the alphanumeric
- // input, the maximum and minimum length within which the
- // input's length must lie, and a pattern to which the input
- // must conform.
-
- // Maximum allowed length of the input; -1 indicates
- // no constraint on maximum length
- private int minLength;
- // Minimum allowed length of the input; -1 indicates
- // no constraint on minimum length
- private int maxLength;
- // The alphanumeric input must conform to this pattern
- private String pattern;
-
- // Error codes, defined in configuration file
- /**A constant for Error Code stating Invalid aphanum */
- public static final int ERR_INVALID_ALPHANUM = 1;
-
- /**A constant for Error Code stating the alphanum entered is
- * larger than allowed */
- public static final int ERR_NEED_SHORTER_ALPHANUM = 2;
-
- /**A constant for Error Code stating the alphanum entered is
- * smaller than allowed */
- public static final int ERR_NEED_LONGER_ALPHANUM = 3;
-
- /**
- * Sets default values for all data members
- */
- public Alphanum() {
- super();
- this.minLength = -1;
- this.maxLength = -1;
- // Default pattern allows any combination of alphabets
- // and digits
- this.pattern = "[0-9a-z]*";
- }
-
- /**
- * Gets the maximum allowed length of alphanum
- *
- * @return the maximum allowed length of alphanum
- */
- public String getMaxLength() {
- return String.valueOf(maxLength);
- }
-
- /**
- * Sets the maximum allowed length of input
- *
- * @param maxLength the maximum allowed length of input
- */
- public void setMaxLength(String maxLength) {
- if (maxLength != null) {
- try {
- this.maxLength = Integer.parseInt(maxLength);
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException("maxLength attribute of \""
- + getId() + "\" alphanum tag is not a number.");
- }
- }
- }
-
- /**
- * Gets the minimum allowed length of alphanum
- *
- * @return the minimum allowed length of alphanum
- */
- public String getMinLength() {
- return String.valueOf(minLength);
- }
-
- /**
- * Sets the minimum allowed length of input
- *
- * @param minLength the minimum allowed length of input
- */
- public void setMinLength(String minLength) {
- if (minLength != null) {
- try {
- this.minLength = Integer.parseInt(minLength);
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException("minLength attribute " +
- "of \"" + getId() + "\" alphanum tag is not a number.");
- }
- }
- }
-
- /**
- * Gets the pattern string
- *
- * @return the pattern string
- */
- public String getPattern() {
- return this.pattern;
- }
-
- /**
- * Sets the pattern string to which the input must conform
- *
- * @param pattern the pattern string to which the input must conform
- */
- public void setPattern(String pattern) {
- if (pattern != null) {
- try {
- Pattern.compile(pattern);
- this.pattern = pattern;
- } catch (PatternSyntaxException e) {
- throw new IllegalArgumentException("pattern attribute of \""
- + getId() + "\" alphanum tag not in proper format.");
- }
- }
- }
-
- /**
- * Validates the input against the given constraints
- *
- * @return TRUE if valid, FALSE otherwise
- */
- protected Boolean validate(Object newValue, boolean setErrorCode) {
-
- if (pattern != null && !(Pattern.matches(pattern.toLowerCase(),
- ((String) newValue).toLowerCase()))) {
- if (setErrorCode) setErrorCode(ERR_INVALID_ALPHANUM);
- return Boolean.FALSE;
- }
- if (maxLength > 0 && ((String) newValue).length() > maxLength) {
- if (setErrorCode) setErrorCode(ERR_NEED_SHORTER_ALPHANUM);
- return Boolean.FALSE;
- }
- if (minLength > 0 && ((String) newValue).length() < minLength) {
- if (setErrorCode) setErrorCode(ERR_NEED_LONGER_ALPHANUM);
- return Boolean.FALSE;
- }
- return Boolean.TRUE;
- }
+ // The alphanum RDC will be associated with the alphanumeric
+ // input, the maximum and minimum length within which the
+ // input's length must lie, and a pattern to which the input
+ // must conform.
+
+ // Maximum allowed length of the input; -1 indicates
+ // no constraint on maximum length
+ private int minLength;
+ // Minimum allowed length of the input; -1 indicates
+ // no constraint on minimum length
+ private int maxLength;
+ // The alphanumeric input must conform to this pattern
+ private String pattern;
+
+ // Error codes, defined in configuration file
+ /**A constant for Error Code stating Invalid aphanum */
+ public static final int ERR_INVALID_ALPHANUM = 1;
+
+ /**A constant for Error Code stating the alphanum entered is
+ * larger than allowed */
+ public static final int ERR_NEED_SHORTER_ALPHANUM = 2;
+
+ /**A constant for Error Code stating the alphanum entered is
+ * smaller than allowed */
+ public static final int ERR_NEED_LONGER_ALPHANUM = 3;
+
+ /**
+ * Sets default values for all data members
+ */
+ public Alphanum() {
+ super();
+ this.minLength = -1;
+ this.maxLength = -1;
+ // Default pattern allows any combination of alphabets
+ // and digits
+ this.pattern = "[0-9a-z]*";
+ }
+
+ /**
+ * Gets the maximum allowed length of alphanum
+ *
+ * @return the maximum allowed length of alphanum
+ */
+ public String getMaxLength() {
+ return String.valueOf(maxLength);
+ }
+
+ /**
+ * Sets the maximum allowed length of input
+ *
+ * @param maxLength the maximum allowed length of input
+ */
+ public void setMaxLength(String maxLength) {
+ if (maxLength != null) {
+ try {
+ this.maxLength = Integer.parseInt(maxLength);
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException("maxLength attribute of \""
+ + getId() + "\" alphanum tag is not a number.");
+ }
+ }
+ }
+
+ /**
+ * Gets the minimum allowed length of alphanum
+ *
+ * @return the minimum allowed length of alphanum
+ */
+ public String getMinLength() {
+ return String.valueOf(minLength);
+ }
+
+ /**
+ * Sets the minimum allowed length of input
+ *
+ * @param minLength the minimum allowed length of input
+ */
+ public void setMinLength(String minLength) {
+ if (minLength != null) {
+ try {
+ this.minLength = Integer.parseInt(minLength);
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException("minLength attribute " +
+ "of \"" + getId() + "\" alphanum tag is not a number.");
+ }
+ }
+ }
+
+ /**
+ * Gets the pattern string
+ *
+ * @return the pattern string
+ */
+ public String getPattern() {
+ return this.pattern;
+ }
+
+ /**
+ * Sets the pattern string to which the input must conform
+ *
+ * @param pattern the pattern string to which the input must conform
+ */
+ public void setPattern(String pattern) {
+ if (pattern != null) {
+ try {
+ Pattern.compile(pattern);
+ this.pattern = pattern;
+ } catch (PatternSyntaxException e) {
+ throw new IllegalArgumentException("pattern attribute of \""
+ + getId() + "\" alphanum tag not in proper format.");
+ }
+ }
+ }
+
+ /**
+ * Validates the input against the given constraints
+ *
+ * @return TRUE if valid, FALSE otherwise
+ */
+ protected Boolean validate(Object newValue, boolean setErrorCode) {
+
+ if (pattern != null && !(Pattern.matches(pattern.toLowerCase(),
+ ((String) newValue).toLowerCase()))) {
+ if (setErrorCode) setErrorCode(ERR_INVALID_ALPHANUM);
+ return Boolean.FALSE;
+ }
+ if (maxLength > 0 && ((String) newValue).length() > maxLength) {
+ if (setErrorCode) setErrorCode(ERR_NEED_SHORTER_ALPHANUM);
+ return Boolean.FALSE;
+ }
+ if (minLength > 0 && ((String) newValue).length() < minLength) {
+ if (setErrorCode) setErrorCode(ERR_NEED_LONGER_ALPHANUM);
+ return Boolean.FALSE;
+ }
+ return Boolean.TRUE;
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Color.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Color.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Color.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Color.java Wed Aug 10 14:10:59 2005
@@ -29,11 +29,11 @@
*/
public class Color extends BaseModel {
- /**
- * Sets default values for all data members
- */
- public Color() {
- super();
- }
+ /**
+ * Sets default values for all data members
+ */
+ public Color() {
+ super();
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Country.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Country.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Country.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Country.java Wed Aug 10 14:10:59 2005
@@ -29,11 +29,11 @@
public class Country extends BaseModel {
- /**
- * Sets default values for all data members
- */
- public Country() {
- super();
- }
+ /**
+ * Sets default values for all data members
+ */
+ public Country() {
+ super();
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardAmount.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardAmount.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardAmount.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardAmount.java Wed Aug 10 14:10:59 2005
@@ -39,278 +39,278 @@
* @author Rahul Akolkar
*/
public class CreditCardAmount extends BaseModel {
- // The amount value, balance, the maximum and minimum amounts due
- // have an expected format of the form UUUmm.nn or mm.nn
- // where UUU is the ISO 4217 currency code, mmm is integer
- // part and nn is the fractional part. If currency code is not
- // specified the default currency code for the default locale is used.
-
- // Maximum allowed amount for this payment
- private String maxAmount;
- // Minimum allowed amount for this payment
- private String minAmount;
- // The account balance
- private String balance;
- // ISO 4217 currency code for the amount
- private String currencyCode;
- // Maximum number of denials before a graceful exit
- private int maxDenials;
-
- // Number of denials
- private int denialCount;
-
- // Component Grammars
- private Grammar minimumDueGrammar;
- private Grammar fullAmountGrammar;
- public void setMinimumDueGrammar(Grammar g) { minimumDueGrammar = g; }
- public void setFullAmountGrammar(Grammar g) { fullAmountGrammar = g; }
-
- // If the current value is higher than the maximum value allowed
- /**A constant for Error Code stating the currency entered
- * is higher than allowed */
- public static final int ERR_NEED_LOWER_AMOUNT = 1;
-
- // If the current value is lower than the minimum value allowed
- /**A constant for Error Code stating the currency entered
- * is lower than allowed */
- public static final int ERR_NEED_HIGHER_AMOUNT = 2;
-
- /**
- * Sets default values for all data model members
- */
- public CreditCardAmount() {
- super();
- this.minAmount = null;
- this.maxAmount = null;
- this.maxDenials = 2;
- this.denialCount = 0;
- try {
- Locale defaultLocale = Locale.getDefault();
- java.util.Currency defaultCurrency =
- java.util.Currency.getInstance(defaultLocale);
- if (defaultCurrency == null) {
- this.currencyCode = "USD";
- } else {
- this.currencyCode = defaultCurrency.getCurrencyCode();
- }
- } catch (NullPointerException e) {
- this.currencyCode = "USD";
- } catch (IllegalArgumentException e) {
- this.currencyCode = "USD";
- }
- }
-
- /**
- * Record user response to confirmation
- *
- * @param confirmed The user confirmation
- */
- public void setConfirmed(Boolean confirmed) {
- super.setConfirmed(confirmed);
- if (!confirmed.booleanValue()) {
- denialCount++;
- if (maxDenials > 0 && denialCount == maxDenials) {
- setState(Constants.FSM_DONE);
- }
- }
- }
-
- /**
- * Gets the currency code for the currency used
- *
- * @return The ISO 4217 currency code currently used
- */
- public String getCurrencyCode() {
- return this.currencyCode;
- } // end getCurrencyCode
-
- /**
- * Sets the specified currency code
- *
- * @param code The currency code as defined in ISO 4217 standards
- */
- public void setCurrencyCode(String code) {
- if (code != null) {
- this.currencyCode = code.toUpperCase();
- }
- } // end setCurrencyCode
-
- /**
- * Gets the maximum allowed amount for this payment
- *
- * @return the maximum allowed amount
- */
- public String getMaxAmount() {
- return this.maxAmount;
- } // end getMaxAmount
-
- /**
- * Sets the maximum allowed amount for this payment
- *
- * @param maxAmount The maximum allowed amount
- */
- public void setMaxAmount(String maxAmount) {
- if (maxAmount != null) {
- this.maxAmount = (String)canonicalize(maxAmount.toUpperCase(), true);
- }
- } // end setMaxAmount
-
- /**
- * Gets the minimum allowed amount for this payment
- *
- * @return the minimum allowed amount
- */
- public String getMinAmount() {
- return this.minAmount;
- } // end getMinAmount
-
- /**
- * Sets the minimum allowed amount for this payment
- *
- * @param minAmount The minimum allowed amount
- */
- public void setMinAmount(String minAmount) {
- if (minAmount != null) {
- this.minAmount = (String)canonicalize(minAmount.toUpperCase(), true);
- this.grammars.add(this.minimumDueGrammar);
- }
- } // end setMinAmount
-
- /**
- * Return the account balance
- *
- * @return Returns the balance
- */
- public String getBalance() {
- return balance;
- }
-
- /**
- * Set the account balance
- *
- * @param balance The balance to set.
- */
- public void setBalance(String balance) {
- if (balance != null) {
- this.balance = (String)canonicalize(balance.toUpperCase(), true);
- this.grammars.add(this.fullAmountGrammar);
- }
- }
-
- /**
- * Get the maximum denials allowed before graceful exit
- *
- * @return Returns the maxDenials.
- */
- public int getMaxDenials() {
- return maxDenials;
- }
- /**
- * Set the maximum denials allowed before graceful exit
- *
- * @param maxDenials The maxDenials to set.
- */
- public void setMaxDenials(int maxDenials) {
- this.maxDenials = maxDenials;
- }
-
- /**
- * Sets up maximum or minimum permissible value. The format is
- * UUUmm.nn or mm.nn. If value is in UUUmm.nn format the currency
- * code UUU is ignored and the default currency code or
- * the supplied currency code is assumed.
- *
- * @param strInput The maximum or minimum amount,
- * either in UUUmm.nn or mm.nn format
- * @return formatted maximum or minimum value in mm.nn format
- */
- protected Object canonicalize(Object input, boolean isAttribute) {
- if (input == null) {
- return null;
- }
- String inputStr = (String) input;
- try {
- if (inputStr == null) {
- return inputStr;
- }
- String newValue = null;
-
- DecimalFormat df = new DecimalFormat("#.#");
- java.util.Currency currency =
- java.util.Currency.getInstance(getCurrencyCode());
- df.setMaximumFractionDigits(currency.getDefaultFractionDigits());
- df.setMinimumFractionDigits(currency.getDefaultFractionDigits());
-
- if (Pattern.matches("[A-Za-z][A-Za-z][A-Za-z][0-9]*.?[0-9]*",
- inputStr.toUpperCase())) {
- String strCode = inputStr.toUpperCase().substring(0, 3);
- if ((!isAttribute &&
- (strCode.compareToIgnoreCase(currencyCode)) != 0)) {
- throw new IllegalArgumentException("The required " +
- "currency code of \"" + getId() + "\" and the" +
- " entered currency code do not match.");
- }
- newValue = inputStr.toUpperCase().substring(3);
- } else {
- newValue = inputStr;
- }
- if (!isAttribute) {
- if ("minimum".equalsIgnoreCase(inputStr)) {
- inputStr = minAmount;
- } else if ("full".equalsIgnoreCase(inputStr)) {
- inputStr = balance;
- }
- }
- Double valueDouble = new Double(newValue);
- return df.format(valueDouble.doubleValue()).toUpperCase();
- } catch (IndexOutOfBoundsException e) {
- if (isAttribute) {
- throw new IllegalArgumentException("An amount value \"" +
- inputStr + "\" associated with creditcardAmount RDC " +getId()+
- "\" is not in proper format. The format is UUUmm.nn or mm.nn");
- } else {
- return null;
- }
- } catch (NullPointerException e) {
- throw new IllegalArgumentException("Currency code of \"" +
- getId() + "\" is null.");
- } catch (NumberFormatException e) {
- if (isAttribute) {
- throw new IllegalArgumentException("An amount value \"" +
- inputStr + "\" associated with creditcardAmount RDC " +getId()+
- "\" is not in proper format. The format is UUUmm.nn or mm.nn");
- } else {
- return null;
- }
- }
-
- } // end normalize()
-
- /**
- * Validates the amount value against the given constraints
- *
- * @return TRUE if valid, FALSE otherwise
- */
- protected Boolean validate(Object newValue, boolean setErrorCode) {
-
- Double val, maxVal, minVal;
- val = new Double((String) newValue);
- if (maxAmount != null) {
- maxVal = new Double(maxAmount);
- if (val.doubleValue() > maxVal.doubleValue()) {
- if (setErrorCode) setErrorCode(ERR_NEED_LOWER_AMOUNT);
- return Boolean.FALSE;
- }
- }
- if (minAmount != null) {
- minVal = new Double(minAmount);
- if (val.doubleValue() < minVal.doubleValue()) {
- if (setErrorCode) setErrorCode(ERR_NEED_HIGHER_AMOUNT);
- return Boolean.FALSE;
- }
- }
- return Boolean.TRUE;
- } // end validate()
+ // The amount value, balance, the maximum and minimum amounts due
+ // have an expected format of the form UUUmm.nn or mm.nn
+ // where UUU is the ISO 4217 currency code, mmm is integer
+ // part and nn is the fractional part. If currency code is not
+ // specified the default currency code for the default locale is used.
+
+ // Maximum allowed amount for this payment
+ private String maxAmount;
+ // Minimum allowed amount for this payment
+ private String minAmount;
+ // The account balance
+ private String balance;
+ // ISO 4217 currency code for the amount
+ private String currencyCode;
+ // Maximum number of denials before a graceful exit
+ private int maxDenials;
+
+ // Number of denials
+ private int denialCount;
+
+ // Component Grammars
+ private Grammar minimumDueGrammar;
+ private Grammar fullAmountGrammar;
+ public void setMinimumDueGrammar(Grammar g) { minimumDueGrammar = g; }
+ public void setFullAmountGrammar(Grammar g) { fullAmountGrammar = g; }
+
+ // If the current value is higher than the maximum value allowed
+ /**A constant for Error Code stating the currency entered
+ * is higher than allowed */
+ public static final int ERR_NEED_LOWER_AMOUNT = 1;
+
+ // If the current value is lower than the minimum value allowed
+ /**A constant for Error Code stating the currency entered
+ * is lower than allowed */
+ public static final int ERR_NEED_HIGHER_AMOUNT = 2;
+
+ /**
+ * Sets default values for all data model members
+ */
+ public CreditCardAmount() {
+ super();
+ this.minAmount = null;
+ this.maxAmount = null;
+ this.maxDenials = 2;
+ this.denialCount = 0;
+ try {
+ Locale defaultLocale = Locale.getDefault();
+ java.util.Currency defaultCurrency =
+ java.util.Currency.getInstance(defaultLocale);
+ if (defaultCurrency == null) {
+ this.currencyCode = "USD";
+ } else {
+ this.currencyCode = defaultCurrency.getCurrencyCode();
+ }
+ } catch (NullPointerException e) {
+ this.currencyCode = "USD";
+ } catch (IllegalArgumentException e) {
+ this.currencyCode = "USD";
+ }
+ }
+
+ /**
+ * Record user response to confirmation
+ *
+ * @param confirmed The user confirmation
+ */
+ public void setConfirmed(Boolean confirmed) {
+ super.setConfirmed(confirmed);
+ if (!confirmed.booleanValue()) {
+ denialCount++;
+ if (maxDenials > 0 && denialCount == maxDenials) {
+ setState(Constants.FSM_DONE);
+ }
+ }
+ }
+
+ /**
+ * Gets the currency code for the currency used
+ *
+ * @return The ISO 4217 currency code currently used
+ */
+ public String getCurrencyCode() {
+ return this.currencyCode;
+ } // end getCurrencyCode
+
+ /**
+ * Sets the specified currency code
+ *
+ * @param code The currency code as defined in ISO 4217 standards
+ */
+ public void setCurrencyCode(String code) {
+ if (code != null) {
+ this.currencyCode = code.toUpperCase();
+ }
+ } // end setCurrencyCode
+
+ /**
+ * Gets the maximum allowed amount for this payment
+ *
+ * @return the maximum allowed amount
+ */
+ public String getMaxAmount() {
+ return this.maxAmount;
+ } // end getMaxAmount
+
+ /**
+ * Sets the maximum allowed amount for this payment
+ *
+ * @param maxAmount The maximum allowed amount
+ */
+ public void setMaxAmount(String maxAmount) {
+ if (maxAmount != null) {
+ this.maxAmount = (String)canonicalize(maxAmount.toUpperCase(), true);
+ }
+ } // end setMaxAmount
+
+ /**
+ * Gets the minimum allowed amount for this payment
+ *
+ * @return the minimum allowed amount
+ */
+ public String getMinAmount() {
+ return this.minAmount;
+ } // end getMinAmount
+
+ /**
+ * Sets the minimum allowed amount for this payment
+ *
+ * @param minAmount The minimum allowed amount
+ */
+ public void setMinAmount(String minAmount) {
+ if (minAmount != null) {
+ this.minAmount = (String)canonicalize(minAmount.toUpperCase(), true);
+ this.grammars.add(this.minimumDueGrammar);
+ }
+ } // end setMinAmount
+
+ /**
+ * Return the account balance
+ *
+ * @return Returns the balance
+ */
+ public String getBalance() {
+ return balance;
+ }
+
+ /**
+ * Set the account balance
+ *
+ * @param balance The balance to set.
+ */
+ public void setBalance(String balance) {
+ if (balance != null) {
+ this.balance = (String)canonicalize(balance.toUpperCase(), true);
+ this.grammars.add(this.fullAmountGrammar);
+ }
+ }
+
+ /**
+ * Get the maximum denials allowed before graceful exit
+ *
+ * @return Returns the maxDenials.
+ */
+ public int getMaxDenials() {
+ return maxDenials;
+ }
+ /**
+ * Set the maximum denials allowed before graceful exit
+ *
+ * @param maxDenials The maxDenials to set.
+ */
+ public void setMaxDenials(int maxDenials) {
+ this.maxDenials = maxDenials;
+ }
+
+ /**
+ * Sets up maximum or minimum permissible value. The format is
+ * UUUmm.nn or mm.nn. If value is in UUUmm.nn format the currency
+ * code UUU is ignored and the default currency code or
+ * the supplied currency code is assumed.
+ *
+ * @param strInput The maximum or minimum amount,
+ * either in UUUmm.nn or mm.nn format
+ * @return formatted maximum or minimum value in mm.nn format
+ */
+ protected Object canonicalize(Object input, boolean isAttribute) {
+ if (input == null) {
+ return null;
+ }
+ String inputStr = (String) input;
+ try {
+ if (inputStr == null) {
+ return inputStr;
+ }
+ String newValue = null;
+
+ DecimalFormat df = new DecimalFormat("#.#");
+ java.util.Currency currency =
+ java.util.Currency.getInstance(getCurrencyCode());
+ df.setMaximumFractionDigits(currency.getDefaultFractionDigits());
+ df.setMinimumFractionDigits(currency.getDefaultFractionDigits());
+
+ if (Pattern.matches("[A-Za-z][A-Za-z][A-Za-z][0-9]*.?[0-9]*",
+ inputStr.toUpperCase())) {
+ String strCode = inputStr.toUpperCase().substring(0, 3);
+ if ((!isAttribute &&
+ (strCode.compareToIgnoreCase(currencyCode)) != 0)) {
+ throw new IllegalArgumentException("The required " +
+ "currency code of \"" + getId() + "\" and the" +
+ " entered currency code do not match.");
+ }
+ newValue = inputStr.toUpperCase().substring(3);
+ } else {
+ newValue = inputStr;
+ }
+ if (!isAttribute) {
+ if ("minimum".equalsIgnoreCase(inputStr)) {
+ inputStr = minAmount;
+ } else if ("full".equalsIgnoreCase(inputStr)) {
+ inputStr = balance;
+ }
+ }
+ Double valueDouble = new Double(newValue);
+ return df.format(valueDouble.doubleValue()).toUpperCase();
+ } catch (IndexOutOfBoundsException e) {
+ if (isAttribute) {
+ throw new IllegalArgumentException("An amount value \"" +
+ inputStr + "\" associated with creditcardAmount RDC " +getId()+
+ "\" is not in proper format. The format is UUUmm.nn or mm.nn");
+ } else {
+ return null;
+ }
+ } catch (NullPointerException e) {
+ throw new IllegalArgumentException("Currency code of \"" +
+ getId() + "\" is null.");
+ } catch (NumberFormatException e) {
+ if (isAttribute) {
+ throw new IllegalArgumentException("An amount value \"" +
+ inputStr + "\" associated with creditcardAmount RDC " +getId()+
+ "\" is not in proper format. The format is UUUmm.nn or mm.nn");
+ } else {
+ return null;
+ }
+ }
+
+ } // end normalize()
+
+ /**
+ * Validates the amount value against the given constraints
+ *
+ * @return TRUE if valid, FALSE otherwise
+ */
+ protected Boolean validate(Object newValue, boolean setErrorCode) {
+
+ Double val, maxVal, minVal;
+ val = new Double((String) newValue);
+ if (maxAmount != null) {
+ maxVal = new Double(maxAmount);
+ if (val.doubleValue() > maxVal.doubleValue()) {
+ if (setErrorCode) setErrorCode(ERR_NEED_LOWER_AMOUNT);
+ return Boolean.FALSE;
+ }
+ }
+ if (minAmount != null) {
+ minVal = new Double(minAmount);
+ if (val.doubleValue() < minVal.doubleValue()) {
+ if (setErrorCode) setErrorCode(ERR_NEED_HIGHER_AMOUNT);
+ return Boolean.FALSE;
+ }
+ }
+ return Boolean.TRUE;
+ } // end validate()
}
// *** End of CreditCardPayment.java ***
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardData.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardData.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardData.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardData.java Wed Aug 10 14:10:59 2005
@@ -29,104 +29,104 @@
*/
public class CreditCardData implements Serializable {
- // Properties, one for each child component
- private String type;
- private String number;
- private Date expiry;
- private String securityCode;
- // Formatter for date
- private SimpleDateFormat formatter;
+ // Properties, one for each child component
+ private String type;
+ private String number;
+ private Date expiry;
+ private String securityCode;
+ // Formatter for date
+ private SimpleDateFormat formatter;
- public CreditCardData() {
- this.type = null;
- this.number = null;
- this.expiry = null;
- this.securityCode = null;
- this.formatter = new SimpleDateFormat("MMyyyy");
- }
-
- /**
- * Get the type of credit card
- *
- * @return the card type
- */
- public String getType() {
- return type;
- }
+ public CreditCardData() {
+ this.type = null;
+ this.number = null;
+ this.expiry = null;
+ this.securityCode = null;
+ this.formatter = new SimpleDateFormat("MMyyyy");
+ }
+
+ /**
+ * Get the type of credit card
+ *
+ * @return the card type
+ */
+ public String getType() {
+ return type;
+ }
- /**
- * Set the type of credit card
- *
- * @param type The card type.
- */
- public void setType(String type) {
- this.type = type;
- }
-
- /**
- * Get the card number as a String
- *
- * @return the card number
- */
- public String getNumber() {
- return number;
- }
-
- /**
- * Set the card number as a String
- *
- * @param number The card number.
- */
- public void setNumber(String number) {
- this.number = number;
- }
+ /**
+ * Set the type of credit card
+ *
+ * @param type The card type.
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * Get the card number as a String
+ *
+ * @return the card number
+ */
+ public String getNumber() {
+ return number;
+ }
+
+ /**
+ * Set the card number as a String
+ *
+ * @param number The card number.
+ */
+ public void setNumber(String number) {
+ this.number = number;
+ }
- /**
- * Gets the expiry date
- *
- * @return Returns the expiry date.
- */
- public Date getExpiry() {
- return expiry;
- }
-
- /**
- * Sets the expiry date
- *
- * @param expiry The expiry to set.
- */
- public void setExpiry(Date expiry) {
- this.expiry = expiry;
- }
-
- /**
- * Gets the security code
- *
- * @return Returns the securityCode.
- */
- public String getSecurityCode() {
- return securityCode;
- }
-
- /**
- * Sets the security code
- *
- * @param securityCode The securityCode to set.
- */
- public void setSecurityCode(String securityCode) {
- this.securityCode = securityCode;
- }
-
- /**
- * A serialized version of CreditCardData object
- */
- public String toString() {
- String expStr = formatter.format(expiry);
- StringBuffer buf = new StringBuffer();
- buf.append("type=").append(this.type).append(";number=").
- append(this.number).append(";expiry=").append(expStr).
- append(";securityCode=").append(this.securityCode);
- return buf.toString();
- }
-
+ /**
+ * Gets the expiry date
+ *
+ * @return Returns the expiry date.
+ */
+ public Date getExpiry() {
+ return expiry;
+ }
+
+ /**
+ * Sets the expiry date
+ *
+ * @param expiry The expiry to set.
+ */
+ public void setExpiry(Date expiry) {
+ this.expiry = expiry;
+ }
+
+ /**
+ * Gets the security code
+ *
+ * @return Returns the securityCode.
+ */
+ public String getSecurityCode() {
+ return securityCode;
+ }
+
+ /**
+ * Sets the security code
+ *
+ * @param securityCode The securityCode to set.
+ */
+ public void setSecurityCode(String securityCode) {
+ this.securityCode = securityCode;
+ }
+
+ /**
+ * A serialized version of CreditCardData object
+ */
+ public String toString() {
+ String expStr = formatter.format(expiry);
+ StringBuffer buf = new StringBuffer();
+ buf.append("type=").append(this.type).append(";number=").
+ append(this.number).append(";expiry=").append(expStr).
+ append(";securityCode=").append(this.securityCode);
+ return buf.toString();
+ }
+
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardExpiry.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardExpiry.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardExpiry.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardExpiry.java Wed Aug 10 14:10:59 2005
@@ -33,86 +33,86 @@
*/
public class CreditCardExpiry extends BaseModel {
- // Error codes, corresponding prompts defined in configuration file
- /**A constant for Error Code stating card has already expired
- * (as of today) */
- public static final int ERR_EXPIRED = 1;
-
- // Maximum number of denials before a graceful exit
- private int maxDenials;
-
- // Number of denials
- private int denialCount;
-
- /**
- * Sets default values for all data members
- */
- public CreditCardExpiry() {
- super();
- this.maxDenials = 2;
- this.denialCount = 0;
- } // end CreditCardExpiry constructor
-
- /**
- * Record user response to confirmation
- *
- * @param confirmed The user confirmation
- */
- public void setConfirmed(Boolean confirmed) {
- super.setConfirmed(confirmed);
- if (!confirmed.booleanValue()) {
- denialCount++;
- if (maxDenials > 0 && denialCount == maxDenials) {
- setState(Constants.FSM_DONE);
- }
- }
- }
+ // Error codes, corresponding prompts defined in configuration file
+ /**A constant for Error Code stating card has already expired
+ * (as of today) */
+ public static final int ERR_EXPIRED = 1;
+
+ // Maximum number of denials before a graceful exit
+ private int maxDenials;
+
+ // Number of denials
+ private int denialCount;
+
+ /**
+ * Sets default values for all data members
+ */
+ public CreditCardExpiry() {
+ super();
+ this.maxDenials = 2;
+ this.denialCount = 0;
+ } // end CreditCardExpiry constructor
+
+ /**
+ * Record user response to confirmation
+ *
+ * @param confirmed The user confirmation
+ */
+ public void setConfirmed(Boolean confirmed) {
+ super.setConfirmed(confirmed);
+ if (!confirmed.booleanValue()) {
+ denialCount++;
+ if (maxDenials > 0 && denialCount == maxDenials) {
+ setState(Constants.FSM_DONE);
+ }
+ }
+ }
- /**
- * Get the maximum denials allowed before graceful exit
- *
- * @return Returns the maxDenials.
- */
- public int getMaxDenials() {
- return maxDenials;
- }
- /**
- * Set the maximum denials allowed before graceful exit
- *
- * @param maxDenials The maxDenials to set.
- */
- public void setMaxDenials(int maxDenials) {
- this.maxDenials = maxDenials;
- }
-
- /**
- * Canonicalize
- *
- * @return The value of date
- */
- protected Object canonicalize(Object input, boolean isAttribute) {
- if (input == null) {
- return null;
- }
- SimpleDateFormat df = new SimpleDateFormat("MMddyyyy");
- df.setLenient(false);
- return df.parse((String) input, new ParsePosition(0));
- }
+ /**
+ * Get the maximum denials allowed before graceful exit
+ *
+ * @return Returns the maxDenials.
+ */
+ public int getMaxDenials() {
+ return maxDenials;
+ }
+ /**
+ * Set the maximum denials allowed before graceful exit
+ *
+ * @param maxDenials The maxDenials to set.
+ */
+ public void setMaxDenials(int maxDenials) {
+ this.maxDenials = maxDenials;
+ }
+
+ /**
+ * Canonicalize
+ *
+ * @return The value of date
+ */
+ protected Object canonicalize(Object input, boolean isAttribute) {
+ if (input == null) {
+ return null;
+ }
+ SimpleDateFormat df = new SimpleDateFormat("MMddyyyy");
+ df.setLenient(false);
+ return df.parse((String) input, new ParsePosition(0));
+ }
- /**
- * Validates the received input against the validation constraints
- *
- * @return True if valid, False if invalid
- */
- protected Boolean validate(Object newValue, boolean setErrorCode) {
-
- Date newDate = (Date) newValue;
- if (newDate.before(new GregorianCalendar().getTime())) {
- if (setErrorCode) setErrorCode(ERR_EXPIRED);
- return Boolean.FALSE;
- }
- return Boolean.TRUE;
- } // end validate()
+ /**
+ * Validates the received input against the validation constraints
+ *
+ * @return True if valid, False if invalid
+ */
+ protected Boolean validate(Object newValue, boolean setErrorCode) {
+
+ Date newDate = (Date) newValue;
+ if (newDate.before(new GregorianCalendar().getTime())) {
+ if (setErrorCode) setErrorCode(ERR_EXPIRED);
+ return Boolean.FALSE;
+ }
+ return Boolean.TRUE;
+ } // end validate()
} // end class CreditCardExpiry{}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardInfo.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardInfo.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardInfo.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardInfo.java Wed Aug 10 14:10:59 2005
@@ -28,94 +28,94 @@
*/
public class CreditCardInfo extends ComponentModel {
- // The mode this instance will work in
- private String mode;
-
- public CreditCardInfo(){
- super();
- mode = MODE_LONG;
- }
+ // The mode this instance will work in
+ private String mode;
+
+ public CreditCardInfo(){
+ super();
+ mode = MODE_LONG;
+ }
- /**
- * Stores the id and file attributes from the config xml to the
- * configMap
- *
- * @see ComponentModel#configHandler()
- */
- public void configHandler() {
- this.configMap = RDCUtils.configHandler(this.config,
- (PageContext) this.context);
- }
-
- /**
- * Get the current mode
- *
- * @return Returns the mode.
- */
- public String getMode() {
- return mode;
- }
-
- /**
- * Set the mode
- *
- * @param mode The mode to set.
- */
- public void setMode(String mode) {
- if (mode != null) {
- this.mode = mode;
- }
- }
+ /**
+ * Stores the id and file attributes from the config xml to the
+ * configMap
+ *
+ * @see ComponentModel#configHandler()
+ */
+ public void configHandler() {
+ this.configMap = RDCUtils.configHandler(this.config,
+ (PageContext) this.context);
+ }
+
+ /**
+ * Get the current mode
+ *
+ * @return Returns the mode.
+ */
+ public String getMode() {
+ return mode;
+ }
+
+ /**
+ * Set the mode
+ *
+ * @param mode The mode to set.
+ */
+ public void setMode(String mode) {
+ if (mode != null) {
+ this.mode = mode;
+ }
+ }
- //// Mode definitions
- // Everything
- private static final String MODE_LONG = "long";
- // number + expiry
- private static final String MODE_SHORT = "short";
- // type only
- private static final String MODE_TYPE = "type";
- // number only
- private static final String MODE_NUMBER = "number";
- // expiry only
- private static final String MODE_EXPIRY = "expiry";
- // security code only
- private static final String MODE_SECURITY = "security";
-
- //// Getters for the modes
- /**
- * @return Returns MODE_EXPIRY
- */
- public String getMODE_EXPIRY() {
- return MODE_EXPIRY;
- }
- /**
- * @return Returns MODE_LONG.
- */
- public String getMODE_LONG() {
- return MODE_LONG;
- }
- /**
- * @return Returns MODE_NUMBER.
- */
- public String getMODE_NUMBER() {
- return MODE_NUMBER;
- }
- /**
- * @return Returns MODE_SECURITY.
- */
- public String getMODE_SECURITY() {
- return MODE_SECURITY;
- }
- /**
- * @return Returns MODE_SHORT.
- */
- public String getMODE_SHORT() {
- return MODE_SHORT;
- }
- /**
- * @return Returns MODE_TYPE.
- */
- public String getMODE_TYPE() {
- return MODE_TYPE;
- }
+ //// Mode definitions
+ // Everything
+ private static final String MODE_LONG = "long";
+ // number + expiry
+ private static final String MODE_SHORT = "short";
+ // type only
+ private static final String MODE_TYPE = "type";
+ // number only
+ private static final String MODE_NUMBER = "number";
+ // expiry only
+ private static final String MODE_EXPIRY = "expiry";
+ // security code only
+ private static final String MODE_SECURITY = "security";
+
+ //// Getters for the modes
+ /**
+ * @return Returns MODE_EXPIRY
+ */
+ public String getMODE_EXPIRY() {
+ return MODE_EXPIRY;
+ }
+ /**
+ * @return Returns MODE_LONG.
+ */
+ public String getMODE_LONG() {
+ return MODE_LONG;
+ }
+ /**
+ * @return Returns MODE_NUMBER.
+ */
+ public String getMODE_NUMBER() {
+ return MODE_NUMBER;
+ }
+ /**
+ * @return Returns MODE_SECURITY.
+ */
+ public String getMODE_SECURITY() {
+ return MODE_SECURITY;
+ }
+ /**
+ * @return Returns MODE_SHORT.
+ */
+ public String getMODE_SHORT() {
+ return MODE_SHORT;
+ }
+ /**
+ * @return Returns MODE_TYPE.
+ */
+ public String getMODE_TYPE() {
+ return MODE_TYPE;
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardNumber.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardNumber.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardNumber.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardNumber.java Wed Aug 10 14:10:59 2005
@@ -27,51 +27,51 @@
* @author Rahul Akolkar
*/
public class CreditCardNumber extends BaseModel {
-
- // Maximum number of denials before a graceful exit
- private int maxDenials;
-
- // Number of denials
- private int denialCount;
+
+ // Maximum number of denials before a graceful exit
+ private int maxDenials;
+
+ // Number of denials
+ private int denialCount;
- /**
- * Constructor
- */
- public CreditCardNumber() {
- super();
- this.maxDenials = 2;
- this.denialCount = 0;
- }
-
- /**
- * Record user response to confirmation
- *
- * @param confirmed The user confirmation
- */
- public void setConfirmed(Boolean confirmed) {
- super.setConfirmed(confirmed);
- if (!confirmed.booleanValue()) {
- denialCount++;
- if (maxDenials > 0 && denialCount == maxDenials) {
- setState(Constants.FSM_DONE);
- }
- }
- }
+ /**
+ * Constructor
+ */
+ public CreditCardNumber() {
+ super();
+ this.maxDenials = 2;
+ this.denialCount = 0;
+ }
+
+ /**
+ * Record user response to confirmation
+ *
+ * @param confirmed The user confirmation
+ */
+ public void setConfirmed(Boolean confirmed) {
+ super.setConfirmed(confirmed);
+ if (!confirmed.booleanValue()) {
+ denialCount++;
+ if (maxDenials > 0 && denialCount == maxDenials) {
+ setState(Constants.FSM_DONE);
+ }
+ }
+ }
- /**
- * Get the maximum denials allowed before graceful exit
- *
- * @return Returns the maxDenials.
- */
- public int getMaxDenials() {
- return maxDenials;
- }
- /**
- * Set the maximum denials allowed before graceful exit
- *
- * @param maxDenials The maxDenials to set.
- */
- public void setMaxDenials(int maxDenials) {
- this.maxDenials = maxDenials;
- }
+ /**
+ * Get the maximum denials allowed before graceful exit
+ *
+ * @return Returns the maxDenials.
+ */
+ public int getMaxDenials() {
+ return maxDenials;
+ }
+ /**
+ * Set the maximum denials allowed before graceful exit
+ *
+ * @param maxDenials The maxDenials to set.
+ */
+ public void setMaxDenials(int maxDenials) {
+ this.maxDenials = maxDenials;
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardType.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardType.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardType.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/CreditCardType.java Wed Aug 10 14:10:59 2005
@@ -29,11 +29,11 @@
public class CreditCardType extends BaseModel {
- /**
- * Sets default values for all data members
- */
- public CreditCardType() {
- super();
- }
+ /**
+ * Sets default values for all data members
+ */
+ public CreditCardType() {
+ super();
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Currency.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Currency.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Currency.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/Currency.java Wed Aug 10 14:10:59 2005
@@ -40,210 +40,210 @@
* @author Rahul Akolkar
*/
public class Currency extends BaseModel {
- // The currency RDC will be associated with the currency input,
- // the maximum and minimum values within which the input must
- // lie and the currency code. The currency value and the maximum
- // and minimum values has an expected format of the form UUUmm.nn
- // or mm.nn where UUU is the ISO 4217 currency code, mmm is integer
- // part and nn is the fractional part. If currency code is not
- // specified the default currency code for the default locale is assumed.
-
- // Maximum allowed value for the amount
- private String maxValue;
- // Minimum allowed value for the amount
- private String minValue;
- // ISO 4217 currency code for the amount
- private String currencyCode;
-
- // If the current value is higher than the maximum value allowed
- /**A constant for Error Code stating the currency entered
- * is higher than allowed */
- public static final int ERR_NEED_LOWER_VALUE = 1;
-
- // If the current value is lower than the minimum value allowed
- /**A constant for Error Code stating the currency entered
- * is lower than allowed */
- public static final int ERR_NEED_HIGHER_VALUE = 2;
-
- /**
- * Sets default values for all data model members
- */
- public Currency() {
- super();
-
- // Values are of the form mm.nn
- this.minValue = null;
- this.maxValue = null;
-
- // Get default locale and the corresponding currecy code for that locale
- // If there is no currency code for the default locale or if the default
- // currency code is not supported than the default currency code is USD
- // (US dollars)
- try {
- Locale defaultLocale = Locale.getDefault();
- java.util.Currency defaultCurrency =
- java.util.Currency.getInstance(defaultLocale);
- if (defaultCurrency == null) {
- this.currencyCode = "USD";
- } else {
- this.currencyCode = defaultCurrency.getCurrencyCode();
- }
- } catch (NullPointerException e) {
- this.currencyCode = "USD";
- } catch (IllegalArgumentException e) {
- this.currencyCode = "USD";
- }
- }
-
- /**
- * Gets the currency code for the currency used
- *
- * @return The ISO 4217 currency code currently used
- */
- public String getCurrencyCode() {
- return this.currencyCode;
- } // end getCurrencyCode
-
- /**
- * Sets the specified currency code
- *
- * @param code The currency code as defined in ISO 4217 standards
- */
- public void setCurrencyCode(String code) {
- if (code != null) {
- this.currencyCode = code.toUpperCase();
- }
- } // end setCurrencyCode
-
- /**
- * Gets the maximum allowed value for the amount
- *
- * @return the maximum allowed value for the amount
- */
- public String getMaxValue() {
- return this.maxValue;
- } // end getMaxValue
-
- /**
- * Sets the maximum allowed value for the amount
- *
- * @param maxValue The maximum allowed value
- */
- public void setMaxValue(String maxValue) {
- if (maxValue != null) {
- this.maxValue = (String)canonicalize(maxValue.toUpperCase(), true);
- }
- } // end setMaxValue
-
- /**
- * Gets the minimum allowed value for the amount
- *
- * @return the minimum allowed value for the amount
- */
- public String getMinValue() {
- return this.minValue;
- } // end getMinValue
-
- /**
- * Sets the minimum allowed value for the amount
- *
- * @param minValue The minimum allowed value
- */
- public void setMinValue(String minValue) {
- if (minValue != null) {
- this.minValue = (String)canonicalize(minValue.toUpperCase(), true);
- }
- } // end setMinValue()
-
- /**
- * Sets up maximum or minimum permissible value. The format is UUUmm.nn or mm.nn. If value
- * is in UUUmm.nn format the currency code UUU is ignored and the default currency code or
- * the supplied currency code is assumed.
- *
- * @param strInput The maximum or minimum amount, either in UUUmm.nn or mm.nn format
- * @return formatted maximum or minimum value in mm.nn format
- */
- protected Object canonicalize(Object input, boolean isAttribute) {
- if (input == null) {
- return null;
- }
- String inputStr = (String) input;
- try {
- if (inputStr == null) {
- return inputStr;
- }
- String newValue = null;
-
- DecimalFormat df = new DecimalFormat("#.#");
- java.util.Currency currency =
- java.util.Currency.getInstance(getCurrencyCode());
- df.setMaximumFractionDigits(currency.getDefaultFractionDigits());
- df.setMinimumFractionDigits(currency.getDefaultFractionDigits());
-
- if (Pattern.matches("[A-Za-z][A-Za-z][A-Za-z][0-9]*.?[0-9]*",
- inputStr.toUpperCase())) {
- String strCode = inputStr.toUpperCase().substring(0, 3);
- if ((!isAttribute &&
- (strCode.compareToIgnoreCase(currencyCode)) != 0)) {
- throw new IllegalArgumentException("The required " +
- "currency code of \"" + getId() + "\" and the" +
- " entered currency code do not match.");
- }
- newValue = inputStr.toUpperCase().substring(3);
- } else {
- newValue = inputStr.toUpperCase();
- }
-
- Double valueDouble = new Double(newValue);
- return df.format(valueDouble.doubleValue()).toUpperCase();
- } catch (IndexOutOfBoundsException e) {
- if (isAttribute) {
- throw new IllegalArgumentException("An amount value \"" +
- inputStr + "\" associated with currency RDC " + getId() +
- "\" is not in proper format. The format is UUUmm.nn or mm.nn");
- } else {
- return null;
- }
- } catch (NullPointerException e) {
- throw new IllegalArgumentException("Currency code of \"" +
- getId() + "\" is null.");
- } catch (NumberFormatException e) {
- if (isAttribute) {
- throw new IllegalArgumentException("An amount value \"" +
- inputStr + "\" associated with currency RDC " + getId() +
- "\" is not in proper format. The format is UUUmm.nn or mm.nn");
- } else {
- return null;
- }
- }
-
- } // end normalize()
-
- /**
- * Validates the amount value against the given constraints
- *
- * @return TRUE if valid, FALSE otherwise
- */
- protected Boolean validate(Object newValue, boolean setErrorCode) {
-
- Double val, maxVal, minVal;
- val = new Double((String) value);
- if (maxValue != null) {
- maxVal = new Double(maxValue);
- if (val.doubleValue() > maxVal.doubleValue()) {
- if (setErrorCode) setErrorCode(ERR_NEED_LOWER_VALUE);
- return Boolean.FALSE;
- }
- }
- if (minValue != null) {
- minVal = new Double(minValue);
- if (val.doubleValue() < minVal.doubleValue()) {
- if (setErrorCode) setErrorCode(ERR_NEED_HIGHER_VALUE);
- return Boolean.FALSE;
- }
- }
- return Boolean.TRUE;
- } // end customValidate()
+ // The currency RDC will be associated with the currency input,
+ // the maximum and minimum values within which the input must
+ // lie and the currency code. The currency value and the maximum
+ // and minimum values has an expected format of the form UUUmm.nn
+ // or mm.nn where UUU is the ISO 4217 currency code, mmm is integer
+ // part and nn is the fractional part. If currency code is not
+ // specified the default currency code for the default locale is assumed.
+
+ // Maximum allowed value for the amount
+ private String maxValue;
+ // Minimum allowed value for the amount
+ private String minValue;
+ // ISO 4217 currency code for the amount
+ private String currencyCode;
+
+ // If the current value is higher than the maximum value allowed
+ /**A constant for Error Code stating the currency entered
+ * is higher than allowed */
+ public static final int ERR_NEED_LOWER_VALUE = 1;
+
+ // If the current value is lower than the minimum value allowed
+ /**A constant for Error Code stating the currency entered
+ * is lower than allowed */
+ public static final int ERR_NEED_HIGHER_VALUE = 2;
+
+ /**
+ * Sets default values for all data model members
+ */
+ public Currency() {
+ super();
+
+ // Values are of the form mm.nn
+ this.minValue = null;
+ this.maxValue = null;
+
+ // Get default locale and the corresponding currecy code for that locale
+ // If there is no currency code for the default locale or if the default
+ // currency code is not supported than the default currency code is USD
+ // (US dollars)
+ try {
+ Locale defaultLocale = Locale.getDefault();
+ java.util.Currency defaultCurrency =
+ java.util.Currency.getInstance(defaultLocale);
+ if (defaultCurrency == null) {
+ this.currencyCode = "USD";
+ } else {
+ this.currencyCode = defaultCurrency.getCurrencyCode();
+ }
+ } catch (NullPointerException e) {
+ this.currencyCode = "USD";
+ } catch (IllegalArgumentException e) {
+ this.currencyCode = "USD";
+ }
+ }
+
+ /**
+ * Gets the currency code for the currency used
+ *
+ * @return The ISO 4217 currency code currently used
+ */
+ public String getCurrencyCode() {
+ return this.currencyCode;
+ } // end getCurrencyCode
+
+ /**
+ * Sets the specified currency code
+ *
+ * @param code The currency code as defined in ISO 4217 standards
+ */
+ public void setCurrencyCode(String code) {
+ if (code != null) {
+ this.currencyCode = code.toUpperCase();
+ }
+ } // end setCurrencyCode
+
+ /**
+ * Gets the maximum allowed value for the amount
+ *
+ * @return the maximum allowed value for the amount
+ */
+ public String getMaxValue() {
+ return this.maxValue;
+ } // end getMaxValue
+
+ /**
+ * Sets the maximum allowed value for the amount
+ *
+ * @param maxValue The maximum allowed value
+ */
+ public void setMaxValue(String maxValue) {
+ if (maxValue != null) {
+ this.maxValue = (String)canonicalize(maxValue.toUpperCase(), true);
+ }
+ } // end setMaxValue
+
+ /**
+ * Gets the minimum allowed value for the amount
+ *
+ * @return the minimum allowed value for the amount
+ */
+ public String getMinValue() {
+ return this.minValue;
+ } // end getMinValue
+
+ /**
+ * Sets the minimum allowed value for the amount
+ *
+ * @param minValue The minimum allowed value
+ */
+ public void setMinValue(String minValue) {
+ if (minValue != null) {
+ this.minValue = (String)canonicalize(minValue.toUpperCase(), true);
+ }
+ } // end setMinValue()
+
+ /**
+ * Sets up maximum or minimum permissible value. The format is UUUmm.nn or mm.nn. If value
+ * is in UUUmm.nn format the currency code UUU is ignored and the default currency code or
+ * the supplied currency code is assumed.
+ *
+ * @param strInput The maximum or minimum amount, either in UUUmm.nn or mm.nn format
+ * @return formatted maximum or minimum value in mm.nn format
+ */
+ protected Object canonicalize(Object input, boolean isAttribute) {
+ if (input == null) {
+ return null;
+ }
+ String inputStr = (String) input;
+ try {
+ if (inputStr == null) {
+ return inputStr;
+ }
+ String newValue = null;
+
+ DecimalFormat df = new DecimalFormat("#.#");
+ java.util.Currency currency =
+ java.util.Currency.getInstance(getCurrencyCode());
+ df.setMaximumFractionDigits(currency.getDefaultFractionDigits());
+ df.setMinimumFractionDigits(currency.getDefaultFractionDigits());
+
+ if (Pattern.matches("[A-Za-z][A-Za-z][A-Za-z][0-9]*.?[0-9]*",
+ inputStr.toUpperCase())) {
+ String strCode = inputStr.toUpperCase().substring(0, 3);
+ if ((!isAttribute &&
+ (strCode.compareToIgnoreCase(currencyCode)) != 0)) {
+ throw new IllegalArgumentException("The required " +
+ "currency code of \"" + getId() + "\" and the" +
+ " entered currency code do not match.");
+ }
+ newValue = inputStr.toUpperCase().substring(3);
+ } else {
+ newValue = inputStr.toUpperCase();
+ }
+
+ Double valueDouble = new Double(newValue);
+ return df.format(valueDouble.doubleValue()).toUpperCase();
+ } catch (IndexOutOfBoundsException e) {
+ if (isAttribute) {
+ throw new IllegalArgumentException("An amount value \"" +
+ inputStr + "\" associated with currency RDC " + getId() +
+ "\" is not in proper format. The format is UUUmm.nn or mm.nn");
+ } else {
+ return null;
+ }
+ } catch (NullPointerException e) {
+ throw new IllegalArgumentException("Currency code of \"" +
+ getId() + "\" is null.");
+ } catch (NumberFormatException e) {
+ if (isAttribute) {
+ throw new IllegalArgumentException("An amount value \"" +
+ inputStr + "\" associated with currency RDC " + getId() +
+ "\" is not in proper format. The format is UUUmm.nn or mm.nn");
+ } else {
+ return null;
+ }
+ }
+
+ } // end normalize()
+
+ /**
+ * Validates the amount value against the given constraints
+ *
+ * @return TRUE if valid, FALSE otherwise
+ */
+ protected Boolean validate(Object newValue, boolean setErrorCode) {
+
+ Double val, maxVal, minVal;
+ val = new Double((String) value);
+ if (maxValue != null) {
+ maxVal = new Double(maxValue);
+ if (val.doubleValue() > maxVal.doubleValue()) {
+ if (setErrorCode) setErrorCode(ERR_NEED_LOWER_VALUE);
+ return Boolean.FALSE;
+ }
+ }
+ if (minValue != null) {
+ minVal = new Double(minValue);
+ if (val.doubleValue() < minVal.doubleValue()) {
+ if (setErrorCode) setErrorCode(ERR_NEED_HIGHER_VALUE);
+ return Boolean.FALSE;
+ }
+ }
+ return Boolean.TRUE;
+ } // end customValidate()
} // end class Currency{}
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org