antonio 2003/10/01 11:20:23
Modified: src/blocks/woody/java/org/apache/cocoon/woody/datatype/convertor
FormattingDecimalConvertor.java
src/blocks/woody/java/org/apache/cocoon/woody/datatype/validationruleimpl
RangeValidationRule.java
src/blocks/woody/conf woody-datatype.xconf
Added: src/blocks/woody/java/org/apache/cocoon/woody/datatype/typeimpl
IntegerTypeBuilder.java IntegerType.java
src/blocks/woody/java/org/apache/cocoon/woody/datatype/convertor
PlainIntegerConvertorBuilder.java
PlainIntegerConvertor.java
FormattingIntegerConvertor.java
FormattingIntegerConvertorBuilder.java
Log:
Adding integer support to Woody.
Revision Changes Path
1.1
cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/typeimpl/IntegerTypeBuilder.java
Index: IntegerTypeBuilder.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the
documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes
software
developed by the Apache Software Foundation
(http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself,
if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software
without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of
the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.woody.datatype.typeimpl;
import org.apache.cocoon.woody.datatype.*;
import org.w3c.dom.Element;
/**
* Builds [EMAIL PROTECTED] IntegerType}s.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Antonio Gallardo</a>
* @version CVS $Id: IntegerTypeBuilder.java,v 1.1 2003/10/01 18:20:23
antonio Exp $
*/
public class IntegerTypeBuilder extends AbstractDatatypeBuilder {
public Datatype build(Element datatypeElement, boolean arrayType,
DatatypeManager datatypeManager) throws Exception {
IntegerType type = new IntegerType();
type.setArrayType(arrayType);
type.setBuilder(this);
buildValidationRules(datatypeElement, type, datatypeManager);
buildConvertor(datatypeElement, type);
return type;
}
}
1.1
cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/typeimpl/IntegerType.java
Index: IntegerType.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.woody.datatype.typeimpl;
/**
* A [EMAIL PROTECTED] org.apache.cocoon.woody.datatype.Datatype Datatype}
implementation
* for whole numbers.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Antonio Gallardo</a>
* @version CVS $Id: IntegerType.java,v 1.1 2003/10/01 18:20:23 antonio Exp $
*/
public class IntegerType extends AbstractDatatype {
public Class getTypeClass() {
return Integer.class;
}
public String getDescriptiveName() {
return "integer";
}
}
1.2 +2 -0
cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/convertor/FormattingDecimalConvertor.java
Index: FormattingDecimalConvertor.java
===================================================================
RCS file:
/home/cvs//cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/convertor/FormattingDecimalConvertor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FormattingDecimalConvertor.java 25 Jul 2003 16:21:31 -0000 1.1
+++ FormattingDecimalConvertor.java 1 Oct 2003 18:20:23 -0000 1.2
@@ -103,6 +103,8 @@
Number decimalValue = decimalFormat.parse(value);
if (decimalValue instanceof BigDecimal)
;
+ else if (decimalValue instanceof Integer)
+ decimalValue = new BigDecimal(decimalValue
.intValue());
else if (decimalValue instanceof Long)
decimalValue = new BigDecimal(decimalValue.longValue());
else if (decimalValue instanceof Double)
1.1
cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/convertor/PlainIntegerConvertorBuilder.java
Index: PlainIntegerConvertorBuilder.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.woody.datatype.convertor;
import org.w3c.dom.Element;
/**
* Builds [EMAIL PROTECTED] PlainIntegerConvertor}s.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Antonio Gallardo</a>
* @version CVS $Id: PlainIntegerConvertorBuilder.java,v 1.1 2003/10/01
18:20:23 antonio Exp $
*/
public class PlainIntegerConvertorBuilder implements ConvertorBuilder {
public Convertor build(Element configElement) throws Exception {
return new PlainIntegerConvertor();
}
}
1.1
cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/convertor/PlainIntegerConvertor.java
Index: PlainIntegerConvertor.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.woody.datatype.convertor;
import java.util.Locale;
/**
* Convertor for java.lang.Integers that does not do any (Locale-dependent)
* formatting. It simply uses String.valueOf() and Long.parseLong().
*
* @author <a href="mailto:[EMAIL PROTECTED]">Antonio Gallardo</a>
* @version CVS $Id: PlainIntegerConvertor.java,v 1.1 2003/10/01 18:20:23
antonio Exp $
*/
public class PlainIntegerConvertor implements Convertor {
public Object convertFromString(String value, Locale locale,
Convertor.FormatCache formatCache) {
try {
return new Integer(Integer.parseInt(value));
} catch (NumberFormatException e) {
return null;
}
}
public String convertToString(Object value, Locale locale,
Convertor.FormatCache formatCache) {
return String.valueOf(value);
}
public Class getTypeClass() {
return Integer.class;
}
}
1.1
cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/convertor/FormattingIntegerConvertor.java
Index: FormattingIntegerConvertor.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.woody.datatype.convertor;
import org.outerj.i18n.DecimalFormat;
import java.util.Locale;
import java.text.ParseException;
/**
* A Convertor for [EMAIL PROTECTED] Integer}s backed by the
* [EMAIL PROTECTED] java.text.DecimalFormat DecimalFormat} class.
*
* <p>This class is mostly the same as the [EMAIL PROTECTED]
FormattingDecimalConvertor},
* so see there for more information.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Antonio Gallardo</a>
* @version CVS $Id: FormattingIntegerConvertor.java,v 1.1 2003/10/01
18:20:23 antonio Exp $
*/
public class FormattingIntegerConvertor extends FormattingDecimalConvertor {
public FormattingIntegerConvertor() {
super();
}
public Object convertFromString(String value, Locale locale,
Convertor.FormatCache formatCache) {
DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);
try {
Number decimalValue = decimalFormat.parse(value);
if (decimalValue instanceof Integer)
return decimalValue;
else
return new Integer(decimalValue.intValue());
} catch (ParseException e) {
return null;
}
}
protected int getDefaultVariant() {
return INTEGER;
}
public Class getTypeClass() {
return Integer.class;
}
}
1.1
cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/convertor/FormattingIntegerConvertorBuilder.java
Index: FormattingIntegerConvertorBuilder.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.woody.datatype.convertor;
/**
* Builds [EMAIL PROTECTED] FormattingIntegerConvertor}s.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Antonio Gallardo</a>
* @version CVS $Id: FormattingIntegerConvertorBuilder.java,v 1.1 2003/10/01
18:20:23 antonio Exp $
*/
public class FormattingIntegerConvertorBuilder extends
FormattingDecimalConvertorBuilder {
protected FormattingDecimalConvertor createConvertor() {
return new FormattingIntegerConvertor();
}
}
1.3 +16 -9
cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/validationruleimpl/RangeValidationRule.java
Index: RangeValidationRule.java
===================================================================
RCS file:
/home/cvs//cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/validationruleimpl/RangeValidationRule.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RangeValidationRule.java 26 Jun 2003 09:11:24 -0000 1.2
+++ RangeValidationRule.java 1 Oct 2003 18:20:23 -0000 1.3
@@ -58,7 +58,7 @@
import java.math.BigDecimal;
/**
- * Checks numeric ranges. Works both for Long and BigDecimal values.
+ * Checks numeric ranges. Works for Integer, Long and BigDecimal values.
*
* <p>This validation rule can perform 3 different checks:
* <ul>
@@ -69,7 +69,12 @@
*/
public class RangeValidationRule extends AbstractValidationRule {
private Expression minExpr;
- private Expression maxExpr;
+ private Expression maxExpr;
+
+ private static final String RANGE_ELEM = "range";
+ private static final String MIN_ATTR = "min";
+ private static final String MAX_ATTR = "max";
+
public void setMinExpr(Expression minExpr) {
this.minExpr = minExpr;
@@ -81,20 +86,22 @@
public ValidationError validate(Object value, ExpressionContext
expressionContext) {
BigDecimal decimal = null;
- if (value instanceof Long)
- decimal = new BigDecimal(((Long) value).longValue());
+ if (value instanceof Integer)
+ decimal = new BigDecimal(((Integer) value).intValue());
+ else if (value instanceof Long)
+ decimal = new BigDecimal(((Long) value).longValue());
else
decimal = (BigDecimal) value;
if (minExpr != null && maxExpr != null) {
- Object result = evaluateNumeric(minExpr, expressionContext,
"min", "range");
+ Object result = evaluateNumeric(minExpr, expressionContext,
MIN_ATTR, RANGE_ELEM);
if (result instanceof ValidationError)
return (ValidationError) result;
else if (result instanceof CannotYetResolveWarning)
return null;
BigDecimal min = (BigDecimal) result;
- result = evaluateNumeric(maxExpr, expressionContext, "max",
"range");
+ result = evaluateNumeric(maxExpr, expressionContext, MAX_ATTR,
RANGE_ELEM);
if (result instanceof ValidationError)
return (ValidationError) result;
else if (result instanceof CannotYetResolveWarning)
@@ -105,7 +112,7 @@
return hasFailMessage() ? getFailMessage() : new
ValidationError("validation.numeric.range", new String[]{min.toString(),
max.toString()});
return null;
} else if (minExpr != null) {
- Object result = evaluateNumeric(minExpr, expressionContext,
"min", "range");
+ Object result = evaluateNumeric(minExpr, expressionContext,
MIN_ATTR, RANGE_ELEM);
if (result instanceof ValidationError)
return (ValidationError) result;
else if (result instanceof CannotYetResolveWarning)
@@ -115,7 +122,7 @@
return hasFailMessage() ? getFailMessage() : new
ValidationError("validation.numeric.min", new String[]{min.toString()});
return null;
} else if (maxExpr != null) {
- Object result = evaluateNumeric(maxExpr, expressionContext,
"max", "range");
+ Object result = evaluateNumeric(maxExpr, expressionContext,
MAX_ATTR, RANGE_ELEM);
if (result instanceof ValidationError)
return (ValidationError) result;
else if (result instanceof CannotYetResolveWarning)
@@ -129,6 +136,6 @@
}
public boolean supportsType(Class clazz, boolean arrayType) {
- return (clazz.isAssignableFrom(Long.class) ||
clazz.isAssignableFrom(BigDecimal.class)) && !arrayType;
+ return (clazz.isAssignableFrom(Integer.class) ||
clazz.isAssignableFrom(Long.class) || clazz.isAssignableFrom(BigDecimal.class))
&& !arrayType;
}
}
1.4 +7 -1 cocoon-2.1/src/blocks/woody/conf/woody-datatype.xconf
Index: woody-datatype.xconf
===================================================================
RCS file: /home/cvs//cocoon-2.1/src/blocks/woody/conf/woody-datatype.xconf,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- woody-datatype.xconf 12 Aug 2003 12:57:47 -0000 1.3
+++ woody-datatype.xconf 1 Oct 2003 18:20:23 -0000 1.4
@@ -33,7 +33,13 @@
<convertors default="plain" plain="plain">
<convertor name="plain"
src="org.apache.cocoon.woody.datatype.convertor.PlainBooleanConvertorBuilder"/>
</convertors>
- </datatype>
+ </datatype>
+ <datatype name="integer"
src="org.apache.cocoon.woody.datatype.typeimpl.IntegerTypeBuilder">
+ <convertors default="formatting" plain="plain">
+ <convertor name="plain"
src="org.apache.cocoon.woody.datatype.convertor.PlainIntegerConvertorBuilder"/>
+ <convertor name="formatting"
src="org.apache.cocoon.woody.datatype.convertor.FormattingIntegerConvertorBuilder"/>
+ </convertors>
+ </datatype>
</datatypes>
<validation-rules>
<validation-rule name="length"
src="org.apache.cocoon.woody.datatype.validationruleimpl.LengthValidationRuleBuilder"/>