You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by tv...@apache.org on 2007/04/08 15:49:41 UTC
svn commit: r526554 - in /jakarta/turbine/fulcrum/trunk/intake: src/dtd/
src/java/org/apache/fulcrum/intake/ src/java/org/apache/fulcrum/intake/model/
src/java/org/apache/fulcrum/intake/transform/
src/java/org/apache/fulcrum/intake/validator/ src/java/...
Author: tv
Date: Sun Apr 8 06:49:40 2007
New Revision: 526554
URL: http://svn.apache.org/viewvc?view=rev&rev=526554
Log:
- Added locale handling to Intake validators
- Added user-defined field types.
Added:
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/AbstractNumberField.java
jakarta/turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/test/MyField.java
Modified:
jakarta/turbine/fulcrum/trunk/intake/src/dtd/intake.dtd
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeError.java
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeException.java
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeRuntimeException.java
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/BigDecimalField.java
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/DoubleField.java
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/Field.java
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FieldFactory.java
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FloatField.java
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/transform/DTDResolver.java
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/BigDecimalValidator.java
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/DefaultValidator.java
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/DoubleValidator.java
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/FloatValidator.java
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/InvalidMaskException.java
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/StringValidator.java
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/ValidationException.java
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/Validator.java
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/xmlmodel/AppData.java
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/xmlmodel/Rule.java
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/xmlmodel/XmlField.java
jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/xmlmodel/XmlGroup.java
jakarta/turbine/fulcrum/trunk/intake/src/test/intake1.xml
jakarta/turbine/fulcrum/trunk/intake/src/test/intake2.xml
jakarta/turbine/fulcrum/trunk/intake/xdocs/changes.xml
Modified: jakarta/turbine/fulcrum/trunk/intake/src/dtd/intake.dtd
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/dtd/intake.dtd?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
Binary files - no diff available.
Modified: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeError.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeError.java?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeError.java (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeError.java Sun Apr 8 06:49:40 2007
@@ -27,6 +27,11 @@
public class IntakeError extends NestableError
{
/**
+ * Serial version id
+ */
+ private static final long serialVersionUID = 7594936180163472231L;
+
+ /**
* Constructs a new <code>IntakeError</code> without specified
* detail message.
*/
Modified: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeException.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeException.java?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeException.java (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeException.java Sun Apr 8 06:49:40 2007
@@ -25,6 +25,11 @@
public class IntakeException extends Exception
{
/**
+ * Serial version id
+ */
+ private static final long serialVersionUID = 7078617074679759156L;
+
+ /**
* Constructs a new <code>TurbineException</code> without specified
* detail message.
*/
Modified: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeRuntimeException.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeRuntimeException.java?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeRuntimeException.java (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeRuntimeException.java Sun Apr 8 06:49:40 2007
@@ -25,6 +25,11 @@
public class IntakeRuntimeException extends RuntimeException
{
/**
+ * Serial version id
+ */
+ private static final long serialVersionUID = -6874511109052092373L;
+
+ /**
* Constructs a new <code>TurbineException</code> without specified
* detail message.
*/
Modified: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java Sun Apr 8 06:49:40 2007
@@ -54,26 +54,23 @@
import org.apache.fulcrum.intake.xmlmodel.AppData;
import org.apache.fulcrum.intake.xmlmodel.XmlGroup;
import org.apache.fulcrum.localization.LocalizationService;
+
/**
- * This service provides access to input processing objects based
- * on an XML specification.
- *
+ * This service provides access to input processing objects based on an XML
+ * specification.
+ *
* @author <a href="mailto:jmcnally@collab.net">John McNally</a>
* @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
* @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
* @version $Id$
- *
+ *
* @avalon.component name="intake"
* @avalon.service type="org.apache.fulcrum.intake.IntakeService"
*/
-public class IntakeServiceImpl
- extends AbstractLogEnabled
- implements
- IntakeService,
- Configurable,
- Initializable,
- Contextualizable,
- Serviceable {
+public class IntakeServiceImpl extends AbstractLogEnabled implements
+ IntakeService, Configurable, Initializable, Contextualizable,
+ Serviceable
+{
/** Map of groupNames -> appData elements */
private Map groupNames;
@@ -92,12 +89,7 @@
/** AppData -> keyed Pools Map */
private Map keyedPools;
- /** The Avalon Context */
- private Context context = null;
-
- /** The Avalon ComponentManager */
- private ServiceManager manager = null;
-
+ /** The Avalon Container root directory */
private String applicationRoot;
/**
@@ -106,34 +98,38 @@
String XML_PATHS = "xmlPaths";
/**
- * The property specifying the location where a serialized version of
- * the xml specification can be written for faster restarts..
+ * The property specifying the location where a serialized version of the
+ * xml specification can be written for faster restarts..
*/
String SERIAL_XML = "serialDataPath";
/**
* Registers a given group name in the system
- *
- * @param groupName The name to register the group under
- * @param group The XML Group to register in
- * @param appData The app Data object where the group can be found
- * @param checkKey Whether to check if the key also exists.
- *
+ *
+ * @param groupName
+ * The name to register the group under
+ * @param group
+ * The XML Group to register in
+ * @param appData
+ * The app Data object where the group can be found
+ * @param checkKey
+ * Whether to check if the key also exists.
+ *
* @return true if successful, false if not
*/
- private boolean registerGroup(
- String groupName,
- XmlGroup group,
- AppData appData,
- boolean checkKey) {
- if (groupNames.keySet().contains(groupName)) {
+ private boolean registerGroup(String groupName, XmlGroup group,
+ AppData appData, boolean checkKey)
+ {
+ if (groupNames.keySet().contains(groupName))
+ {
// This name already exists.
return false;
}
boolean keyExists = groupNameMap.keySet().contains(group.getKey());
- if (checkKey && keyExists) {
+ if (checkKey && keyExists)
+ {
// The key for this package is already registered for another group
return false;
}
@@ -142,15 +138,18 @@
groupKeyMap.put(groupName, group.getKey());
- if (!keyExists) {
+ if (!keyExists)
+ {
// This key does not exist. Add it to the hash.
groupNameMap.put(group.getKey(), groupName);
}
List classNames = group.getMapToObjects();
- for (Iterator iter2 = classNames.iterator(); iter2.hasNext();) {
+ for (Iterator iter2 = classNames.iterator(); iter2.hasNext();)
+ {
String className = (String) iter2.next();
- if (!getterMap.containsKey(className)) {
+ if (!getterMap.containsKey(className))
+ {
getterMap.put(className, new HashMap());
setterMap.put(className, new HashMap());
}
@@ -159,34 +158,36 @@
}
/**
- * Tries to load a serialized Intake Group file. This
- * can reduce the startup time of Turbine.
- *
- * @param serialDataPath The path of the File to load.
- *
- * @return A map with appData objects loaded from the file
- * or null if the map could not be loaded.
+ * Tries to load a serialized Intake Group file. This can reduce the startup
+ * time of Turbine.
+ *
+ * @param serialDataPath
+ * The path of the File to load.
+ *
+ * @return A map with appData objects loaded from the file or null if the
+ * map could not be loaded.
*/
- private Map loadSerialized(String serialDataPath, long timeStamp) {
+ private Map loadSerialized(String serialDataPath, long timeStamp)
+ {
getLogger().debug(
- "Entered loadSerialized("
- + serialDataPath
- + ", "
- + timeStamp
- + ")");
+ "Entered loadSerialized(" + serialDataPath + ", " + timeStamp
+ + ")");
- if (serialDataPath == null) {
+ if (serialDataPath == null)
+ {
return null;
}
File serialDataFile = new File(serialDataPath);
- if (!serialDataFile.exists()) {
+ if (!serialDataFile.exists())
+ {
getLogger().info("No serialized file found, parsing XML");
return null;
}
- if (serialDataFile.lastModified() <= timeStamp) {
+ if (serialDataFile.lastModified() <= timeStamp)
+ {
getLogger().info("serialized file too old, parsing XML");
return null;
}
@@ -194,34 +195,48 @@
InputStream in = null;
Map serialData = null;
- try {
+ try
+ {
in = new FileInputStream(serialDataFile);
ObjectInputStream p = new ObjectInputStream(in);
Object o = p.readObject();
- if (o instanceof Map) {
+ if (o instanceof Map)
+ {
serialData = (Map) o;
- } else {
+ }
+ else
+ {
// Maybe an old file from intake. Ignore it and try to delete
- getLogger().info("serialized object is not an intake map, ignoring");
+ getLogger().info(
+ "serialized object is not an intake map, ignoring");
in.close();
in = null;
- serialDataFile.delete(); // Try to delete the file lying around
+ serialDataFile.delete(); // Try to delete the file lying
+ // around
}
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
getLogger().error("Serialized File could not be read.", e);
// We got a corrupt file for some reason.
// Null out serialData to be sure
serialData = null;
- } finally {
+ }
+ finally
+ {
// Could be null if we opened a file, didn't find it to be a
// Map object and then nuked it away.
- try {
- if (in != null) {
+ try
+ {
+ if (in != null)
+ {
in.close();
}
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
getLogger().error("Exception while closing file", e);
}
}
@@ -231,40 +246,47 @@
}
/**
- * Writes a parsed XML map with all the appData groups into a
- * file. This will speed up loading time when you restart the
- * Intake Service because it will only unserialize this file instead
- * of reloading all of the XML files
- *
- * @param serialDataPath The path of the file to write to
- * @param appDataElements A Map containing all of the XML parsed appdata elements
+ * Writes a parsed XML map with all the appData groups into a file. This
+ * will speed up loading time when you restart the Intake Service because it
+ * will only unserialize this file instead of reloading all of the XML files
+ *
+ * @param serialDataPath
+ * The path of the file to write to
+ * @param appDataElements
+ * A Map containing all of the XML parsed appdata elements
*/
- private void saveSerialized(String serialDataPath, Map appDataElements) {
+ private void saveSerialized(String serialDataPath, Map appDataElements)
+ {
getLogger().debug(
- "Entered saveSerialized(" + serialDataPath + ", appDataElements)");
+ "Entered saveSerialized(" + serialDataPath
+ + ", appDataElements)");
- if (serialDataPath == null) {
+ if (serialDataPath == null)
+ {
return;
}
File serialData = new File(serialDataPath);
- try {
+ try
+ {
serialData.createNewFile();
serialData.delete();
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
getLogger().info(
- "Could not create serialized file "
- + serialDataPath
- + ", not serializing the XML data");
+ "Could not create serialized file " + serialDataPath
+ + ", not serializing the XML data");
return;
}
OutputStream out = null;
InputStream in = null;
- try {
+ try
+ {
// write the appData file out
out = new FileOutputStream(serialDataPath);
ObjectOutputStream pout = new ObjectOutputStream(out);
@@ -278,53 +300,67 @@
Map dummy = (Map) pin.readObject();
getLogger().debug("Serializing successful");
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
getLogger().info(
- "Could not write serialized file to "
- + serialDataPath
- + ", not serializing the XML data");
- } finally {
- try {
- if (out != null) {
+ "Could not write serialized file to " + serialDataPath
+ + ", not serializing the XML data");
+ }
+ finally
+ {
+ try
+ {
+ if (out != null)
+ {
out.close();
}
- if (in != null) {
+ if (in != null)
+ {
in.close();
}
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
getLogger().error("Exception while closing file", e);
}
}
}
/**
- * Gets an instance of a named group either from the pool
- * or by calling the Factory Service if the pool is empty.
- *
- * @param groupName the name of the group.
+ * Gets an instance of a named group either from the pool or by calling the
+ * Factory Service if the pool is empty.
+ *
+ * @param groupName
+ * the name of the group.
* @return a Group instance.
- * @throws IntakeException if recycling fails.
+ * @throws IntakeException
+ * if recycling fails.
*/
- public Group getGroup(String groupName) throws IntakeException {
+ public Group getGroup(String groupName) throws IntakeException
+ {
Group group = null;
AppData appData = (AppData) groupNames.get(groupName);
- if (groupName == null) {
- throw new IntakeException("Intake IntakeServiceImpl.getGroup(groupName) is null");
+ if (groupName == null)
+ {
+ throw new IntakeException(
+ "Intake IntakeServiceImpl.getGroup(groupName) is null");
}
- if (appData == null) {
+ if (appData == null)
+ {
throw new IntakeException(
- "Intake IntakeServiceImpl.getGroup(groupName): No XML definition for Group "
- + groupName
- + " found");
- }
- try {
- group =
- (Group)
- ((KeyedObjectPool) keyedPools.get(appData)).borrowObject(
- groupName);
- } catch (Exception e) {
+ "Intake IntakeServiceImpl.getGroup(groupName): No XML definition for Group "
+ + groupName + " found");
+ }
+ try
+ {
+ group = (Group) ((KeyedObjectPool) keyedPools.get(appData))
+ .borrowObject(groupName);
+ }
+ catch (Exception e)
+ {
throw new IntakeException("Could not get group " + groupName, e);
}
return group;
@@ -332,29 +368,35 @@
/**
* Puts a Group back to the pool.
- *
- * @param instance the object instance to recycle.
- *
- * @throws IntakeException The passed group name does not exist.
- */
- public void releaseGroup(Group instance) throws IntakeException {
- if (instance != null) {
+ *
+ * @param instance
+ * the object instance to recycle.
+ *
+ * @throws IntakeException
+ * The passed group name does not exist.
+ */
+ public void releaseGroup(Group instance) throws IntakeException
+ {
+ if (instance != null)
+ {
String groupName = instance.getIntakeGroupName();
AppData appData = (AppData) groupNames.get(groupName);
- if (appData == null) {
+ if (appData == null)
+ {
throw new IntakeException(
- "Intake IntakeServiceImpl.releaseGroup(groupName): "
- + "No XML definition for Group "
- + groupName
- + " found");
+ "Intake IntakeServiceImpl.releaseGroup(groupName): "
+ + "No XML definition for Group " + groupName
+ + " found");
}
- try {
+ try
+ {
((KeyedObjectPool) keyedPools.get(appData)).returnObject(
- groupName,
- instance);
- } catch (Exception e) {
+ groupName, instance);
+ }
+ catch (Exception e)
+ {
new IntakeException("Could not get group " + groupName, e);
}
}
@@ -362,18 +404,21 @@
/**
* Gets the current size of the pool for a group.
- *
- * @param groupName the name of the group.
- *
- * @throws IntakeException The passed group name does not exist.
+ *
+ * @param groupName
+ * the name of the group.
+ *
+ * @throws IntakeException
+ * The passed group name does not exist.
*/
- public int getSize(String groupName) throws IntakeException {
+ public int getSize(String groupName) throws IntakeException
+ {
AppData appData = (AppData) groupNames.get(groupName);
- if (appData == null) {
+ if (appData == null)
+ {
throw new IntakeException(
- "Intake IntakeServiceImpl.Size(groupName): No XML definition for Group "
- + groupName
- + " found");
+ "Intake IntakeServiceImpl.Size(groupName): No XML definition for Group "
+ + groupName + " found");
}
KeyedObjectPool kop = (KeyedObjectPool) keyedPools.get(groupName);
@@ -383,80 +428,95 @@
/**
* Names of all the defined groups.
- *
+ *
* @return array of names.
*/
- public String[] getGroupNames() {
+ public String[] getGroupNames()
+ {
return (String[]) groupNames.keySet().toArray(new String[0]);
}
/**
* Gets the key (usually a short identifier) for a group.
- *
- * @param groupName the name of the group.
+ *
+ * @param groupName
+ * the name of the group.
* @return the the key.
*/
- public String getGroupKey(String groupName) {
+ public String getGroupKey(String groupName)
+ {
return (String) groupKeyMap.get(groupName);
}
/**
* Gets the group name given its key.
- *
- * @param groupKey the key.
+ *
+ * @param groupKey
+ * the key.
* @return groupName the name of the group.
*/
- public String getGroupName(String groupKey) {
+ public String getGroupName(String groupKey)
+ {
return (String) groupNameMap.get(groupKey);
}
/**
* Gets the Method that can be used to set a property.
- *
- * @param className the name of the object.
- * @param propName the name of the property.
+ *
+ * @param className
+ * the name of the object.
+ * @param propName
+ * the name of the property.
* @return the setter.
* @throws ClassNotFoundException
* @throws IntrospectionException
*/
public Method getFieldSetter(String className, String propName)
- throws ClassNotFoundException, IntrospectionException {
+ throws ClassNotFoundException, IntrospectionException
+ {
Map settersForClassName = (Map) setterMap.get(className);
- if (settersForClassName == null) {
- throw new IntrospectionException(
- "No setter Map for " + className + " available!");
+ if (settersForClassName == null)
+ {
+ throw new IntrospectionException("No setter Map for " + className
+ + " available!");
}
Method setter = (Method) settersForClassName.get(propName);
- if (setter == null) {
- PropertyDescriptor pd =
- new PropertyDescriptor(propName, Class.forName(className));
- synchronized (setterMap) {
+ if (setter == null)
+ {
+ PropertyDescriptor pd = new PropertyDescriptor(propName, Class
+ .forName(className));
+ synchronized (setterMap)
+ {
setter = pd.getWriteMethod();
settersForClassName.put(propName, setter);
- if (setter == null) {
+ if (setter == null)
+ {
getLogger().error(
- "Intake: setter for '"
- + propName
- + "' in class '"
- + className
- + "' could not be found.");
+ "Intake: setter for '" + propName + "' in class '"
+ + className + "' could not be found.");
}
}
// we have already completed the reflection on the getter, so
// save it so we do not have to repeat
- synchronized (getterMap) {
+ synchronized (getterMap)
+ {
Map gettersForClassName = (Map) getterMap.get(className);
- if (gettersForClassName != null) {
- try {
+ if (gettersForClassName != null)
+ {
+ try
+ {
Method getter = pd.getReadMethod();
- if (getter != null) {
+ if (getter != null)
+ {
gettersForClassName.put(propName, getter);
}
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
// Do nothing
}
}
@@ -467,51 +527,61 @@
/**
* Gets the Method that can be used to get a property value.
- *
- * @param className the name of the object.
- * @param propName the name of the property.
+ *
+ * @param className
+ * the name of the object.
+ * @param propName
+ * the name of the property.
* @return the getter.
* @throws ClassNotFoundException
* @throws IntrospectionException
*/
public Method getFieldGetter(String className, String propName)
- throws ClassNotFoundException, IntrospectionException {
+ throws ClassNotFoundException, IntrospectionException
+ {
Map gettersForClassName = (Map) getterMap.get(className);
- if (gettersForClassName == null) {
- throw new IntrospectionException(
- "No getter Map for " + className + " available!");
+ if (gettersForClassName == null)
+ {
+ throw new IntrospectionException("No getter Map for " + className
+ + " available!");
}
Method getter = (Method) gettersForClassName.get(propName);
- if (getter == null) {
+ if (getter == null)
+ {
PropertyDescriptor pd = null;
- synchronized (getterMap) {
+ synchronized (getterMap)
+ {
pd = new PropertyDescriptor(propName, Class.forName(className));
getter = pd.getReadMethod();
gettersForClassName.put(propName, getter);
- if (getter == null) {
+ if (getter == null)
+ {
getLogger().error(
- "Intake: getter for '"
- + propName
- + "' in class '"
- + className
- + "' could not be found.");
+ "Intake: getter for '" + propName + "' in class '"
+ + className + "' could not be found.");
}
}
// we have already completed the reflection on the setter, so
// save it so we do not have to repeat
- synchronized (setterMap) {
+ synchronized (setterMap)
+ {
Map settersForClassName = (Map) getterMap.get(className);
- if (settersForClassName != null) {
- try {
+ if (settersForClassName != null)
+ {
+ try
+ {
Method setter = pd.getWriteMethod();
- if (setter != null) {
+ if (setter != null)
+ {
settersForClassName.put(propName, setter);
}
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
// Do nothing
}
}
@@ -524,35 +594,42 @@
/**
* Avalon component lifecycle method
*/
- public void configure(Configuration conf) throws ConfigurationException {
+ public void configure(Configuration conf) throws ConfigurationException
+ {
Vector defaultXmlPathes = new Vector();
defaultXmlPathes.add(XML_PATH_DEFAULT);
final Configuration xmlPaths = conf.getChild(XML_PATHS, false);
List xmlPathes = new ArrayList();
- if (xmlPaths == null) {
+ if (xmlPaths == null)
+ {
xmlPathes.add(XML_PATH_DEFAULT);
- } else {
+ }
+ else
+ {
Configuration[] nameVal = xmlPaths.getChildren();
- for (int i = 0; i < nameVal.length; i++) {
- String key = nameVal[i].getName();
+ for (int i = 0; i < nameVal.length; i++)
+ {
String val = nameVal[i].getValue();
- // getLogger.debug("Registered " + val
- // + " for Crypto Algorithm " + key);
+ // getLogger.debug("Registered " + val
+ // + " for Crypto Algorithm " + key);
xmlPathes.add(val);
}
}
Map appDataElements = null;
- String serialDataPath =
- conf.getChild(SERIAL_XML, false).getValue(SERIAL_XML_DEFAULT);
+ String serialDataPath = conf.getChild(SERIAL_XML, false).getValue(
+ SERIAL_XML_DEFAULT);
- if (!serialDataPath.equalsIgnoreCase("none")) {
- serialDataPath =
- new File(applicationRoot, serialDataPath).getAbsolutePath();
- } else {
+ if (!serialDataPath.equalsIgnoreCase("none"))
+ {
+ serialDataPath = new File(applicationRoot, serialDataPath)
+ .getAbsolutePath();
+ }
+ else
+ {
serialDataPath = null;
}
@@ -565,9 +642,9 @@
setterMap = new HashMap();
keyedPools = new HashMap();
- if (xmlPathes == null) {
- String LOAD_ERROR =
- "No paths for XML files were specified. "
+ if (xmlPathes == null)
+ {
+ String LOAD_ERROR = "No paths for XML files were specified. "
+ "Check that the property exists in "
+ "TurbineResources.props and were loaded.";
@@ -579,15 +656,18 @@
long timeStamp = 0;
- for (Iterator it = xmlPathes.iterator(); it.hasNext();) {
+ for (Iterator it = xmlPathes.iterator(); it.hasNext();)
+ {
// Files are webapp.root relative
String xmlPath = (String) it.next();
- File xmlFile = new File( applicationRoot, xmlPath).getAbsoluteFile();
+ File xmlFile = new File(applicationRoot, xmlPath).getAbsoluteFile();
getLogger().debug("Path for XML File: " + xmlFile);
- if (!xmlFile.canRead()) {
- String READ_ERR = "Could not read input file with path " + xmlPath +". Looking for file " + xmlFile;
+ if (!xmlFile.canRead())
+ {
+ String READ_ERR = "Could not read input file with path "
+ + xmlPath + ". Looking for file " + xmlFile;
getLogger().error(READ_ERR);
throw new ConfigurationException(READ_ERR);
@@ -600,36 +680,40 @@
// Get the timestamp of the youngest file to be compared with
// a serialized file. If it is younger than the serialized file,
// then we have to parse the XML anyway.
- timeStamp =
- (xmlFile.lastModified() > timeStamp)
- ? xmlFile.lastModified()
- : timeStamp;
+ timeStamp = (xmlFile.lastModified() > timeStamp) ? xmlFile
+ .lastModified() : timeStamp;
}
Map serializedMap = loadSerialized(serialDataPath, timeStamp);
- if (serializedMap != null) {
+ if (serializedMap != null)
+ {
// Use the serialized data as XML groups. Don't parse.
appDataElements = serializedMap;
getLogger().debug("Using the serialized map");
- } else {
+ }
+ else
+ {
// Parse all the given XML files
appDataElements = new HashMap();
- for (Iterator it = xmlFiles.iterator(); it.hasNext();) {
+ for (Iterator it = xmlFiles.iterator(); it.hasNext();)
+ {
String xmlPath = (String) it.next();
AppData appData = null;
getLogger().debug("Now parsing: " + xmlPath);
- try {
+ try
+ {
XmlToAppData xmlApp = new XmlToAppData();
appData = xmlApp.parseFile(xmlPath);
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
getLogger().error("Could not parse XML file " + xmlPath, e);
throw new ConfigurationException(
- "Could not parse XML file " + xmlPath,
- e);
+ "Could not parse XML file " + xmlPath, e);
}
appDataElements.put(appData, xmlPath);
@@ -639,10 +723,11 @@
saveSerialized(serialDataPath, appDataElements);
}
- try {
- for (Iterator it = appDataElements.keySet().iterator();
- it.hasNext();
- ) {
+ try
+ {
+ for (Iterator it = appDataElements.keySet().iterator(); it
+ .hasNext();)
+ {
AppData appData = (AppData) it.next();
int maxPooledGroups = 0;
@@ -650,70 +735,73 @@
String groupPrefix = appData.getGroupPrefix();
- for (int i = glist.size() - 1; i >= 0; i--) {
+ for (int i = glist.size() - 1; i >= 0; i--)
+ {
XmlGroup g = (XmlGroup) glist.get(i);
String groupName = g.getName();
- boolean registerUnqualified =
- registerGroup(groupName, g, appData, true);
+ boolean registerUnqualified = registerGroup(groupName, g,
+ appData, true);
- if (!registerUnqualified) {
+ if (!registerUnqualified)
+ {
getLogger().info(
- "Ignored redefinition of Group "
- + groupName
- + " or Key "
- + g.getKey()
- + " from "
- + appDataElements.get(appData));
+ "Ignored redefinition of Group " + groupName
+ + " or Key " + g.getKey() + " from "
+ + appDataElements.get(appData));
}
- if (groupPrefix != null) {
+ if (groupPrefix != null)
+ {
StringBuffer qualifiedName = new StringBuffer();
qualifiedName.append(groupPrefix).append(':').append(
- groupName);
+ groupName);
- // Add the fully qualified group name. Do _not_ check for
- // the existence of the key if the unqualified registration succeeded
- // (because then it was added by the registerGroup above).
- if (!registerGroup(qualifiedName.toString(),
- g,
- appData,
- !registerUnqualified)) {
- getLogger().error(
- "Could not register fully qualified name "
- + qualifiedName
- + ", maybe two XML files have the same prefix. Ignoring it.");
+ // Add the fully qualified group name. Do _not_ check
+ // for
+ // the existence of the key if the unqualified
+ // registration succeeded
+ // (because then it was added by the registerGroup
+ // above).
+ if (!registerGroup(qualifiedName.toString(), g,
+ appData, !registerUnqualified))
+ {
+ getLogger()
+ .error(
+ "Could not register fully qualified name "
+ + qualifiedName
+ + ", maybe two XML files have the same prefix. Ignoring it.");
}
}
- maxPooledGroups =
- Math.max(
- maxPooledGroups,
- Integer.parseInt(g.getPoolCapacity()));
+ maxPooledGroups = Math.max(maxPooledGroups, Integer
+ .parseInt(g.getPoolCapacity()));
}
- KeyedPoolableObjectFactory factory =
- new Group.GroupFactory(appData);
- keyedPools.put(
- appData,
- new StackKeyedObjectPool(factory, maxPooledGroups));
+ KeyedPoolableObjectFactory factory = new Group.GroupFactory(
+ appData);
+ keyedPools.put(appData, new StackKeyedObjectPool(factory,
+ maxPooledGroups));
}
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
throw new ConfigurationException(
- "IntakeServiceImpl failed to initialize",
- e);
+ "IntakeServiceImpl failed to initialize", e);
}
}
+
/**
- * Avalon component lifecycle method
- * Initializes the service by loading default class loaders
- * and customized object factories.
- *
- * @throws InitializationException if initialization fails.
+ * Avalon component lifecycle method Initializes the service by loading
+ * default class loaders and customized object factories.
+ *
+ * @throws InitializationException
+ * if initialization fails.
*/
- public void initialize() throws Exception {
+ public void initialize() throws Exception
+ {
Intake.setIntakeService(this);
if (getLogger().isInfoEnabled())
{
@@ -725,29 +813,21 @@
* @see org.apache.avalon.framework.context.Contextualizable
* @avalon.entry key="urn:avalon:home" type="java.io.File"
*/
- public void contextualize(Context context) throws ContextException {
- this.context = context;
- this.applicationRoot = context.get( "urn:avalon:home" ).toString();
- }
-
- /**
- * Avalon component lifecycle method
- * @avalon.dependency type="org.apache.fulcrum.localization.LocalizationService"
- */
- public void service( ServiceManager manager) throws ServiceException {
- this.manager = manager;
-
- IntakeServiceFacade.setIntakeService(this);
- LocalizationService localizationService =
- (LocalizationService)manager.lookup(LocalizationService.ROLE);
- IntakeServiceFacade.setLocalizationService(localizationService);
+ public void contextualize(Context context) throws ContextException
+ {
+ this.applicationRoot = context.get("urn:avalon:home").toString();
}
/**
* Avalon component lifecycle method
+ *
+ * @avalon.dependency type="org.apache.fulcrum.localization.LocalizationService"
*/
- public void dispose() {
-
- manager = null;
+ public void service(ServiceManager manager) throws ServiceException
+ {
+ IntakeServiceFacade.setIntakeService(this);
+ LocalizationService localizationService = (LocalizationService) manager
+ .lookup(LocalizationService.ROLE);
+ IntakeServiceFacade.setLocalizationService(localizationService);
}
}
Added: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/AbstractNumberField.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/AbstractNumberField.java?view=auto&rev=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/AbstractNumberField.java (added)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/AbstractNumberField.java Sun Apr 8 06:49:40 2007
@@ -0,0 +1,70 @@
+package org.apache.fulcrum.intake.model;
+
+/*
+ * Copyright 2001-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.
+ */
+
+import java.text.DecimalFormatSymbols;
+import java.util.Locale;
+
+import org.apache.fulcrum.intake.IntakeException;
+import org.apache.fulcrum.intake.xmlmodel.XmlField;
+
+/**
+ * Provides helper methods for localizing floating point numbers
+ *
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
+ * @version $Id: BigDecimalField.java 223047 2004-07-01 11:30:52Z epugh $
+ */
+public abstract class AbstractNumberField
+ extends Field
+{
+ /**
+ * Constructor.
+ *
+ * @param field xml field definition object
+ * @param group xml group definition object
+ * @throws IntakeException thrown by superclass
+ */
+ public AbstractNumberField(XmlField field, Group group)
+ throws IntakeException
+ {
+ super(field, group);
+ }
+
+ /**
+ * Canonicalizes an user-inputted <code>BigDecimal</code> string
+ * to the system's internal format.
+ *
+ * @param number Text conforming to a <code>Number</code>
+ * description for a set of <code>DecimalFormatSymbols</code>.
+ * @return The canonicalized representation.
+ */
+ protected final String canonicalizeDecimalInput(String number)
+ {
+ if (getLocale() != null)
+ {
+ DecimalFormatSymbols internal = new DecimalFormatSymbols(Locale.US);
+ DecimalFormatSymbols user = new DecimalFormatSymbols(getLocale());
+
+ if (!internal.equals(user))
+ {
+ number = number.replace(user.getDecimalSeparator(),
+ internal.getDecimalSeparator());
+ }
+ }
+ return number;
+ }
+}
Modified: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/BigDecimalField.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/BigDecimalField.java?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/BigDecimalField.java (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/BigDecimalField.java Sun Apr 8 06:49:40 2007
@@ -18,10 +18,7 @@
import java.math.BigDecimal;
-import java.text.DecimalFormatSymbols;
-
import org.apache.commons.lang.StringUtils;
-
import org.apache.fulcrum.intake.IntakeException;
import org.apache.fulcrum.intake.validator.BigDecimalValidator;
import org.apache.fulcrum.intake.xmlmodel.XmlField;
@@ -31,10 +28,11 @@
* @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
* @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
* @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
* @version $Id$
*/
public class BigDecimalField
- extends Field
+ extends AbstractNumberField
{
/**
* Constructor.
@@ -108,38 +106,14 @@
for (int i = 0; i < inputs.length; i++)
{
values[i] = StringUtils.isNotEmpty(inputs[i])
- ? canonicalizeDecimalInput(inputs[i]) : (BigDecimal) getEmptyValue();
+ ? new BigDecimal(canonicalizeDecimalInput(inputs[i])) : (BigDecimal) getEmptyValue();
}
setTestValue(values);
}
else
{
String val = parser.getString(getKey());
- setTestValue(StringUtils.isNotEmpty(val) ? canonicalizeDecimalInput(val) : (BigDecimal) getEmptyValue());
- }
- }
-
- /**
- * Canonicalizes an user-inputted <code>BigDecimal</code> string
- * to the system's internal format.
- *
- * @param bigDecimal Text conforming to a <code>BigDecimal</code>
- * description for a set of <code>DecimalFormatSymbols</code>.
- * @return The canonicalized representation.
- */
- protected final BigDecimal canonicalizeDecimalInput(String bigDecimal)
- {
- if (getLocale() != null)
- {
- DecimalFormatSymbols internal = new DecimalFormatSymbols();
- DecimalFormatSymbols user = new DecimalFormatSymbols(getLocale());
-
- if (!internal.equals(user))
- {
- bigDecimal = bigDecimal.replace(user.getDecimalSeparator(),
- internal.getDecimalSeparator());
- }
+ setTestValue(StringUtils.isNotEmpty(val) ? new BigDecimal(canonicalizeDecimalInput(val)) : (BigDecimal) getEmptyValue());
}
- return new BigDecimal(bigDecimal);
}
}
Modified: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/DoubleField.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/DoubleField.java?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/DoubleField.java (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/DoubleField.java Sun Apr 8 06:49:40 2007
@@ -17,7 +17,6 @@
*/
import org.apache.commons.lang.StringUtils;
-
import org.apache.fulcrum.intake.IntakeException;
import org.apache.fulcrum.intake.validator.DoubleValidator;
import org.apache.fulcrum.intake.xmlmodel.XmlField;
@@ -25,10 +24,11 @@
/**
* Processor for double fields.
*
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
* @version $Id$
*/
public class DoubleField
- extends Field
+ extends AbstractNumberField
{
/**
* Constructor.
@@ -125,7 +125,7 @@
for (int i = 0; i < inputs.length; i++)
{
values[i] = StringUtils.isNotEmpty(inputs[i])
- ? new Double(inputs[i]).doubleValue()
+ ? new Double(canonicalizeDecimalInput(inputs[i])).doubleValue()
: ((Double) getEmptyValue()).doubleValue();
}
setTestValue(values);
@@ -134,8 +134,8 @@
{
String val = parser.getString(getKey());
setTestValue(StringUtils.isNotEmpty(val)
- ? new Double(val) : (Double) getEmptyValue());
+ ? new Double(canonicalizeDecimalInput(val))
+ : (Double) getEmptyValue());
}
}
-
}
Modified: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/Field.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/Field.java?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/Field.java (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/Field.java Sun Apr 8 06:49:40 2007
@@ -44,6 +44,7 @@
* @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
* @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
* @author <a href="mailto:jh@byteaction.de">Jürgen Hoffmann</a>
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
* @version $Id$
*/
public abstract class Field
@@ -54,8 +55,11 @@
/** CGI Key for "value if absent" */
private static final String VALUE_IF_ABSENT_KEY = "_vifa_";
- /** Default Package */
- public static final String defaultFieldPackage = "org.apache.fulcrum.intake.validator.";
+ /** Default Validator Package */
+ public static final String defaultValidatorPackage = "org.apache.fulcrum.intake.validator.";
+
+ /** Default Field Package */
+ public static final String defaultFieldPackage = "org.apache.fulcrum.intake.model.";
// the following are set from the xml file and are permanent (final)
@@ -200,7 +204,7 @@
else if (validatorClassName != null
&& validatorClassName.indexOf('.') == -1)
{
- validatorClassName = defaultFieldPackage + validatorClassName;
+ validatorClassName = defaultValidatorPackage + validatorClassName;
}
if (validatorClassName != null)
@@ -371,12 +375,23 @@
}
/**
+ * Returns the <code>Group</code> this field belongs to
+ * or <code>null</code> if unknown.
+ *
+ * @return The group this field belongs to.
+ */
+ public Group getGroup()
+ {
+ return group;
+ }
+
+ /**
* Returns the <code>Locale</code> used when localizing data for
* this field, or <code>null</code> if unknown.
*
* @return Where to localize for.
*/
- protected Locale getLocale()
+ public Locale getLocale()
{
return locale;
}
@@ -401,6 +416,16 @@
}
/**
+ * Flag to determine whether the field has been declared as multi-valued.
+ *
+ * @return value of isMultiValued.
+ */
+ public boolean isMultiValued()
+ {
+ return isMultiValued;
+ }
+
+ /**
* Flag to determine whether the field has been declared as required.
*
* @return value of required.
@@ -589,16 +614,14 @@
// set the test value as a String[] which might be replaced by
// the correct type if the input is valid.
setTestValue(parser.getStrings(getKey()));
- for (int i = 0; i < stringValues.length; i++)
+
+ try
{
- try
- {
- validator.assertValidity(stringValues[i]);
- }
- catch (ValidationException ve)
- {
- setMessage(ve.getMessage());
- }
+ validator.assertValidity(this);
+ }
+ catch (ValidationException ve)
+ {
+ setMessage(ve.getMessage());
}
}
@@ -624,7 +647,7 @@
try
{
- validator.assertValidity(stringValue);
+ validator.assertValidity(this);
log.debug(name + ": Value is ok");
doSetValue();
}
@@ -798,7 +821,7 @@
{
try
{
- validValue = getter.invoke(obj, null);
+ validValue = getter.invoke(obj, (Object[])null);
}
catch (IllegalAccessException e)
{
Modified: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FieldFactory.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FieldFactory.java?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FieldFactory.java (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FieldFactory.java Sun Apr 8 06:49:40 2007
@@ -16,6 +16,7 @@
* limitations under the License.
*/
+import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
@@ -28,6 +29,7 @@
* @author <a href="mailto:jmcnally@collab.net">John McNally</a>
* @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
* @author <a href="mailto:Colin.Chalmers@maxware.nl">Colin Chalmers</a>
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
* @version $Id$
*/
public abstract class FieldFactory
@@ -125,6 +127,52 @@
throws IntakeException
{
return new LongField(f, g);
+ }
+ }
+ );
+ fieldCtors.put("custom", new FieldFactory.FieldCtor()
+ {
+ public Field getInstance(XmlField f, Group g)
+ throws IntakeException
+ {
+ String fieldClass = f.getFieldClass();
+
+ if (fieldClass != null
+ && fieldClass.indexOf('.') == -1)
+ {
+ fieldClass = Field.defaultFieldPackage + fieldClass;
+ }
+
+ if (fieldClass != null)
+ {
+ Class field;
+
+ try
+ {
+ field = Class.forName(fieldClass);
+ Constructor constructor =
+ field.getConstructor(new Class[] { XmlField.class, Group.class });
+
+ return (Field)constructor.newInstance(new Object[] { f, g });
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new IntakeException(
+ "Could not load Field class("
+ + fieldClass + ")", e);
+ }
+ catch (Exception e)
+ {
+ throw new IntakeException(
+ "Could not create new instance of Field("
+ + fieldClass + ")", e);
+ }
+ }
+ else
+ {
+ throw new IntakeException(
+ "Custom field types must define a fieldClass");
+ }
}
}
);
Modified: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FloatField.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FloatField.java?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FloatField.java (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FloatField.java Sun Apr 8 06:49:40 2007
@@ -17,7 +17,6 @@
*/
import org.apache.commons.lang.StringUtils;
-
import org.apache.fulcrum.intake.IntakeException;
import org.apache.fulcrum.intake.validator.FloatValidator;
import org.apache.fulcrum.intake.xmlmodel.XmlField;
@@ -25,10 +24,11 @@
/**
* Processor for float fields.
*
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
* @version $Id$
*/
public class FloatField
- extends Field
+ extends AbstractNumberField
{
/**
* Constructor.
@@ -125,7 +125,7 @@
for (int i = 0; i < inputs.length; i++)
{
values[i] = StringUtils.isNotEmpty(inputs[i])
- ? new Float(inputs[i]).floatValue()
+ ? new Float(canonicalizeDecimalInput(inputs[i])).floatValue()
: ((Float) getEmptyValue()).floatValue();
}
setTestValue(values);
@@ -134,7 +134,8 @@
{
String val = parser.getString(getKey());
setTestValue(StringUtils.isNotEmpty(val)
- ? new Float(val) : getEmptyValue());
+ ? new Float(canonicalizeDecimalInput(val))
+ : getEmptyValue());
}
}
Modified: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/transform/DTDResolver.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/transform/DTDResolver.java?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/transform/DTDResolver.java (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/transform/DTDResolver.java Sun Apr 8 06:49:40 2007
@@ -40,7 +40,7 @@
public class DTDResolver implements EntityResolver
{
private static final String WEB_SITE_DTD =
- "http://jakarta.apache.org/turbine/dtd/intake_2_3.dtd";
+ "http://jakarta.apache.org/turbine/dtd/intake_2_4.dtd";
/** InputSource for <code>intake.dtd</code>. */
private InputSource intakeDTD = null;
Modified: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/BigDecimalValidator.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/BigDecimalValidator.java?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/BigDecimalValidator.java (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/BigDecimalValidator.java Sun Apr 8 06:49:40 2007
@@ -17,10 +17,13 @@
*/
import java.math.BigDecimal;
-
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.Locale;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
+import org.apache.fulcrum.intake.model.Field;
/**
* Validates BigDecimals with the following constraints in addition to those
@@ -39,6 +42,7 @@
* @author <a href="mailto:jmcnally@collab.net">John McNally</a>
* @author <a href="mailto:Colin.Chalmers@maxware.nl">Colin Chalmers</a>
* @author <a href="mailto:jh@byteaction.de">Jürgen Hoffmann</a>
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
* @version $Id$
*/
public class BigDecimalValidator
@@ -96,14 +100,43 @@
}
/**
+ * Determine whether a field meets the criteria specified
+ * in the constraints defined for this validator
+ *
+ * @param field a <code>Field</code> to be tested
+ * @exception ValidationException containing an error message if the
+ * testValue did not pass the validation tests.
+ */
+ public void assertValidity(Field field)
+ throws ValidationException
+ {
+ Locale locale = field.getLocale();
+
+ if (field.isMultiValued())
+ {
+ String[] stringValues = (String[])field.getTestValue();
+
+ for (int i = 0; i < stringValues.length; i++)
+ {
+ assertValidity(stringValues[i], locale);
+ }
+ }
+ else
+ {
+ assertValidity((String)field.getTestValue(), locale);
+ }
+ }
+
+ /**
* Determine whether a testValue meets the criteria specified
* in the constraints defined for this validator
*
* @param testValue a <code>String</code> to be tested
+ * @param locale the Locale of the associated field
* @exception ValidationException containing an error message if the
* testValue did not pass the validation tests.
*/
- public void assertValidity(String testValue)
+ public void assertValidity(String testValue, Locale locale)
throws ValidationException
{
super.assertValidity(testValue);
@@ -111,11 +144,13 @@
if (required || StringUtils.isNotEmpty(testValue))
{
BigDecimal bd = null;
+ NumberFormat nf = NumberFormat.getInstance(locale);
try
{
- bd = new BigDecimal(testValue);
+ Number number = nf.parse(testValue);
+ bd = new BigDecimal(number.doubleValue());
}
- catch (RuntimeException e)
+ catch (ParseException e)
{
errorMessage = invalidNumberMessage;
throw new ValidationException(invalidNumberMessage);
Modified: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/DefaultValidator.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/DefaultValidator.java?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/DefaultValidator.java (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/DefaultValidator.java Sun Apr 8 06:49:40 2007
@@ -21,6 +21,7 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.fulcrum.intake.model.Field;
/**
* DefaultValidator that will compare a testValue against the following
@@ -39,6 +40,7 @@
* @author <a href="mailto:jmcnally@collab.net">John McNally</a>
* @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
* @author <a href="mailto:Colin.Chalmers@maxware.nl">Colin Chalmers</a>
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
* @version $Id$
*/
abstract public class DefaultValidator
@@ -126,11 +128,61 @@
}
/**
+ * Determine whether a field meets the criteria specified
+ * in the constraints defined for this validator
+ *
+ * @param field a <code>Field</code> to be tested
+ * @return true if valid, false otherwise
+ */
+ public boolean isValid(Field field)
+ {
+ boolean valid = false;
+ try
+ {
+ assertValidity(field);
+ valid = true;
+ }
+ catch (ValidationException ve)
+ {
+ valid = false;
+ }
+ return valid;
+ }
+
+ /**
+ * Determine whether a field meets the criteria specified
+ * in the constraints defined for this validator
+ *
+ * @param field a <code>Field</code> to be tested
+ * @exception ValidationException containing an error message if the
+ * testValue did not pass the validation tests.
+ */
+ public void assertValidity(Field field)
+ throws ValidationException
+ {
+ if (field.isMultiValued())
+ {
+ String[] stringValues = (String[])field.getTestValue();
+
+ for (int i = 0; i < stringValues.length; i++)
+ {
+ assertValidity(stringValues[i]);
+ }
+ }
+ else
+ {
+ assertValidity((String)field.getTestValue());
+ }
+ }
+
+ /**
* Determine whether a testValue meets the criteria specified
* in the constraints defined for this validator
*
* @param testValue a <code>String</code> to be tested
* @return true if valid, false otherwise
+ *
+ * @deprecated use isValid(Field) instead
*/
public boolean isValid(String testValue)
{
Modified: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/DoubleValidator.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/DoubleValidator.java?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/DoubleValidator.java (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/DoubleValidator.java Sun Apr 8 06:49:40 2007
@@ -16,9 +16,13 @@
* limitations under the License.
*/
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.Locale;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
+import org.apache.fulcrum.intake.model.Field;
/**
* Validates Doubles with the following constraints in addition to those
@@ -37,6 +41,7 @@
* @author <a href="mailto:jmcnally@collab.net">John McNally</a>
* @author <a href="mailto:Colin.Chalmers@maxware.nl">Colin Chalmers</a>
* @author <a href="mailto:jh@byteaction.de">Jürgen Hoffmann</a>
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
* @version $Id$
*/
public class DoubleValidator
@@ -97,14 +102,43 @@
}
/**
+ * Determine whether a field meets the criteria specified
+ * in the constraints defined for this validator
+ *
+ * @param field a <code>Field</code> to be tested
+ * @exception ValidationException containing an error message if the
+ * testValue did not pass the validation tests.
+ */
+ public void assertValidity(Field field)
+ throws ValidationException
+ {
+ Locale locale = field.getLocale();
+
+ if (field.isMultiValued())
+ {
+ String[] stringValues = (String[])field.getTestValue();
+
+ for (int i = 0; i < stringValues.length; i++)
+ {
+ assertValidity(stringValues[i], locale);
+ }
+ }
+ else
+ {
+ assertValidity((String)field.getTestValue(), locale);
+ }
+ }
+
+ /**
* Determine whether a testValue meets the criteria specified
* in the constraints defined for this validator
*
* @param testValue a <code>String</code> to be tested
+ * @param locale the Locale of the associated field
* @exception ValidationException containing an error message if the
* testValue did not pass the validation tests.
*/
- public void assertValidity(String testValue)
+ public void assertValidity(String testValue, Locale locale)
throws ValidationException
{
super.assertValidity(testValue);
@@ -113,11 +147,13 @@
if (required || StringUtils.isNotEmpty(testValue))
{
+ NumberFormat nf = NumberFormat.getInstance(locale);
+
try
{
- d = Double.parseDouble(testValue);
+ d = nf.parse(testValue).doubleValue();
}
- catch (RuntimeException e)
+ catch (ParseException e)
{
errorMessage = invalidNumberMessage;
throw new ValidationException(invalidNumberMessage);
@@ -128,6 +164,7 @@
errorMessage = minValueMessage;
throw new ValidationException(minValueMessage);
}
+
if (d > maxValue)
{
errorMessage = maxValueMessage;
@@ -180,4 +217,4 @@
{
this.maxValue = value;
}
-}
+}
\ No newline at end of file
Modified: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/FloatValidator.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/FloatValidator.java?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/FloatValidator.java (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/FloatValidator.java Sun Apr 8 06:49:40 2007
@@ -16,9 +16,13 @@
* limitations under the License.
*/
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.Locale;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
+import org.apache.fulcrum.intake.model.Field;
/**
* Validates Floats with the following constraints in addition to those
@@ -37,6 +41,7 @@
* @author <a href="mailto:jmcnally@collab.net">John McNally</a>
* @author <a href="mailto:Colin.Chalmers@maxware.nl">Colin Chalmers</a>
* @author <a href="mailto:jh@byteaction.de">Jürgen Hoffmann</a>
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
* @version $Id$
*/
public class FloatValidator
@@ -97,14 +102,43 @@
}
/**
+ * Determine whether a field meets the criteria specified
+ * in the constraints defined for this validator
+ *
+ * @param field a <code>Field</code> to be tested
+ * @exception ValidationException containing an error message if the
+ * testValue did not pass the validation tests.
+ */
+ public void assertValidity(Field field)
+ throws ValidationException
+ {
+ Locale locale = field.getLocale();
+
+ if (field.isMultiValued())
+ {
+ String[] stringValues = (String[])field.getTestValue();
+
+ for (int i = 0; i < stringValues.length; i++)
+ {
+ assertValidity(stringValues[i], locale);
+ }
+ }
+ else
+ {
+ assertValidity((String)field.getTestValue(), locale);
+ }
+ }
+
+ /**
* Determine whether a testValue meets the criteria specified
* in the constraints defined for this validator
*
* @param testValue a <code>String</code> to be tested
+ * @param locale the Locale of the associated field
* @exception ValidationException containing an error message if the
* testValue did not pass the validation tests.
*/
- public void assertValidity(String testValue)
+ public void assertValidity(String testValue, Locale locale)
throws ValidationException
{
super.assertValidity(testValue);
@@ -112,11 +146,13 @@
if (required || StringUtils.isNotEmpty(testValue))
{
float f = 0.0f;
+ NumberFormat nf = NumberFormat.getInstance(locale);
+
try
{
- f = Float.parseFloat(testValue);
+ f = nf.parse(testValue).floatValue();
}
- catch (RuntimeException e)
+ catch (ParseException e)
{
errorMessage = invalidNumberMessage;
throw new ValidationException(invalidNumberMessage);
Modified: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/InvalidMaskException.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/InvalidMaskException.java?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/InvalidMaskException.java (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/InvalidMaskException.java Sun Apr 8 06:49:40 2007
@@ -22,12 +22,18 @@
* An Exception indidate an invalid field mask.
*
* @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
* @version $Id$
*/
public class InvalidMaskException
extends IntakeException
{
/**
+ * Serial version
+ */
+ private static final long serialVersionUID = 7190367576315674427L;
+
+ /**
* Creates a new <code>InvalidMaskException</code> instance.
*
* @param message describing the reason validation failed.
Modified: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/StringValidator.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/StringValidator.java?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/StringValidator.java (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/StringValidator.java Sun Apr 8 06:49:40 2007
@@ -42,6 +42,7 @@
* @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
* @author <a href="mailto:Colin.Chalmers@maxware.nl">Colin Chalmers</a>
* @author <a href="mailto:jh@byteaction.de">Jürgen Hoffmann</a>
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
* @version $Id$
*/
public class StringValidator
@@ -99,28 +100,6 @@
maskMessage = constraint.getMessage();
}
- }
-
- /**
- * Determine whether a testValue meets the criteria specified
- * in the constraints defined for this validator
- *
- * @param testValue a <code>String</code> to be tested
- * @return true if valid, false otherwise
- */
- public boolean isValid(String testValue)
- {
- boolean valid = false;
- try
- {
- assertValidity(testValue);
- valid = true;
- }
- catch (ValidationException ve)
- {
- valid = false;
- }
- return valid;
}
/**
Modified: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/ValidationException.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/ValidationException.java?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/ValidationException.java (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/ValidationException.java Sun Apr 8 06:49:40 2007
@@ -23,12 +23,18 @@
*
* @author <a href="mailto:jmcnally@collab.net">John McNally</a>
* @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
* @version $Id$
*/
public class ValidationException
extends IntakeException
{
/**
+ * Serial version
+ */
+ private static final long serialVersionUID = -5934465742157387249L;
+
+ /**
* Creates a new <code>ValidationException</code> instance.
*
* @param message describing the reason validation failed.
Modified: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/Validator.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/Validator.java?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/Validator.java (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/Validator.java Sun Apr 8 06:49:40 2007
@@ -1,5 +1,7 @@
package org.apache.fulcrum.intake.validator;
+import org.apache.fulcrum.intake.model.Field;
+
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
@@ -20,6 +22,7 @@
* Validator api.
*
* @author <a href="mailto:jmcnally@collab.net">John McNally</a>
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
* @version $Id$
*/
public interface Validator
@@ -52,11 +55,33 @@
String REQUIRED_RULE_NAME = "required";
/**
+ * Determine whether a field meets the criteria specified
+ * in the constraints defined for this validator
+ *
+ * @param field a <code>Field</code> to be tested
+ * @return true if valid, false otherwise
+ */
+ boolean isValid(Field field);
+
+ /**
+ * Determine whether a field meets the criteria specified
+ * in the constraints defined for this validator
+ *
+ * @param field a <code>Field</code> to be tested
+ * @exception ValidationException containing an error message if the
+ * testValue did not pass the validation tests.
+ */
+ void assertValidity(Field field)
+ throws ValidationException;
+
+ /**
* Determine whether a testValue meets the criteria specified
* in the constraints defined for this validator
*
* @param testValue a <code>String</code> to be tested
* @return true if valid, false otherwise
+ *
+ * @deprecated use isValid(Field) instead
*/
boolean isValid(String testValue);
Modified: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/xmlmodel/AppData.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/xmlmodel/AppData.java?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/xmlmodel/AppData.java (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/xmlmodel/AppData.java Sun Apr 8 06:49:40 2007
@@ -31,11 +31,17 @@
*
* @author <a href="mailto:jmcnally@collab.net>John McNally</a>
* @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
* @version $Id$
*/
public class AppData
implements Serializable
{
+ /**
+ * Serial version id
+ */
+ private static final long serialVersionUID = -3953843038383617960L;
+
/** List of groups */
private List inputs;
Modified: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/xmlmodel/Rule.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/xmlmodel/Rule.java?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/xmlmodel/Rule.java (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/xmlmodel/Rule.java Sun Apr 8 06:49:40 2007
@@ -26,11 +26,17 @@
* A Class for holding data about a constraint on a property.
*
* @author <a href="mailto:jmcnally@collab.net">John McNally</a>
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
* @version $Id$
*/
public class Rule
implements Constraint, Serializable
{
+ /**
+ * Serial version id
+ */
+ private static final long serialVersionUID = -4059931768288150848L;
+
private String name;
private String value;
private String message;
Modified: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/xmlmodel/XmlField.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/xmlmodel/XmlField.java?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/xmlmodel/XmlField.java (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/xmlmodel/XmlField.java Sun Apr 8 06:49:40 2007
@@ -37,11 +37,17 @@
* @author <a href="mailto:jmcnally@collab.net">John McNally</a>
* @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
* @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
* @version $Id$
*/
public class XmlField
implements Serializable
{
+ /**
+ * Serial version id
+ */
+ private static final long serialVersionUID = -734309157828058007L;
+
private String name;
private String key;
private String type;
@@ -57,6 +63,7 @@
private String defaultValue;
private String emptyValue;
private String displaySize;
+ private String fieldClass;
/**
* Default Constructor
@@ -96,6 +103,7 @@
}
setMapToProperty(attrib.getValue("mapToProperty"));
+ setFieldClass(attrib.getValue("fieldClass"));
setValidator(attrib.getValue("validator"));
setDefaultValue(attrib.getValue("defaultValue"));
setEmptyValue(attrib.getValue("emptyValue"));
@@ -359,6 +367,26 @@
public void setIfRequiredMessage(String v)
{
this.ifRequiredMessage = v;
+ }
+
+ /**
+ * Get the value of fieldClass.
+ *
+ * @return value of fieldClass.
+ */
+ public String getFieldClass()
+ {
+ return fieldClass;
+ }
+
+ /**
+ * Set the value of fieldClass.
+ *
+ * @param v Value to assign to fieldClass.
+ */
+ public void setFieldClass(String v)
+ {
+ this.fieldClass = v;
}
/**
Modified: jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/xmlmodel/XmlGroup.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/xmlmodel/XmlGroup.java?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/xmlmodel/XmlGroup.java (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/xmlmodel/XmlGroup.java Sun Apr 8 06:49:40 2007
@@ -30,11 +30,17 @@
* A Class for holding data about a grouping of inputs used in an Application.
*
* @author <a href="mailto:jmcnally@collab.net>John McNally</a>
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
* @version $Id$
*/
public class XmlGroup
implements Serializable
{
+ /**
+ * Serial version id
+ */
+ private static final long serialVersionUID = 4771953823149519746L;
+
private List fields;
private List mapToObjects;
private String defaultMapToObject;
Modified: jakarta/turbine/fulcrum/trunk/intake/src/test/intake1.xml
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/test/intake1.xml?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/test/intake1.xml (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/test/intake1.xml Sun Apr 8 06:49:40 2007
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE input-data SYSTEM "http://jakarta.apache.org/turbine/dtd/intake_2_3.dtd">
+<!DOCTYPE input-data SYSTEM
+ "http://jakarta.apache.org/turbine/dtd/intake_2_4.dtd">
<input-data basePackage="org.apache.fulcrum.intake.test.">
<group name="LoginGroup" key="loginGroupKey" mapToObject="LoginForm">
<field name="Username" key="loginUsernameKey" type="String"
@@ -16,6 +17,8 @@
<field name="RequiredBooleanTestField" key="rbtf" type="boolean">
<rule value="true" name="required">ValidValue</rule>
</field>
+ <field name="TestCustomTypeField" key="tctf" type="custom"
+ fieldClass="org.apache.fulcrum.intake.test.MyField" />
</group>
</input-data>
Modified: jakarta/turbine/fulcrum/trunk/intake/src/test/intake2.xml
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/test/intake2.xml?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/test/intake2.xml (original)
+++ jakarta/turbine/fulcrum/trunk/intake/src/test/intake2.xml Sun Apr 8 06:49:40 2007
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE input-data SYSTEM
- "http://jakarta.apache.org/turbine/dtd/intake_2_3.dtd">
+ "http://jakarta.apache.org/turbine/dtd/intake_2_4.dtd">
<input-data basePackage="org.apache.fulcrum.intake.test.">
<group name="AnotherGroup" key="anotherGroupKey" mapToObject="AnotherForm">
<field name="Username" key="loginUsernameKey" type="String"
Added: jakarta/turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/test/MyField.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/test/MyField.java?view=auto&rev=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/test/MyField.java (added)
+++ jakarta/turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/test/MyField.java Sun Apr 8 06:49:40 2007
@@ -0,0 +1,17 @@
+package org.apache.fulcrum.intake.test;
+
+import org.apache.fulcrum.intake.IntakeException;
+import org.apache.fulcrum.intake.model.Group;
+import org.apache.fulcrum.intake.model.StringField;
+import org.apache.fulcrum.intake.xmlmodel.XmlField;
+
+public class MyField extends StringField
+{
+
+ public MyField(XmlField field, Group group) throws IntakeException
+ {
+ super(field, group);
+ log.info("Instance of MyField created.");
+ }
+
+}
Modified: jakarta/turbine/fulcrum/trunk/intake/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/intake/xdocs/changes.xml?view=diff&rev=526554&r1=526553&r2=526554
==============================================================================
--- jakarta/turbine/fulcrum/trunk/intake/xdocs/changes.xml (original)
+++ jakarta/turbine/fulcrum/trunk/intake/xdocs/changes.xml Sun Apr 8 06:49:40 2007
@@ -7,7 +7,10 @@
</properties>
<body>
- <release version="1.0.3" date="in Subversion">
+ <release version="1.0.4-dev" date="in Subversion">
+ <action type="add" dev="tv">
+ Added locale handling to Intake, added user-defined field types.
+ </action>
<action type="update" dev="seade" issue="TRB-9" due-to="Jürgen Hoffmann">
Intake now handles the case where the mapToObject does not map to all
fields in the group.
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org