You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by jh...@apache.org on 2005/11/03 15:00:48 UTC
svn commit: r330548 [90/132] - in
/cocoon/whiteboard/maven2/cocoon-flat-layout: ./ cocoon-ajax-block/
cocoon-ajax-block/api/ cocoon-ajax-block/api/src/
cocoon-ajax-block/api/src/main/ cocoon-ajax-block/api/src/main/java/
cocoon-ajax-block/api/src/main/...
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingDoubleConvertorBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingDoubleConvertorBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingDoubleConvertorBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingDoubleConvertorBuilder.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,27 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+/**
+ * Builds {@link FormattingDoubleConvertor}s.
+ *
+ * @version $Id: FormattingDoubleConvertorBuilder.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class FormattingDoubleConvertorBuilder extends FormattingDecimalConvertorBuilder {
+ protected FormattingDecimalConvertor createConvertor() {
+ return new FormattingDoubleConvertor();
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingDoubleConvertorBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingFloatConvertor.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingFloatConvertor.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingFloatConvertor.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingFloatConvertor.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,55 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import java.util.Locale;
+import java.text.DecimalFormat;
+import java.text.ParseException;
+
+/**
+ * A Convertor for {@link Float}s backed by the
+ * {@link java.text.DecimalFormat DecimalFormat} class.
+ *
+ * <p>This class is mostly the same as the {@link FormattingDecimalConvertor},
+ * so see there for more information.
+ *
+ * @version $Id: FormattingFloatConvertor.java 157080 2005-03-11 14:04:07Z sylvain $
+ */
+public class FormattingFloatConvertor extends FormattingDecimalConvertor {
+
+ public FormattingFloatConvertor() {
+ super();
+ }
+
+ public ConversionResult convertFromString(String value, Locale locale, Convertor.FormatCache formatCache) {
+ // Some locales (e.g. "fr") produce non-breaking spaces sent back as space by the browser
+ value = value.replace(' ', (char)160);
+ DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);
+ try {
+ Number decimalValue = decimalFormat.parse(value);
+ if (decimalValue instanceof Float)
+ return new ConversionResult(decimalValue);
+ else
+ return new ConversionResult(new Float(decimalValue.floatValue()));
+ } catch (ParseException e) {
+ return ConversionResult.create("float");
+ }
+ }
+
+ public Class getTypeClass() {
+ return Float.class;
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingFloatConvertor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingFloatConvertorBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingFloatConvertorBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingFloatConvertorBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingFloatConvertorBuilder.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,27 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+/**
+ * Builds {@link FormattingFloatConvertor}s.
+ *
+ * @version $Id: FormattingFloatConvertorBuilder.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class FormattingFloatConvertorBuilder extends FormattingDecimalConvertorBuilder {
+ protected FormattingDecimalConvertor createConvertor() {
+ return new FormattingFloatConvertor();
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingFloatConvertorBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingIntegerConvertor.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingIntegerConvertor.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingIntegerConvertor.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingIntegerConvertor.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,60 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import java.util.Locale;
+import java.text.DecimalFormat;
+import java.text.ParseException;
+
+/**
+ * A Convertor for {@link Integer}s backed by the
+ * {@link java.text.DecimalFormat DecimalFormat} class.
+ *
+ * <p>This class is mostly the same as the {@link FormattingDecimalConvertor},
+ * so see there for more information.
+ *
+ * @author <a href="mailto:antonio@apache.org">Antonio Gallardo</a>
+ * @version $Id: FormattingIntegerConvertor.java 157080 2005-03-11 14:04:07Z sylvain $
+*/
+public class FormattingIntegerConvertor extends FormattingDecimalConvertor {
+
+ public FormattingIntegerConvertor() {
+ super();
+ }
+
+ public ConversionResult convertFromString(String value, Locale locale, Convertor.FormatCache formatCache) {
+ // Some locales (e.g. "fr") produce non-breaking spaces sent back as space by the browser
+ value = value.replace(' ', (char)160);
+ DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);
+ try {
+ Number decimalValue = decimalFormat.parse(value);
+ if (decimalValue instanceof Integer)
+ return new ConversionResult(decimalValue);
+ else
+ return new ConversionResult(new Integer(decimalValue.intValue()));
+ } catch (ParseException e) {
+ return ConversionResult.create("integer");
+ }
+ }
+
+ protected int getDefaultVariant() {
+ return INTEGER;
+ }
+
+ public Class getTypeClass() {
+ return Integer.class;
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingIntegerConvertor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingIntegerConvertorBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingIntegerConvertorBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingIntegerConvertorBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingIntegerConvertorBuilder.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,28 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+/**
+ * Builds {@link FormattingIntegerConvertor}s.
+ *
+ * @author <a href="mailto:antonio@apache.org">Antonio Gallardo</a>
+ * @version $Id: FormattingIntegerConvertorBuilder.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class FormattingIntegerConvertorBuilder extends FormattingDecimalConvertorBuilder {
+ protected FormattingDecimalConvertor createConvertor() {
+ return new FormattingIntegerConvertor();
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingIntegerConvertorBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingLongConvertor.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingLongConvertor.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingLongConvertor.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingLongConvertor.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,59 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import java.util.Locale;
+import java.text.DecimalFormat;
+import java.text.ParseException;
+
+/**
+ * A Convertor for {@link Long}s backed by the
+ * {@link java.text.DecimalFormat DecimalFormat} class.
+ *
+ * <p>This class is mostly the same as the {@link FormattingDecimalConvertor},
+ * so see there for more information.
+ *
+ * @version $Id: FormattingLongConvertor.java 157080 2005-03-11 14:04:07Z sylvain $
+ */
+public class FormattingLongConvertor extends FormattingDecimalConvertor {
+
+ public FormattingLongConvertor() {
+ super();
+ }
+
+ public ConversionResult convertFromString(String value, Locale locale, Convertor.FormatCache formatCache) {
+ // Some locales (e.g. "fr") produce non-breaking spaces sent back as space by the browser
+ value = value.replace(' ', (char)160);
+ DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);
+ try {
+ Number decimalValue = decimalFormat.parse(value);
+ if (decimalValue instanceof Long)
+ return new ConversionResult(decimalValue);
+ else
+ return new ConversionResult(new Long(decimalValue.longValue()));
+ } catch (ParseException e) {
+ return ConversionResult.create("long");
+ }
+ }
+
+ protected int getDefaultVariant() {
+ return INTEGER;
+ }
+
+ public Class getTypeClass() {
+ return Long.class;
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingLongConvertor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingLongConvertorBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingLongConvertorBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingLongConvertorBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingLongConvertorBuilder.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,27 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+/**
+ * Builds {@link FormattingLongConvertor}s.
+ *
+ * @version $Id: FormattingLongConvertorBuilder.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class FormattingLongConvertorBuilder extends FormattingDecimalConvertorBuilder {
+ protected FormattingDecimalConvertor createConvertor() {
+ return new FormattingLongConvertor();
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/FormattingLongConvertorBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertor.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertor.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertor.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertor.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2004 Outerthought bvba and Schaubroeck nv
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import org.apache.cocoon.forms.datatype.convertor.Convertor;
+import org.apache.cocoon.forms.datatype.convertor.ConversionResult;
+import org.apache.cocoon.forms.validation.ValidationError;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.outerj.daisy.htmlcleaner.HtmlCleanerTemplate;
+import org.outerj.daisy.htmlcleaner.HtmlCleaner;
+
+import java.util.Locale;
+
+/**
+ * A CForms convertor doing string-to-string conversion by utilizing
+ * the Daisy HtmlCleaner component.
+ */
+public class HtmlCleaningConvertor implements Convertor {
+ HtmlCleanerTemplate template;
+
+ public HtmlCleaningConvertor(HtmlCleanerTemplate template) {
+ this.template = template;
+ }
+
+ public ConversionResult convertFromString(String value, Locale locale, Convertor.FormatCache formatCache) {
+ HtmlCleaner cleaner = template.newHtmlCleaner();
+ try {
+ String result = cleaner.cleanToString(value);
+ return new ConversionResult(result);
+ } catch (Exception e) {
+ Throwable t = ExceptionUtils.getRootCause(e);
+ if (t == null)
+ t = e;
+ String message = t.getMessage();
+ if (message == null)
+ message = t.toString();
+ ValidationError validationError = new ValidationError(message, false);
+ return new ConversionResult(validationError);
+ }
+ }
+
+ public String convertToString(Object object, Locale locale, Convertor.FormatCache formatCache) {
+ return (String)object;
+ }
+
+ public Class getTypeClass() {
+ return java.lang.String.class;
+ }
+
+ public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
+ // nothing to say about me
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertorBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertorBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertorBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertorBuilder.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2004 Outerthought bvba and Schaubroeck nv
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import org.apache.cocoon.forms.datatype.convertor.ConvertorBuilder;
+import org.apache.cocoon.forms.datatype.convertor.Convertor;
+import org.apache.cocoon.forms.util.DomHelper;
+import org.apache.cocoon.forms.CacheManager;
+import org.apache.cocoon.components.source.SourceUtil;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.excalibur.source.Source;
+import org.w3c.dom.Element;
+import org.outerj.daisy.htmlcleaner.HtmlCleanerTemplate;
+import org.outerj.daisy.htmlcleaner.HtmlCleanerFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Builds {@link HtmlCleaningConvertor}s.
+ */
+public class HtmlCleaningConvertorBuilder implements ConvertorBuilder, Serviceable {
+ private ServiceManager serviceManager;
+
+ public void service(ServiceManager serviceManager) throws ServiceException {
+ this.serviceManager = serviceManager;
+ }
+
+ public Convertor build(Element element) throws Exception {
+ String config = DomHelper.getAttribute(element, "config");
+
+ Source source = null;
+ SourceResolver sourceResolver = null;
+ CacheManager cacheManager = null;
+ try {
+ cacheManager = (CacheManager)serviceManager.lookup(CacheManager.ROLE);
+ sourceResolver = (SourceResolver)serviceManager.lookup(SourceResolver.ROLE);
+ source = sourceResolver.resolveURI(config);
+
+ String prefix = HtmlCleanerTemplate.class.getName();
+ HtmlCleanerTemplate template = (HtmlCleanerTemplate)cacheManager.get(source, prefix);
+ if (template == null) {
+ HtmlCleanerFactory factory = new HtmlCleanerFactory();
+ InputSource is = SourceUtil.getInputSource(source);
+ template = factory.buildTemplate(is);
+ cacheManager.set(template, source, prefix);
+ }
+
+ return new HtmlCleaningConvertor(template);
+ } finally {
+ if (source != null)
+ sourceResolver.release(source);
+ if (sourceResolver != null)
+ serviceManager.release(sourceResolver);
+ if (cacheManager != null)
+ serviceManager.release(cacheManager);
+ }
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertorBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/Icu4jDateConvertor.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/Icu4jDateConvertor.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/Icu4jDateConvertor.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/Icu4jDateConvertor.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,163 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import java.text.ParseException;
+import java.util.Date;
+import java.util.Locale;
+
+import org.apache.cocoon.forms.FormsConstants;
+import org.apache.cocoon.xml.AttributesImpl;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+import com.ibm.icu.text.DateFormat;
+import com.ibm.icu.text.SimpleDateFormat;
+
+/**
+ * A Convertor for {@link java.util.Date Date} objects backed by ICU4J's
+ * {@link com.ibm.icu.text.SimpleDateFormat} class.
+ *
+ * <p>It can be configured to use one of three <strong>variants</strong>: date,
+ * time or datetime and one of four <strong>styles</strong>: long, full, medium or short.
+ *
+ * <p>Alternatively, a <strong>formatting pattern</strong> can be used. This can either be a locale-dependent
+ * or locale-independent formatting pattern. When looking up a formatting pattern, a mechansim
+ * similar to resource bundle lookup is used. Suppose the locale is nl-BE, then first a formatting
+ * pattern for nl-BE will be sought, then one for nl, and if that is not
+ * found, finally the locale-independent formatting pattern will be used.
+ *
+ * @version $Id: Icu4jDateConvertor.java 326838 2005-10-20 06:26:53Z sylvain $
+ */
+public class Icu4jDateConvertor implements Convertor {
+ //FIXME: the only difference of this class with FormattingDateConvertor is the use of com.ibm.icu.text.SimpleDateFormat
+ // --> refactor to have it extend FormattingDateConvertor
+
+ /** See {@link #setStyle}. */
+ private int style;
+ /** See {@link #setVariant}. */
+ private String variant;
+ /** Locale-specific formatting patterns. */
+ private LocaleMap localizedPatterns;
+ /** Non-locale specific formatting pattern. */
+ private String nonLocalizedPattern;
+
+ public static final String DATE = "date";
+ public static final String TIME = "time";
+ public static final String DATE_TIME = "datetime";
+
+ public Icu4jDateConvertor() {
+ this.style = DateFormat.SHORT;
+ this.variant = DATE;
+ this.localizedPatterns = new LocaleMap();
+ }
+
+ public ConversionResult convertFromString(String value, Locale locale, Convertor.FormatCache formatCache) {
+ SimpleDateFormat dateFormat = getDateFormat(locale, formatCache);
+ try {
+ return new ConversionResult(dateFormat.parse(value));
+ } catch (ParseException e) {
+ return ConversionResult.create("date." + this.variant);
+ }
+ }
+
+ public String convertToString(Object value, Locale locale, Convertor.FormatCache formatCache) {
+ SimpleDateFormat dateFormat = getDateFormat(locale, formatCache);
+ return dateFormat.format((Date)value);
+ }
+
+ private final SimpleDateFormat getDateFormat(Locale locale, Convertor.FormatCache formatCache) {
+ SimpleDateFormat dateFormat = null;
+ if (formatCache != null)
+ dateFormat = (SimpleDateFormat)formatCache.get();
+ if (dateFormat == null) {
+ dateFormat = getDateFormat(locale);
+ if (formatCache != null)
+ formatCache.store(dateFormat);
+ }
+ return dateFormat;
+ }
+
+ protected SimpleDateFormat getDateFormat(Locale locale) {
+ SimpleDateFormat dateFormat = null;
+
+ if (this.variant.equals(DATE)) {
+ //dateFormat = I18nSupport.getInstance().getDateFormat(style, locale);
+ dateFormat = (SimpleDateFormat)DateFormat.getDateInstance(style, locale);
+ } else if (this.variant.equals(TIME)) {
+ //dateFormat = I18nSupport.getInstance().getTimeFormat(style, locale);
+ dateFormat = (SimpleDateFormat)DateFormat.getTimeInstance(style, locale);
+ } else if (this.variant.equals(DATE_TIME)) {
+ //dateFormat = I18nSupport.getInstance().getDateTimeFormat(style, style, locale);
+ dateFormat = (SimpleDateFormat)DateFormat.getDateTimeInstance(style, style, locale);
+ }
+
+ String pattern = (String)localizedPatterns.get(locale);
+
+ if (pattern != null)
+ // Note: this was previously using applyLocalizedPattern() which allows to use
+ // a locale-specific pattern syntax, e.g. in french "j" (jour) for "d" and
+ // "a" (annee) for "y". But the localized pattern syntax is very little known and thus
+ // led to some weird pattern syntax error messages.
+ dateFormat.applyPattern(pattern);
+ else if (nonLocalizedPattern != null)
+ dateFormat.applyPattern(nonLocalizedPattern);
+
+ return dateFormat;
+ }
+
+ public Class getTypeClass() {
+ return Date.class;
+ }
+
+ /**
+ *
+ * @param style one of the constants FULL, LONG, MEDIUM or SHORT defined in the {@link Date} class.
+ */
+ public void setStyle(int style) {
+ this.style = style;
+ }
+
+ public void setVariant(String variant) {
+ if (DATE.equals(variant) || TIME.equals(variant) || DATE_TIME.equals(variant)) {
+ this.variant = variant;
+ } else {
+ throw new IllegalArgumentException("Invalid value for variant parameter.");
+ }
+ }
+
+ public void addFormattingPattern(Locale locale, String pattern) {
+ localizedPatterns.put(locale, pattern);
+ }
+
+ public void setNonLocalizedPattern(String pattern) {
+ this.nonLocalizedPattern = pattern;
+ }
+
+ private static final String CONVERTOR_EL = "convertor";
+
+ public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
+ String pattern = getDateFormat(locale).toPattern();
+
+ if (pattern != null) {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addCDATAAttribute("pattern", pattern);
+ attrs.addCDATAAttribute("variant", this.variant);
+ contentHandler.startElement(FormsConstants.INSTANCE_NS, CONVERTOR_EL, FormsConstants.INSTANCE_PREFIX_COLON + CONVERTOR_EL, attrs);
+ contentHandler.endElement(FormsConstants.INSTANCE_NS, CONVERTOR_EL, FormsConstants.INSTANCE_PREFIX_COLON + CONVERTOR_EL);
+ }
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/Icu4jDateConvertor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/Icu4jDateConvertorBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/Icu4jDateConvertorBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/Icu4jDateConvertorBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/Icu4jDateConvertorBuilder.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,83 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import java.util.Locale;
+
+import org.apache.cocoon.forms.FormsConstants;
+import org.apache.cocoon.forms.util.DomHelper;
+import org.apache.cocoon.i18n.I18nUtils;
+import org.w3c.dom.Element;
+
+import com.ibm.icu.text.DateFormat;
+
+/**
+ * Builds {@link Icu4jDateConvertor}s.
+ *
+ * @version $Id: Icu4jDateConvertorBuilder.java 326838 2005-10-20 06:26:53Z sylvain $
+ */
+public class Icu4jDateConvertorBuilder implements ConvertorBuilder {
+ public Convertor build(Element configElement) throws Exception {
+ Icu4jDateConvertor convertor = new Icu4jDateConvertor();
+
+ if (configElement == null)
+ return convertor;
+
+ String style = configElement.getAttribute("style");
+ if (!style.equals("")) {
+ if (style.equals("short"))
+ convertor.setStyle(DateFormat.SHORT);
+ else if (style.equals("medium"))
+ convertor.setStyle(DateFormat.MEDIUM);
+ else if (style.equals("long"))
+ convertor.setStyle(DateFormat.LONG);
+ else if (style.equals("full"))
+ convertor.setStyle(DateFormat.FULL);
+ else
+ throw new Exception("Invalid value \"" + style + "\" for style attribute at " + DomHelper.getLocation(configElement));
+ }
+
+ String variant = configElement.getAttribute("variant");
+ if (!variant.equals("")) {
+ if (variant.equals(Icu4jDateConvertor.DATE) ||
+ variant.equals(Icu4jDateConvertor.TIME) ||
+ variant.equals(Icu4jDateConvertor.DATE_TIME)) {
+ convertor.setVariant(variant);
+ } else {
+ throw new Exception("Invalid value \"" + variant + "\" for variant attribute at " + DomHelper.getLocation(configElement));
+ }
+ }
+
+ Element patternsEl = DomHelper.getChildElement(configElement, FormsConstants.DEFINITION_NS, "patterns", false);
+ if (patternsEl != null) {
+ Element patternEl[] = DomHelper.getChildElements(patternsEl, FormsConstants.DEFINITION_NS, "pattern");
+ for (int i = 0; i < patternEl.length; i++) {
+ String locale = patternEl[i].getAttribute("locale");
+ String pattern = DomHelper.getElementText(patternEl[i]);
+ if (pattern.equals(""))
+ throw new Exception("pattern element does not contain any content at " + DomHelper.getLocation(patternEl[i]));
+ if (locale.equals(""))
+ convertor.setNonLocalizedPattern(pattern);
+ else {
+ Locale loc = I18nUtils.parseLocale(locale);
+ convertor.addFormattingPattern(loc, pattern);
+ }
+ }
+ }
+
+ return convertor;
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/Icu4jDateConvertorBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/LocaleMap.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/LocaleMap.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/LocaleMap.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/LocaleMap.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,95 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import org.apache.commons.collections.FastHashMap;
+
+import java.util.Locale;
+
+/**
+ * Map using Locale objects as keys.
+ *
+ * <p>This map should be filled once using calls to {@link #put(Locale, Object)},
+ * before any calls are made to {@link #get(Locale)}.
+ *
+ * @version $Id: LocaleMap.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class LocaleMap {
+ private FastHashMap map = new FastHashMap();
+
+ /**
+ * Gets an object based on the given locale. An automatic fallback mechanism is used:
+ * if nothing is found for language-COUNTRY-variant, then language-COUNTRY is searched,
+ * the language, and finally "" (empty string). If nothing is found null is returned.
+ */
+ public Object get(Locale locale) {
+ if (map.size() == 0)
+ return null;
+
+ String full = getFullKey(locale);
+
+ if (!map.containsKey(full)) {
+ // check more general variant (lang-COUNTRY and lang), and store result in the map
+ // under the full key, so that next time we have a direct hit
+ String altKey = locale.getLanguage() + '-' + locale.getCountry();
+ Object object = map.get(altKey);
+ if (object != null) {
+ map.put(full, object);
+ return object;
+ }
+
+ altKey = locale.getLanguage();
+ object = map.get(altKey);
+ if (object != null) {
+ map.put(full, object);
+ return object;
+ }
+
+ object = map.get("");
+ if (object != null) {
+ map.put(full, object);
+ return object;
+ }
+
+ map.put(full, null);
+ }
+
+ return map.get(full);
+ }
+
+ private final String getFullKey(Locale locale) {
+ return locale.getLanguage() + '-' + locale.getCountry() + '-' + locale.getVariant();
+ }
+
+ private final String getKey(Locale locale) {
+ boolean hasLanguage = !locale.getLanguage().equals("");
+ boolean hasCountry = !locale.getCountry().equals("");
+ boolean hasVariant = !locale.getVariant().equals("");
+
+ if (hasLanguage && hasCountry && hasVariant)
+ return locale.getLanguage() + '-' + locale.getCountry() + '-' + locale.getVariant();
+ else if (hasLanguage && hasCountry)
+ return locale.getLanguage() + '-' + locale.getCountry();
+ else if (hasLanguage)
+ return locale.getLanguage();
+ else
+ return "";
+ }
+
+ public void put(Locale locale, Object object) {
+ map.put(getKey(locale), object);
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/LocaleMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/MillisDateConvertor.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/MillisDateConvertor.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/MillisDateConvertor.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/MillisDateConvertor.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,52 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+import java.util.Locale;
+import java.util.Date;
+
+/**
+ * A Convertor for Date objects which uses the number of milliseconds since
+ * January 1, 1970, 00:00:00 GMT as string representation.
+ *
+ * @version $Id: MillisDateConvertor.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class MillisDateConvertor implements Convertor {
+ public ConversionResult convertFromString(String value, Locale locale, Convertor.FormatCache formatCache) {
+ try {
+ long date = Long.parseLong(value);
+ return new ConversionResult(new Date(date));
+ } catch (NumberFormatException e) {
+ return ConversionResult.create("date");
+ }
+ }
+
+ public String convertToString(Object value, Locale locale, Convertor.FormatCache formatCache) {
+ Date date = (Date)value;
+ return String.valueOf(date.getTime());
+ }
+
+ public Class getTypeClass() {
+ return Date.class;
+ }
+
+ public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
+ // intentionally empty
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/MillisDateConvertor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/MillisDateConvertorBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/MillisDateConvertorBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/MillisDateConvertorBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/MillisDateConvertorBuilder.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,29 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import org.w3c.dom.Element;
+
+/**
+ * Builds {@link MillisDateConvertor}s.
+ *
+ * @version $Id: MillisDateConvertorBuilder.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class MillisDateConvertorBuilder implements ConvertorBuilder {
+ public Convertor build(Element configElement) {
+ return new MillisDateConvertor();
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/MillisDateConvertorBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainBooleanConvertor.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainBooleanConvertor.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainBooleanConvertor.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainBooleanConvertor.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,44 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+import java.util.Locale;
+
+/**
+ * Convertor for java.lang.Boolean's.
+ *
+ * @version $Id: PlainBooleanConvertor.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class PlainBooleanConvertor implements Convertor {
+ public ConversionResult convertFromString(String value, Locale locale, Convertor.FormatCache formatCache) {
+ return new ConversionResult(Boolean.valueOf(value));
+ }
+
+ public String convertToString(Object value, Locale locale, Convertor.FormatCache formatCache) {
+ return value.toString();
+ }
+
+ public Class getTypeClass() {
+ return Boolean.class;
+ }
+
+ public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
+ // intentionally empty
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainBooleanConvertor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainBooleanConvertorBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainBooleanConvertorBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainBooleanConvertorBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainBooleanConvertorBuilder.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,29 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import org.w3c.dom.Element;
+
+/**
+ * Builds {PlainBooleanConvertor}s.
+ *
+ * @version $Id: PlainBooleanConvertorBuilder.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class PlainBooleanConvertorBuilder implements ConvertorBuilder {
+ public Convertor build(Element configElement) throws Exception {
+ return new PlainBooleanConvertor();
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainBooleanConvertorBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainDecimalConvertor.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainDecimalConvertor.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainDecimalConvertor.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainDecimalConvertor.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,50 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+import java.util.Locale;
+import java.math.BigDecimal;
+
+/**
+ * Convertor for {@link java.math.BigDecimal}s that does not do any
+ * (locale-dependent) formatting.
+ *
+ * @version $Id: PlainDecimalConvertor.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class PlainDecimalConvertor implements Convertor {
+ public ConversionResult convertFromString(String value, Locale locale, Convertor.FormatCache formatCache) {
+ try {
+ return new ConversionResult(new BigDecimal(value));
+ } catch (NumberFormatException e) {
+ return ConversionResult.create("decimal");
+ }
+ }
+
+ public String convertToString(Object value, Locale locale, Convertor.FormatCache formatCache) {
+ return value.toString();
+ }
+
+ public Class getTypeClass() {
+ return BigDecimal.class;
+ }
+
+ public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
+ // intentionally empty
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainDecimalConvertor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainDecimalConvertorBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainDecimalConvertorBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainDecimalConvertorBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainDecimalConvertorBuilder.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,28 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import org.w3c.dom.Element;
+
+/**
+ *
+ * @version $Id: PlainDecimalConvertorBuilder.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class PlainDecimalConvertorBuilder implements ConvertorBuilder {
+ public Convertor build(Element configElement) throws Exception {
+ return new PlainDecimalConvertor();
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainDecimalConvertorBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainDoubleConvertor.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainDoubleConvertor.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainDoubleConvertor.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainDoubleConvertor.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,49 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+import java.util.Locale;
+
+/**
+ * Convertor for java.lang.Doubles that does not do any (Locale-dependent)
+ * formatting. It simply uses String.valueOf() and Long.parseLong().
+ *
+ * @version $Id: PlainDoubleConvertor.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class PlainDoubleConvertor implements Convertor {
+ public ConversionResult convertFromString(String value, Locale locale, Convertor.FormatCache formatCache) {
+ try {
+ return new ConversionResult(new Double(Double.parseDouble(value)));
+ } catch (NumberFormatException e) {
+ return ConversionResult.create("double");
+ }
+ }
+
+ public String convertToString(Object value, Locale locale, Convertor.FormatCache formatCache) {
+ return String.valueOf(value);
+ }
+
+ public Class getTypeClass() {
+ return Double.class;
+ }
+
+ public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
+ // intentionally empty
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainDoubleConvertor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainDoubleConvertorBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainDoubleConvertorBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainDoubleConvertorBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainDoubleConvertorBuilder.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,28 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import org.w3c.dom.Element;
+
+/**
+ *
+ * @version $Id: PlainDoubleConvertorBuilder.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class PlainDoubleConvertorBuilder implements ConvertorBuilder {
+ public Convertor build(Element configElement) throws Exception {
+ return new PlainDoubleConvertor();
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainDoubleConvertorBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainFloatConvertor.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainFloatConvertor.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainFloatConvertor.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainFloatConvertor.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,49 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+import java.util.Locale;
+
+/**
+ * Convertor for {@link Float}s that does not do any (locale-dependent)
+ * formatting.
+ *
+ * @version $Id: PlainFloatConvertor.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class PlainFloatConvertor implements Convertor {
+ public ConversionResult convertFromString(String value, Locale locale, Convertor.FormatCache formatCache) {
+ try {
+ return new ConversionResult(new Float(value));
+ } catch (NumberFormatException e) {
+ return ConversionResult.create("float");
+ }
+ }
+
+ public String convertToString(Object value, Locale locale, Convertor.FormatCache formatCache) {
+ return value.toString();
+ }
+
+ public Class getTypeClass() {
+ return Float.class;
+ }
+
+ public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
+ // intentionally empty
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainFloatConvertor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainFloatConvertorBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainFloatConvertorBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainFloatConvertorBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainFloatConvertorBuilder.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,28 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import org.w3c.dom.Element;
+
+/**
+ *
+ * @version $Id: PlainFloatConvertorBuilder.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class PlainFloatConvertorBuilder implements ConvertorBuilder {
+ public Convertor build(Element configElement) throws Exception {
+ return new PlainFloatConvertor();
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainFloatConvertorBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainIntegerConvertor.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainIntegerConvertor.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainIntegerConvertor.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainIntegerConvertor.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,50 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+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:antonio@apache.org">Antonio Gallardo</a>
+ * @version $Id: PlainIntegerConvertor.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class PlainIntegerConvertor implements Convertor {
+ public ConversionResult convertFromString(String value, Locale locale, Convertor.FormatCache formatCache) {
+ try {
+ return new ConversionResult(new Integer(Integer.parseInt(value)));
+ } catch (NumberFormatException e) {
+ return ConversionResult.create("integer");
+ }
+ }
+
+ public String convertToString(Object value, Locale locale, Convertor.FormatCache formatCache) {
+ return String.valueOf(value);
+ }
+
+ public Class getTypeClass() {
+ return Integer.class;
+ }
+
+ public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
+ // intentionally empty
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainIntegerConvertor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainIntegerConvertorBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainIntegerConvertorBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainIntegerConvertorBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainIntegerConvertorBuilder.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,30 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import org.w3c.dom.Element;
+
+/**
+ * Builds {@link PlainIntegerConvertor}s.
+ *
+ * @author <a href="mailto:antonio@apache.org">Antonio Gallardo</a>
+ * @version $Id: PlainIntegerConvertorBuilder.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class PlainIntegerConvertorBuilder implements ConvertorBuilder {
+ public Convertor build(Element configElement) throws Exception {
+ return new PlainIntegerConvertor();
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainIntegerConvertorBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainLongConvertor.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainLongConvertor.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainLongConvertor.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainLongConvertor.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,49 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+import java.util.Locale;
+
+/**
+ * Convertor for java.lang.Longs that does not do any (Locale-dependent)
+ * formatting. It simply uses String.valueOf() and Long.parseLong().
+ *
+ * @version $Id: PlainLongConvertor.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class PlainLongConvertor implements Convertor {
+ public ConversionResult convertFromString(String value, Locale locale, Convertor.FormatCache formatCache) {
+ try {
+ return new ConversionResult(new Long(Long.parseLong(value)));
+ } catch (NumberFormatException e) {
+ return ConversionResult.create("long");
+ }
+ }
+
+ public String convertToString(Object value, Locale locale, Convertor.FormatCache formatCache) {
+ return String.valueOf(value);
+ }
+
+ public Class getTypeClass() {
+ return Long.class;
+ }
+
+ public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
+ // intentionally empty
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainLongConvertor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainLongConvertorBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainLongConvertorBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainLongConvertorBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainLongConvertorBuilder.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,29 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import org.w3c.dom.Element;
+
+/**
+ * Builds {@link PlainLongConvertor}s.
+ *
+ * @version $Id: PlainLongConvertorBuilder.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class PlainLongConvertorBuilder implements ConvertorBuilder {
+ public Convertor build(Element configElement) throws Exception {
+ return new PlainLongConvertor();
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/convertor/PlainLongConvertorBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/typeimpl/AbstractDatatype.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/typeimpl/AbstractDatatype.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/typeimpl/AbstractDatatype.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/typeimpl/AbstractDatatype.java Thu Nov 3 05:41:06 2005
@@ -0,0 +1,106 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.typeimpl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.cocoon.forms.datatype.Datatype;
+import org.apache.cocoon.forms.datatype.DatatypeBuilder;
+import org.apache.cocoon.forms.datatype.ValidationRule;
+import org.apache.cocoon.forms.datatype.convertor.Convertor;
+import org.apache.cocoon.forms.datatype.convertor.ConversionResult;
+import org.apache.cocoon.forms.validation.ValidationError;
+import org.apache.cocoon.forms.FormsConstants;
+import org.apache.cocoon.xml.AttributesImpl;
+import org.outerj.expression.ExpressionContext;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * Abstract base class for Datatype implementations. Most concreate datatypes
+ * will derive from this class.
+ * @version $Id: AbstractDatatype.java 326838 2005-10-20 06:26:53Z sylvain $
+ */
+public abstract class AbstractDatatype implements Datatype {
+ private List validationRules = new ArrayList();
+ private boolean arrayType = false;
+ private DatatypeBuilder builder;
+ private Convertor convertor;
+
+ public ValidationError validate(Object value, ExpressionContext expressionContext) {
+ Iterator validationRulesIt = validationRules.iterator();
+ while (validationRulesIt.hasNext()) {
+ ValidationRule validationRule = (ValidationRule)validationRulesIt.next();
+ ValidationError result = validationRule.validate(value, expressionContext);
+ if (result != null)
+ return result;
+ }
+ return null;
+ }
+
+ public void addValidationRule(ValidationRule validationRule) {
+ validationRules.add(validationRule);
+ }
+
+ public boolean isArrayType() {
+ return arrayType;
+ }
+
+ protected void setArrayType(boolean arrayType) {
+ this.arrayType = arrayType;
+ }
+
+ protected void setConvertor(Convertor convertor) {
+ this.convertor = convertor;
+ }
+
+ protected void setBuilder(DatatypeBuilder builder) {
+ this.builder = builder;
+ }
+
+ public Convertor getPlainConvertor() {
+ return builder.getPlainConvertor();
+ }
+
+ public DatatypeBuilder getBuilder() {
+ return builder;
+ }
+
+ public Convertor getConvertor() {
+ return convertor;
+ }
+
+ public ConversionResult convertFromString(String value, Locale locale) {
+ return getConvertor().convertFromString(value, locale, null);
+ }
+
+ public String convertToString(Object value, Locale locale) {
+ return getConvertor().convertToString(value, locale, null);
+ }
+
+ private static final String DATATYPE_EL = "datatype";
+
+ public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addCDATAAttribute("type", getDescriptiveName());
+ contentHandler.startElement(FormsConstants.INSTANCE_NS, DATATYPE_EL, FormsConstants.INSTANCE_PREFIX_COLON + DATATYPE_EL, attrs);
+ getConvertor().generateSaxFragment(contentHandler, locale);
+ contentHandler.endElement(FormsConstants.INSTANCE_NS, DATATYPE_EL, FormsConstants.INSTANCE_PREFIX_COLON + DATATYPE_EL);
+ }
+}
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/typeimpl/AbstractDatatype.java
------------------------------------------------------------------------------
svn:eol-style = native