You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jm...@apache.org on 2001/08/30 07:23:58 UTC
cvs commit: jakarta-turbine-fulcrum/src/util/java/org/apache/fulcrum/util/parser DefaultParameterParser.java
jmcnally 01/08/29 22:23:57
Modified: src/services/java/org/apache/fulcrum/intake Intake.java
IntakeService.java TurbineIntake.java
src/services/java/org/apache/fulcrum/intake/model
BigDecimalField.java BooleanField.java
ComboKeyField.java Field.java FileItemField.java
Group.java IntegerField.java NumberKeyField.java
StringField.java
src/util/java/org/apache/fulcrum/util/parser
DefaultParameterParser.java
Log:
base most of Intake on a ValueParser as ParameterParser is only needed for
FileItemField, so the rest of intake is applicable to non http specific
parameters.
also fixed an npe in Group.removeFromRequest
Revision Changes Path
1.3 +4 -4 jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/Intake.java
Index: Intake.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/Intake.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Intake.java 2001/08/27 20:17:08 1.2
+++ Intake.java 2001/08/30 05:23:57 1.3
@@ -63,7 +63,7 @@
import org.apache.fulcrum.Log;
import org.apache.fulcrum.pool.Recyclable;
import org.apache.torque.om.Retrievable;
-import org.apache.fulcrum.util.parser.ParameterParser;
+import org.apache.fulcrum.util.parser.ValueParser;
import org.apache.fulcrum.intake.model.Group;
import org.apache.fulcrum.intake.TurbineIntake;
@@ -71,14 +71,14 @@
* The main class through which Intake is accessed.
*
* @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
- * @version $Id: Intake.java,v 1.2 2001/08/27 20:17:08 jon Exp $
+ * @version $Id: Intake.java,v 1.3 2001/08/30 05:23:57 jmcnally Exp $
*/
public class Intake
implements Recyclable
{
public static final String DEFAULT_KEY = "_0";
private HashMap groups;
- private ParameterParser pp;
+ private ValueParser pp;
HashMap declaredGroups = new HashMap();
StringBuffer allGroupsSB = new StringBuffer(256);
@@ -103,7 +103,7 @@
/**
* Prepares intake for a single request
*/
- public void init(ParameterParser pp)
+ public void init(ValueParser pp)
{
this.pp = pp;
String[] groupKeys = pp.getStrings("intake-grp");
1.2 +6 -6 jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/IntakeService.java
Index: IntakeService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/IntakeService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- IntakeService.java 2001/08/23 07:20:21 1.1
+++ IntakeService.java 2001/08/30 05:23:57 1.2
@@ -57,7 +57,7 @@
import java.lang.reflect.Method;
import org.apache.fulcrum.ServiceException;
import org.apache.fulcrum.pool.Recyclable;
-import org.apache.fulcrum.util.parser.ParameterParser;
+import org.apache.fulcrum.util.parser.ValueParser;
import org.apache.fulcrum.intake.model.Group;
/**
@@ -65,7 +65,7 @@
* on an XML specification.
*
* @author <a href="mailto:jmcnally@collab.net">John McNally</a>
- * @version $Id: IntakeService.java,v 1.1 2001/08/23 07:20:21 jmcnally Exp $
+ * @version $Id: IntakeService.java,v 1.2 2001/08/30 05:23:57 jmcnally Exp $
*/
public interface IntakeService
{
@@ -98,7 +98,7 @@
/**
* Gets an instance of a named group either from the pool
* or by calling the Factory Service if the pool is empty and
- * then initialize it using the ParameterParser looking for
+ * then initialize it using the ValueParser looking for
* a NEW id.
*
* @param groupName the name of the group.
@@ -106,20 +106,20 @@
* @return a Group instance.
* @throws ServiceException if recycling fails.
* /
- public Group getGroup(String groupName, ParameterParser pp)
+ public Group getGroup(String groupName, ValueParser pp)
throws Exception;
/**
* Gets an instance of a named group either from the pool
* or by calling the Factory Service if the pool is empty and
- * then initialize it using the ParameterParser looking for id.
+ * then initialize it using the ValueParser looking for id.
*
* @param groupName the name of the group.
* @param pp the request parameters that may contain matching keys
* @return a Group instance.
* @throws ServiceException if recycling fails.
* /
- public Group getGroup(String groupName, ParameterParser pp, String id)
+ public Group getGroup(String groupName, ValueParser pp, String id)
throws Exception;
*/
1.2 +5 -5 jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/TurbineIntake.java
Index: TurbineIntake.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/TurbineIntake.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TurbineIntake.java 2001/08/23 07:20:21 1.1
+++ TurbineIntake.java 2001/08/30 05:23:57 1.2
@@ -67,7 +67,7 @@
* the settings in TurbineResources.
*
* @author <a href="mailto:jmcnally@collab.net">John McNally</a>
- * @version $Id: TurbineIntake.java,v 1.1 2001/08/23 07:20:21 jmcnally Exp $
+ * @version $Id: TurbineIntake.java,v 1.2 2001/08/30 05:23:57 jmcnally Exp $
*/
public abstract class TurbineIntake
{
@@ -93,7 +93,7 @@
/**
* Gets an instance of a named group either from the pool
* or by calling the Factory Service if the pool is empty and
- * then initialize it using the ParameterParser looking for
+ * then initialize it using the ValueParser looking for
* a NEW id.
*
* @param groupName the name of the group.
@@ -101,7 +101,7 @@
* @return a Group instance.
* @throws ServiceException if recycling fails.
* /
- public static Group getGroup(String groupName, ParameterParser pp)
+ public static Group getGroup(String groupName, ValueParser pp)
throws Exception
{
return getService().getGroup(groupName, pp);
@@ -110,7 +110,7 @@
/**
* Gets an instance of a named group either from the pool
* or by calling the Factory Service if the pool is empty and
- * then initialize it using the ParameterParser looking for id.
+ * then initialize it using the ValueParser looking for id.
*
* @param groupName the name of the group.
* @param pp the request parameters that may contain matching keys
@@ -118,7 +118,7 @@
* @throws ServiceException if recycling fails.
* /
public static Group getGroup(String groupName,
- ParameterParser pp, String id)
+ ValueParser pp, String id)
throws Exception
{
return getService().getGroup(groupName, pp, id);
1.2 +2 -2 jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/model/BigDecimalField.java
Index: BigDecimalField.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/model/BigDecimalField.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BigDecimalField.java 2001/08/23 07:20:21 1.1
+++ BigDecimalField.java 2001/08/30 05:23:57 1.2
@@ -58,7 +58,7 @@
import java.util.Vector;
import org.apache.fulcrum.intake.xmlmodel.Rule;
import org.apache.fulcrum.intake.xmlmodel.XmlField;
-import org.apache.fulcrum.util.parser.ParameterParser;
+import org.apache.fulcrum.util.parser.ValueParser;
/** */
public class BigDecimalField extends Field
@@ -82,7 +82,7 @@
/**
* converts the parameter to the correct Object.
*/
- protected void doSetValue(ParameterParser pp)
+ protected void doSetValue(ValueParser pp)
{
if ( isMultiValued )
{
1.2 +3 -3 jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/model/BooleanField.java
Index: BooleanField.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/model/BooleanField.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BooleanField.java 2001/08/23 07:20:21 1.1
+++ BooleanField.java 2001/08/30 05:23:57 1.2
@@ -56,13 +56,13 @@
import org.apache.fulcrum.intake.xmlmodel.XmlField;
import org.apache.fulcrum.Log;
-import org.apache.fulcrum.util.parser.ParameterParser;
+import org.apache.fulcrum.util.parser.ValueParser;
/**
* Base class for Intake generated input processing classes.
*
* @author <a href="mailto:jmcnally@collab.net>John McNally</a>
- * @version $Id: BooleanField.java,v 1.1 2001/08/23 07:20:21 jmcnally Exp $
+ * @version $Id: BooleanField.java,v 1.2 2001/08/30 05:23:57 jmcnally Exp $
*/
public class BooleanField extends Field
{
@@ -85,7 +85,7 @@
/**
* converts the parameter to the correct Object.
*/
- protected void doSetValue(ParameterParser pp)
+ protected void doSetValue(ValueParser pp)
{
setTestValue( pp.getBool(getKey()) );
}
1.2 +2 -2 jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/model/ComboKeyField.java
Index: ComboKeyField.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/model/ComboKeyField.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ComboKeyField.java 2001/08/23 07:20:21 1.1
+++ ComboKeyField.java 2001/08/30 05:23:57 1.2
@@ -55,7 +55,7 @@
*/
import java.util.Vector;
-import org.apache.fulcrum.util.parser.ParameterParser;
+import org.apache.fulcrum.util.parser.ValueParser;
import org.apache.torque.om.ComboKey;
import org.apache.torque.om.ObjectKey;
import org.apache.fulcrum.intake.xmlmodel.Rule;
@@ -75,7 +75,7 @@
/**
* converts the parameter to the correct Object.
*/
- protected void doSetValue(ParameterParser pp)
+ protected void doSetValue(ValueParser pp)
{
try
{
1.2 +7 -7 jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/model/Field.java
Index: Field.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/model/Field.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Field.java 2001/08/23 07:20:21 1.1
+++ Field.java 2001/08/30 05:23:57 1.2
@@ -57,7 +57,7 @@
import java.util.Map;
import java.lang.reflect.Method;
import org.apache.regexp.RE;
-import org.apache.fulcrum.util.parser.ParameterParser;
+import org.apache.fulcrum.util.parser.ValueParser;
import org.apache.torque.om.Retrievable;
import org.apache.fulcrum.intake.TurbineIntake;
import org.apache.fulcrum.intake.xmlmodel.Rule;
@@ -73,7 +73,7 @@
* Base class for Intake generated input processing classes.
*
* @author <a href="mailto:jmcnally@collab.net>John McNally</a>
- * @version $Id: Field.java,v 1.1 2001/08/23 07:20:21 jmcnally Exp $
+ * @version $Id: Field.java,v 1.2 2001/08/30 05:23:57 jmcnally Exp $
*/
public abstract class Field
{
@@ -109,7 +109,7 @@
private Object[] valArray; // for reflection
/** The object containing the request data */
- protected ParameterParser pp;
+ protected ValueParser pp;
/**
* Constructs a field based on data in the xml specification
@@ -180,11 +180,11 @@
* if a value has been supplied for this field. if so, the value
* is validated.
*
- * @param pp a <code>ParameterParser</code> value
+ * @param pp a <code>ValueParser</code> value
* @return a <code>Field</code> value
* @exception ServiceException if an error occurs
*/
- public Field init(ParameterParser pp)
+ public Field init(ValueParser pp)
throws ServiceException
{
this.pp = pp;
@@ -404,7 +404,7 @@
/**
* Compares request data with constraints and sets the valid flag.
*/
- protected boolean validate(ParameterParser pp)
+ protected boolean validate(ValueParser pp)
// throws ServiceException
{
if ( isMultiValued )
@@ -476,7 +476,7 @@
* Compares request data with constraints and sets the valid flag.
* To be implemented in subclasses
*/
- protected abstract void doSetValue(ParameterParser pp);
+ protected abstract void doSetValue(ValueParser pp);
1.2 +16 -4 jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/model/FileItemField.java
Index: FileItemField.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/model/FileItemField.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FileItemField.java 2001/08/23 07:20:21 1.1
+++ FileItemField.java 2001/08/30 05:23:57 1.2
@@ -57,6 +57,7 @@
import java.util.Vector;
import org.apache.fulcrum.intake.xmlmodel.Rule;
import org.apache.fulcrum.intake.xmlmodel.XmlField;
+import org.apache.fulcrum.util.parser.ValueParser;
import org.apache.fulcrum.util.parser.ParameterParser;
import org.apache.fulcrum.intake.validator.Validator;
import org.apache.fulcrum.intake.validator.FileValidator;
@@ -96,10 +97,19 @@
* @return a <code>Field</code> value
* @exception ServiceException if an error occurs
*/
- public Field init(ParameterParser pp)
+ public Field init(ValueParser vp)
throws ServiceException
{
- this.pp = pp;
+ try
+ {
+ this.pp = (ParameterParser)vp;
+ }
+ catch (ClassCastException e)
+ {
+ throw new ServiceException(
+ "FileItemFields can only be used with ParameterParser");
+ }
+
valid_flag = true;
if ( pp.containsKey(getKey()) )
@@ -115,9 +125,10 @@
/**
* Compares request data with constraints and sets the valid flag.
*/
- protected boolean validate(ParameterParser pp)
+ protected boolean validate(ValueParser vp)
// throws ServiceException
{
+ ParameterParser pp = (ParameterParser)vp;
if ( isMultiValued )
{
FileItem[] ss = pp.getFileItems(getKey());
@@ -185,8 +196,9 @@
/**
* converts the parameter to the correct Object.
*/
- protected void doSetValue(ParameterParser pp)
+ protected void doSetValue(ValueParser vp)
{
+ ParameterParser pp = (ParameterParser)vp;
if ( isMultiValued )
{
setTestValue(pp.getFileItems(getKey()));
1.3 +20 -17 jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/model/Group.java
Index: Group.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/model/Group.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Group.java 2001/08/27 20:17:08 1.2
+++ Group.java 2001/08/30 05:23:57 1.3
@@ -64,7 +64,7 @@
import org.apache.fulcrum.intake.TurbineIntake;
import org.apache.fulcrum.intake.xmlmodel.XmlField;
import org.apache.fulcrum.intake.xmlmodel.XmlGroup;
-import org.apache.fulcrum.util.parser.ParameterParser;
+import org.apache.fulcrum.util.parser.ValueParser;
import org.apache.fulcrum.ServiceException;
import org.apache.fulcrum.pool.Recyclable;
@@ -119,7 +119,7 @@
/**
* The object containing the request data
*/
- protected ParameterParser pp;
+ protected ValueParser pp;
/**
* A flag to help prevent duplicate hidden fields declaring this group.
@@ -177,10 +177,10 @@
/**
* Initializes the default Group using parameters.
*
- * @param pp a <code>ParameterParser</code> value
+ * @param pp a <code>ValueParser</code> value
* @return this Group
*/
- public Group init(ParameterParser pp) throws ServiceException
+ public Group init(ValueParser pp) throws ServiceException
{
return init(NEW, pp);
}
@@ -192,7 +192,7 @@
* @param data a <code>RunData</code> value
* @return this Group
*/
- public Group init(String key, ParameterParser pp)
+ public Group init(String key, ValueParser pp)
throws ServiceException
{
this.oid = key;
@@ -306,11 +306,11 @@
/**
* Describe <code>getObjects</code> method here.
*
- * @param pp a <code>ParameterParser</code> value
+ * @param pp a <code>ValueParser</code> value
* @return an <code>ArrayList</code> value
* @exception ServiceException if an error occurs
*/
- public ArrayList getObjects(ParameterParser pp)
+ public ArrayList getObjects(ValueParser pp)
throws ServiceException
{
ArrayList objs = null;
@@ -413,20 +413,23 @@
*/
public void removeFromRequest()
{
- String[] groups = pp.getStrings(gid);
- if ( groups != null )
+ if (pp != null)
{
- pp.remove(gid);
- for (int i=0; i<groups.length; i++)
+ String[] groups = pp.getStrings(gid);
+ if ( groups != null )
{
- if ( groups[i] != null && !groups[i].equals(oid) )
+ pp.remove(gid);
+ for (int i=0; i<groups.length; i++)
{
- pp.add(gid,groups[i]);
+ if ( groups[i] != null && !groups[i].equals(oid) )
+ {
+ pp.add(gid,groups[i]);
+ }
}
- }
- for (int i=fieldsArray.length-1; i>=0; i--)
- {
- fieldsArray[i].removeFromRequest();
+ for (int i=fieldsArray.length-1; i>=0; i--)
+ {
+ fieldsArray[i].removeFromRequest();
+ }
}
}
}
1.2 +2 -2 jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/model/IntegerField.java
Index: IntegerField.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/model/IntegerField.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- IntegerField.java 2001/08/23 07:20:21 1.1
+++ IntegerField.java 2001/08/30 05:23:57 1.2
@@ -57,7 +57,7 @@
import java.util.Vector;
import org.apache.fulcrum.intake.xmlmodel.Rule;
import org.apache.fulcrum.intake.xmlmodel.XmlField;
-import org.apache.fulcrum.util.parser.ParameterParser;
+import org.apache.fulcrum.util.parser.ValueParser;
/** */
public class IntegerField extends Field
@@ -82,7 +82,7 @@
/**
* converts the parameter to the correct Object.
*/
- protected void doSetValue(ParameterParser pp)
+ protected void doSetValue(ValueParser pp)
{
if ( isMultiValued )
{
1.2 +2 -2 jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/model/NumberKeyField.java
Index: NumberKeyField.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/model/NumberKeyField.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NumberKeyField.java 2001/08/23 07:20:21 1.1
+++ NumberKeyField.java 2001/08/30 05:23:57 1.2
@@ -59,7 +59,7 @@
import org.apache.torque.om.ObjectKey;
import org.apache.fulcrum.intake.xmlmodel.Rule;
import org.apache.fulcrum.intake.xmlmodel.XmlField;
-import org.apache.fulcrum.util.parser.ParameterParser;
+import org.apache.fulcrum.util.parser.ValueParser;
/** */
public class NumberKeyField extends Field
@@ -86,7 +86,7 @@
/**
* converts the parameter to the correct Object.
*/
- protected void doSetValue(ParameterParser pp)
+ protected void doSetValue(ValueParser pp)
{
if ( isMultiValued )
{
1.2 +3 -3 jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/model/StringField.java
Index: StringField.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/intake/model/StringField.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StringField.java 2001/08/23 07:20:21 1.1
+++ StringField.java 2001/08/30 05:23:57 1.2
@@ -54,14 +54,14 @@
* <http://www.apache.org/>.
*/
-import org.apache.fulcrum.util.parser.ParameterParser;
+import org.apache.fulcrum.util.parser.ValueParser;
import org.apache.fulcrum.intake.xmlmodel.XmlField;
/**
* Base class for Intake generated input processing classes.
*
* @author <a href="mailto:jmcnally@collab.net>John McNally</a>
- * @version $Id: StringField.java,v 1.1 2001/08/23 07:20:21 jmcnally Exp $
+ * @version $Id: StringField.java,v 1.2 2001/08/30 05:23:57 jmcnally Exp $
*/
public class StringField extends Field
{
@@ -74,7 +74,7 @@
/**
* converts the parameter to the correct Object.
*/
- protected void doSetValue(ParameterParser pp)
+ protected void doSetValue(ValueParser pp)
{
if ( isMultiValued )
{
1.2 +4 -1 jakarta-turbine-fulcrum/src/util/java/org/apache/fulcrum/util/parser/DefaultParameterParser.java
Index: DefaultParameterParser.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/src/util/java/org/apache/fulcrum/util/parser/DefaultParameterParser.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultParameterParser.java 2001/08/20 00:15:20 1.1
+++ DefaultParameterParser.java 2001/08/30 05:23:57 1.2
@@ -88,7 +88,7 @@
* @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
* @author <a href="mailto:jon@clearink.com">Jon S. Stevens</a>
* @author <a href="mailto:sean@informage.net">Sean Legassick</a>
- * @version $Id: DefaultParameterParser.java,v 1.1 2001/08/20 00:15:20 mpoeschl Exp $
+ * @version $Id: DefaultParameterParser.java,v 1.2 2001/08/30 05:23:57 jmcnally Exp $
*/
public class DefaultParameterParser
extends BaseValueParser
@@ -221,6 +221,9 @@
// if they are query string data.
try
{
+ // the lines below can be substituted with the method
+ // parse(req.getPathInfo(), '/', true);
+ // if DefaultParameterParser extended StringParser
StringTokenizer st = new StringTokenizer(req.getPathInfo(), "/");
boolean isNameTok = true;
String pathPart = null;
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org