You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jv...@apache.org on 2001/07/13 18:50:51 UTC
cvs commit: jakarta-turbine/src/java/org/apache/turbine/util/parser CSVParser.java CookieParser.java DataStreamParser.java TSVParser.java ValueParser.java BaseValueParser.java DefaultCookieParser.java DefaultParameterParser.java
jvanzyl 01/07/13 09:50:48
Modified: src/java/org/apache/turbine/util DynamicURI.java
ParameterParser.java RunDataFactory.java
src/java/org/apache/turbine/util/parser BaseValueParser.java
DefaultCookieParser.java
DefaultParameterParser.java
Added: src/java/org/apache/turbine/util/parser CSVParser.java
CookieParser.java DataStreamParser.java
TSVParser.java ValueParser.java
Removed: src/java/org/apache/turbine/util CSVParser.java
CookieParser.java DataStreamParser.java
TSVParser.java ValueParser.java
Log:
- organized the parser utils into their own package
Revision Changes Path
1.16 +10 -6 jakarta-turbine/src/java/org/apache/turbine/util/DynamicURI.java
Index: DynamicURI.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/DynamicURI.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- DynamicURI.java 2001/07/10 01:04:48 1.15
+++ DynamicURI.java 2001/07/13 16:49:09 1.16
@@ -60,9 +60,7 @@
import java.util.Vector;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.ecs.GenericElement;
-import org.apache.ecs.html.A;
-import org.apache.turbine.services.resources.TurbineResources;
+import org.apache.turbine.Turbine;
import org.apache.turbine.util.parser.BaseValueParser;
/**
@@ -85,7 +83,7 @@
*
* @author <a href="mailto:jon@clearink.com">Jon S. Stevens</a>
* @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
- * @version $Id: DynamicURI.java,v 1.15 2001/07/10 01:04:48 jvanzyl Exp $
+ * @version $Id: DynamicURI.java,v 1.16 2001/07/13 16:49:09 jvanzyl Exp $
*/
public class DynamicURI
{
@@ -569,7 +567,13 @@
*/
public String getA( String name )
{
- return new A(this.toString(), name).toString();
+ return new StringBuffer("<a href=\"")
+ .append(this.toString())
+ .append("\">")
+ .append(name)
+ .append("</a>")
+ .toString();
+ //return new A(this.toString(), name).toString();
}
/**
@@ -900,7 +904,7 @@
*/
public DynamicURI setSecure(int port)
{
- boolean isSSL = TurbineResources.getBoolean("use.ssl", true);
+ boolean isSSL = Turbine.getConfiguration().getBoolean("use.ssl", true);
if (isSSL)
{
setServerScheme(DynamicURI.HTTPS);
1.32 +2 -1 jakarta-turbine/src/java/org/apache/turbine/util/ParameterParser.java
Index: ParameterParser.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/ParameterParser.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- ParameterParser.java 2001/06/25 04:52:06 1.31
+++ ParameterParser.java 2001/07/13 16:49:16 1.32
@@ -56,6 +56,7 @@
import javax.servlet.http.HttpServletRequest;
import org.apache.turbine.services.upload.FileItem;
+import org.apache.turbine.util.parser.ValueParser;
/**
* ParameterParser is an interface to a utility to handle parsing and
@@ -79,7 +80,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: ParameterParser.java,v 1.31 2001/06/25 04:52:06 jvanzyl Exp $
+ * @version $Id: ParameterParser.java,v 1.32 2001/07/13 16:49:16 jvanzyl Exp $
*/
public interface ParameterParser
extends ValueParser
1.14 +1 -4 jakarta-turbine/src/java/org/apache/turbine/util/RunDataFactory.java
Index: RunDataFactory.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/RunDataFactory.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- RunDataFactory.java 2001/07/10 01:04:50 1.13
+++ RunDataFactory.java 2001/07/13 16:49:22 1.14
@@ -56,18 +56,15 @@
import org.apache.turbine.RunData;
import java.io.IOException;
-
import javax.servlet.ServletConfig;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.apache.turbine.services.TurbineServices;
import org.apache.turbine.services.pool.PoolService;
import org.apache.turbine.services.rundata.RunDataService;
import org.apache.turbine.services.rundata.TurbineRunData;
import org.apache.turbine.services.rundata.DefaultTurbineRunData;
-
import org.apache.turbine.util.parser.DefaultCookieParser;
import org.apache.turbine.util.parser.DefaultParameterParser;
@@ -78,7 +75,7 @@
* @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
* @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
- * @version $Id: RunDataFactory.java,v 1.13 2001/07/10 01:04:50 jvanzyl Exp $
+ * @version $Id: RunDataFactory.java,v 1.14 2001/07/13 16:49:22 jvanzyl Exp $
*/
public class RunDataFactory
{
1.17 +12 -16 jakarta-turbine/src/java/org/apache/turbine/util/parser/BaseValueParser.java
Index: BaseValueParser.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/parser/BaseValueParser.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- BaseValueParser.java 2001/07/02 20:00:06 1.16
+++ BaseValueParser.java 2001/07/13 16:50:04 1.17
@@ -57,31 +57,22 @@
import java.beans.IndexedPropertyDescriptor;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
-
import java.io.UnsupportedEncodingException;
-
import java.lang.reflect.Method;
-
import java.math.BigDecimal;
-
import java.text.DateFormat;
import java.text.ParseException;
-
import java.util.Calendar;
import java.util.Date;
import java.util.Enumeration;
import java.util.GregorianCalendar;
import java.util.Hashtable;
-
+import org.apache.turbine.Turbine;
import org.apache.turbine.services.db.om.NumberKey;
import org.apache.turbine.services.db.om.StringKey;
-
-import org.apache.turbine.services.resources.TurbineResources;
-
import org.apache.turbine.util.DateSelector;
import org.apache.turbine.util.StringUtils;
import org.apache.turbine.util.TimeSelector;
-import org.apache.turbine.util.ValueParser;
import org.apache.turbine.util.pool.Recyclable;
import org.apache.turbine.util.pool.RecyclableSupport;
@@ -111,7 +102,7 @@
* @author <a href="mailto:jon@clearink.com">Jon S. Stevens</a>
* @author <a href="mailto:sean@informage.net">Sean Legassick</a>
* @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
- * @version $Id: BaseValueParser.java,v 1.16 2001/07/02 20:00:06 jmcnally Exp $
+ * @version $Id: BaseValueParser.java,v 1.17 2001/07/13 16:50:04 jvanzyl Exp $
*/
public class BaseValueParser
extends RecyclableSupport
@@ -139,15 +130,18 @@
public static String convertAndTrim ( String value )
{
String tmp = value.trim();
- String fold =
- TurbineResources.getString(URL_CASE_FOLDING, "")
- .toLowerCase();
- if ((fold == null) ||
- (fold.equals("")) ||
+ String fold = Turbine.getConfiguration().getString(
+ Turbine.PP_URL_CASE_FOLDING, "").toLowerCase();
+
+ if ((fold == null) || (fold.equals("")) ||
(fold.equals(URL_CASE_FOLDING_LOWER)))
+ {
return (tmp.toLowerCase());
+ }
else if (fold.equals(URL_CASE_FOLDING_UPPER))
+ {
return (tmp.toUpperCase());
+ }
return (tmp);
}
@@ -186,7 +180,9 @@
{
setCharacterEncoding(characterEncoding);
if (!isDisposed())
+ {
super.recycle();
+ }
}
/**
1.4 +1 -3 jakarta-turbine/src/java/org/apache/turbine/util/parser/DefaultCookieParser.java
Index: DefaultCookieParser.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/parser/DefaultCookieParser.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultCookieParser.java 2001/07/10 01:05:03 1.3
+++ DefaultCookieParser.java 2001/07/13 16:50:14 1.4
@@ -57,11 +57,9 @@
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.apache.turbine.util.Log;
import org.apache.turbine.RunData;
import org.apache.turbine.util.DynamicURI;
-import org.apache.turbine.util.CookieParser;
import org.apache.turbine.util.pool.Recyclable;
/**
@@ -89,7 +87,7 @@
*
* @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
* @author <a href="mailto:leon@opticode.co.za">Leon Messerschmidt</a>
- * @version $Id: DefaultCookieParser.java,v 1.3 2001/07/10 01:05:03 jvanzyl Exp $
+ * @version $Id: DefaultCookieParser.java,v 1.4 2001/07/13 16:50:14 jvanzyl Exp $
*/
public class DefaultCookieParser
extends BaseValueParser
1.9 +2 -2 jakarta-turbine/src/java/org/apache/turbine/util/parser/DefaultParameterParser.java
Index: DefaultParameterParser.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/parser/DefaultParameterParser.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DefaultParameterParser.java 2001/07/02 00:33:14 1.8
+++ DefaultParameterParser.java 2001/07/13 16:50:19 1.9
@@ -61,7 +61,7 @@
import java.util.StringTokenizer;
import javax.servlet.http.HttpServletRequest;
import org.apache.turbine.util.Log;
-import org.apache.turbine.util.ParameterParser;
+import org.apache.turbine.ParameterParser;
import org.apache.turbine.util.TurbineException;
import org.apache.turbine.util.pool.Recyclable;
import org.apache.turbine.services.upload.FileItem;
@@ -89,7 +89,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.8 2001/07/02 00:33:14 jvanzyl Exp $
+ * @version $Id: DefaultParameterParser.java,v 1.9 2001/07/13 16:50:19 jvanzyl Exp $
*/
public class DefaultParameterParser
extends BaseValueParser
1.1 jakarta-turbine/src/java/org/apache/turbine/util/parser/CSVParser.java
Index: CSVParser.java
===================================================================
package org.apache.turbine.util.parser;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Turbine" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import java.io.Reader;
import java.io.StreamTokenizer;
import java.util.List;
/**
* CSVParser is used to parse a stream with comma-separated values and
* generate ParameterParser objects which can be used to
* extract the values in the desired type.
*
* <p>The class extends the abstract class DataStreamParser and implements
* initTokenizer with suitable values for CSV files to provide this
* functionality.
*
* <p>The class (indirectly through DataStreamParser) implements the
* java.util.Iterator interface for convenience.
* This allows simple use in a Velocity template for example:
*
* <pre>
* #foreach ($row in $csvfile)
* Name: $row.Name
* Description: $row.Description
* #end
* </pre>
*
* @author <a href="mailto:sean@informage.net">Sean Legassick</a>
* @version $Id: CSVParser.java,v 1.1 2001/07/13 16:50:10 jvanzyl Exp $
*/
public class CSVParser extends DataStreamParser
{
/**
* Create a new CSVParser instance. Requires a Reader to read the
* comma-separated values from. The column headers must be set
* independently either explicitly, or by reading the first line
* of the CSV values.
*
* @param in the input reader.
*/
public CSVParser(Reader in)
{
super(in, null, null);
}
/**
* Create a new CSVParser instance. Requires a Reader to read the
* comma-separated values from, and a list of column names.
*
* @param in the input reader.
* @param columnNames a list of column names.
*/
public CSVParser(Reader in, List columnNames)
{
super(in, columnNames, null);
}
/**
* Create a new CSVParser instance. Requires a Reader to read the
* comma-separated values from, a list of column names and a
* character encoding.
*
* @param in the input reader.
* @param columnNames a list of column names.
* @param characterEncoding the character encoding of the input.
*/
public CSVParser(Reader in, List columnNames, String characterEncoding)
{
super(in, columnNames, characterEncoding);
}
/**
* Initialize the StreamTokenizer instance used to read the lines
* from the input reader.
*/
protected void initTokenizer(StreamTokenizer tokenizer)
{
// set all numeric characters as ordinary characters
// (switches off number parsing)
tokenizer.ordinaryChars('0', '9');
tokenizer.ordinaryChars('-', '-');
tokenizer.ordinaryChars('.', '.');
// set all printable characters to be treated as word chars
tokenizer.wordChars(' ', Integer.MAX_VALUE);
// now set comma as the whitespace character
tokenizer.whitespaceChars(',', ',');
// and set the quote mark as the quoting character
tokenizer.quoteChar('"');
// and finally say that end of line is significant
tokenizer.eolIsSignificant(true);
}
}
1.1 jakarta-turbine/src/java/org/apache/turbine/util/parser/CookieParser.java
Index: CookieParser.java
===================================================================
package org.apache.turbine.util.parser;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Turbine" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import org.apache.turbine.RunData;
import org.apache.turbine.util.DynamicURI;
/**
* CookieParser is an interface to a utility to to get and set values
* of Cookies on the Client Browser. You can use CookieParser to convert
* Cookie values to various types or to set Bean values with setParameters().
* Servlet Spec for more information on Cookies.
* <p>
* Use set() or unset() to Create or Destroy Cookies.
* <p>
* NOTE: The name= portion of a name=value pair may be converted
* to lowercase or uppercase when the object is initialized and when
* new data is added. This behaviour is determined by the url.case.folding
* property in TurbineResources.properties. Adding a name/value pair may
* overwrite existing name=value pairs if the names match:
*
* <pre>
* CookieParser cp = data.getCookies();
* cp.add("ERROR",1);
* cp.add("eRrOr",2);
* int result = cp.getInt("ERROR");
* </pre>
*
* In the above example, result is 2.
*
* @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
* @author <a href="mailto:leon@opticode.co.za">Leon Messerschmidt</a>
* @version $Id: CookieParser.java,v 1.1 2001/07/13 16:50:12 jvanzyl Exp $
*/
public interface CookieParser
extends ValueParser
{
public static final int AGE_SESSION = -1;
public static final int AGE_DELETE = 0;
/**
* Gets the parsed RunData.
*
* @return the parsed RunData object or null.
*/
public RunData getRunData();
/**
* Sets the RunData to be parsed.
* All previous cookies will be cleared.
*
* @param data the RunData object.
*/
public void setRunData (RunData data);
/**
* Get the Path where cookies will be stored
*/
public DynamicURI getCookiePath();
/**
* Set the path for cookie storage
*/
public void setCookiePath (DynamicURI path);
/**
* Set a cookie that will be stored on the client for
* the duration of the session.
*/
public void set (String name, String value);
/**
* Set a persisten cookie on the client that will expire
* after a maximum age (given in seconds).
*/
public void set (String name, String value, int seconds_age);
/**
* Remove a previously set cookie from the client machine.
*/
public void unset (String name);
}
1.1 jakarta-turbine/src/java/org/apache/turbine/util/parser/DataStreamParser.java
Index: DataStreamParser.java
===================================================================
package org.apache.turbine.util.parser;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Turbine" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.Reader;
import java.io.StreamTokenizer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import org.apache.turbine.util.Log;
import org.apache.turbine.util.parser.BaseValueParser;
/**
* DataStreamParser is used to parse a stream with a fixed format and
* generate ValueParser objects which can be used to extract the values
* in the desired type.
*
* <p>The class itself is abstract - a concrete subclass which implements
* the initTokenizer method such as CSVParser or TSVParser is required
* to use the functionality.
*
* <p>The class implements the java.util.Iterator interface for convenience.
* This allows simple use in a Velocity template for example:
*
* <pre>
* #foreach ($row in $datastream)
* Name: $row.Name
* Description: $row.Description
* #end
* </pre>
*
* @author <a href="mailto:sean@informage.net">Sean Legassick</a>
* @version $Id: DataStreamParser.java,v 1.1 2001/07/13 16:50:13 jvanzyl Exp $
*/
public abstract class DataStreamParser
implements Iterator
{
/**
* Conditional compilation flag.
*/
private static final boolean DEBUG = false;
/**
* The list of column names.
*/
private List columnNames;
/**
* The stream tokenizer for reading values from the input reader.
*/
private StreamTokenizer tokenizer;
/**
* The parameter parser holding the values of columns for the current line.
*/
private ValueParser lineValues;
/**
* Indicates whether or not the tokenizer has read anything yet.
*/
private boolean neverRead = true;
/**
* The character encoding of the input
*/
private String characterEncoding;
/**
* Create a new DataStreamParser instance. Requires a Reader to read the
* comma-separated values from, a list of column names and a
* character encoding.
*
* @param in the input reader.
* @param columnNames a list of column names.
* @param characterEncoding the character encoding of the input.
*/
public DataStreamParser(Reader in, List columnNames,
String characterEncoding)
{
this.columnNames = columnNames;
this.characterEncoding = characterEncoding;
if (this.characterEncoding == null)
{
// try and get the characterEncoding from the reader
this.characterEncoding = "US-ASCII";
try
{
this.characterEncoding = ((InputStreamReader)in).getEncoding();
}
catch (ClassCastException e)
{
}
}
tokenizer = new StreamTokenizer(new BufferedReader(in));
initTokenizer(tokenizer);
}
/**
* Initialize the StreamTokenizer instance used to read the lines
* from the input reader. This must be implemented in subclasses to
* set up the tokenizing properties.
*/
protected abstract void initTokenizer(StreamTokenizer tokenizer);
/**
* Set the list of column names explicitly.
*
* @param columnNames A list of column names.
*/
public void setColumnNames(List columnNames)
{
this.columnNames = columnNames;
}
/**
* Read the list of column names from the input reader using the
* tokenizer.
*
* @exception IOException an IOException occurred.
*/
public void readColumnNames()
throws IOException
{
columnNames = new ArrayList();
neverRead = false;
tokenizer.nextToken();
while (tokenizer.ttype == StreamTokenizer.TT_WORD
|| tokenizer.ttype == '"')
{
columnNames.add(tokenizer.sval);
tokenizer.nextToken();
}
}
/**
* Determine whether a further row of values exists in the input.
*
* @return true if the input has more rows.
* @exception IOException an IOException occurred.
*/
public boolean hasNextRow()
throws IOException
{
// check for end of line ensures that an empty last line doesn't
// give a false positive for hasNextRow
if (neverRead || tokenizer.ttype == StreamTokenizer.TT_EOL)
{
tokenizer.nextToken();
tokenizer.pushBack();
neverRead = false;
}
return tokenizer.ttype != StreamTokenizer.TT_EOF;
}
/**
* Returns a ValueParser object containing the next row of values.
*
* @return a ValueParser object.
* @exception IOException an IOException occurred.
* @exception NoSuchElementException there are no more rows in the input.
*/
public ValueParser nextRow()
throws IOException, NoSuchElementException
{
if (!hasNextRow())
{
throw new NoSuchElementException();
}
if (lineValues == null)
{
lineValues = new BaseValueParser(characterEncoding);
}
else
{
lineValues.clear();
}
Iterator it = columnNames.iterator();
tokenizer.nextToken();
while (tokenizer.ttype == StreamTokenizer.TT_WORD
|| tokenizer.ttype == '"')
{
// note this means that if there are more values than
// column names, the extra values are discarded.
if (it.hasNext())
{
String colname = it.next().toString();
String colval = tokenizer.sval;
if (DEBUG)
{
Log.debug("DataStreamParser.nextRow(): " +
colname + '=' + colval);
}
lineValues.add(colname, colval);
}
tokenizer.nextToken();
}
return lineValues;
}
/**
* Determine whether a further row of values exists in the input.
*
* @return true if the input has more rows.
*/
public boolean hasNext()
{
boolean hasNext = false;
try
{
hasNext = hasNextRow();
}
catch (IOException e)
{
Log.error("IOException in CSVParser.hasNext", e);
}
return hasNext;
}
/**
* Returns a ValueParser object containing the next row of values.
*
* @return a ValueParser object as an Object.
* @exception NoSuchElementException there are no more rows in the input
* or an IOException occurred.
*/
public Object next()
throws NoSuchElementException
{
Object nextRow = null;
try
{
nextRow = nextRow();
}
catch (IOException e)
{
Log.error("IOException in CSVParser.next", e);
throw new NoSuchElementException();
}
return nextRow;
}
/**
* The optional Iterator.remove method is not supported.
*
* @exception UnsupportedOperationException the operation is not supported.
*/
public void remove()
throws UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
}
1.1 jakarta-turbine/src/java/org/apache/turbine/util/parser/TSVParser.java
Index: TSVParser.java
===================================================================
package org.apache.turbine.util.parser;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Turbine" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import java.io.Reader;
import java.io.StreamTokenizer;
import java.util.List;
/**
* TSVParser is used to parse a stream with tab-separated values and
* generate ParameterParser objects which can be used to
* extract the values in the desired type.
*
* <p>The class extends the abstract class DataStreamParser and implements
* initTokenizer with suitable values for TSV files to provide this
* functionality.
*
* <p>The class (indirectly through DataStreamParser) implements the
* java.util.Iterator interface for convenience.
* This allows simple use in a Velocity template for example:
*
* <pre>
* #foreach ($row in $tsvfile)
* Name: $row.Name
* Description: $row.Description
* #end
* </pre>
*
* @author <a href="mailto:sean@informage.net">Sean Legassick</a>
* @version $Id: TSVParser.java,v 1.1 2001/07/13 16:50:26 jvanzyl Exp $
*/
public class TSVParser
extends DataStreamParser
{
/**
* Create a new TSVParser instance. Requires a Reader to read the
* tab-separated values from. The column headers must be set
* independently either explicitly, or by reading the first line
* of the TSV values.
*
* @param in the input reader.
*/
public TSVParser(Reader in)
{
super(in, null, null);
}
/**
* Create a new TSVParser instance. Requires a Reader to read the
* tab-separated values from, and a list of column names.
*
* @param in the input reader.
* @param columnNames a list of column names.
*/
public TSVParser(Reader in, List columnNames)
{
super(in, columnNames, null);
}
/**
* Create a new TSVParser instance. Requires a Reader to read the
* tab-separated values from, a list of column names and a
* character encoding.
*
* @param in the input reader.
* @param columnNames a list of column names.
* @param characterEncoding the character encoding of the input.
*/
public TSVParser(Reader in, List columnNames, String characterEncoding)
{
super(in, columnNames, characterEncoding);
}
/**
* Initialize the StreamTokenizer instance used to read the lines
* from the input reader.
*/
protected void initTokenizer(StreamTokenizer tokenizer)
{
// set all numeric characters as ordinary characters
// (switches off number parsing)
tokenizer.ordinaryChars('0', '9');
tokenizer.ordinaryChars('-', '-');
tokenizer.ordinaryChars('.', '.');
// set all printable characters to be treated as word chars
tokenizer.wordChars(' ', Integer.MAX_VALUE);
// and finally say that end of line is significant
tokenizer.eolIsSignificant(true);
}
}
1.1 jakarta-turbine/src/java/org/apache/turbine/util/parser/ValueParser.java
Index: ValueParser.java
===================================================================
package org.apache.turbine.util.parser;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Turbine" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.util.Date;
import java.util.Enumeration;
//!! why are these here? jvz.
import org.apache.turbine.services.db.om.NumberKey;
import org.apache.turbine.services.db.om.StringKey;
/**
* ValueParser is a base interface for classes that need to parse
* name/value Parameters, for example GET/POST data or Cookies
* (ParameterParser and CookieParser)
*
* <p>NOTE: The name= portion of a name=value pair may be converted
* to lowercase or uppercase when the object is initialized and when
* new data is added. This behaviour is determined by the url.case.folding
* property in TurbineResources.properties. Adding a name/value pair may
* overwrite existing name=value pairs if the names match:
*
* @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>
* @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
* @version $Id: ValueParser.java,v 1.1 2001/07/13 16:50:27 jvanzyl Exp $
*/
public interface ValueParser
{
/**
* The case folding property specifying the case folding
* to apply to value keys of the parser.
*/
public static final String URL_CASE_FOLDING = "url.case.folding";
public static final String URL_CASE_FOLDING_NONE = "none";
public static final String URL_CASE_FOLDING_LOWER = "lower";
public static final String URL_CASE_FOLDING_UPPER = "upper";
/**
* Clear all name/value pairs out of this object.
*/
public void clear();
/**
* Set the character encoding that will be used by this ValueParser.
*/
public void setCharacterEncoding (String s);
/**
* Get the character encoding that will be used by this ValueParser.
*/
public String getCharacterEncoding ();
/**
* Trims the string data and applies the conversion specified in
* the property given by URL_CASE_FOLDING. It returns a new
* string so that it does not destroy the value data.
*
* @param value A String to be processed.
* @return A new String converted to lowercase and trimmed.
*/
public String convert ( String value );
/**
* Add a name/value pair into this object.
*
* @param name A String with the name.
* @param value A double with the value.
*/
public void add ( String name,
double value );
/**
* Add a name/value pair into this object.
*
* @param name A String with the name.
* @param value An int with the value.
*/
public void add ( String name,
int value );
/**
* Add a name/value pair into this object.
*
* @param name A String with the name.
* @param value An Integer with the value.
*/
public void add ( String name,
Integer value );
/**
* Add a name/value pair into this object.
*
* @param name A String with the name.
* @param value A long with the value.
*/
public void add ( String name,
long value );
/**
* Add a name/value pair into this object.
*
* @param name A String with the name.
* @param value A long with the value.
*/
public void add ( String name,
String value );
/**
* Add a String parameters. If there are any Strings already
* associated with the name, append to the array. This is used
* for handling parameters from mulitipart POST requests.
*
* @param name A String with the name.
* @param value A String with the value.
*/
public void append( String name,
String value );
/**
* Removes the named parameter from the contained hashtable. Wraps to the
* contained <code>Hashtable.remove()</code>.
*
*
* @return The value that was mapped to the key (a <code>String[]</code>)
* or <code>null</code> if the key was not mapped.
*/
public Object remove(String name);
/**
* Determine whether a given key has been inserted. All keys are
* stored in lowercase strings, so override method to account for
* this.
*
* @param key An Object with the key to search for.
* @return True if the object is found.
*/
public boolean containsKey( Object key );
/**
* Check for existence of key_day, key_month and key_year
* parameters (as returned by DateSelector generated HTML).
*
* @param key A String with the selector name.
* @return True if keys are found.
*/
public boolean containsDateSelectorKeys(String key);
/*
* Get an enumerator for the parameter keys. Wraps to the
* contained <code>Hashtable.keys()</code>.
*
* @return An <code>enumerator</code> of the keys.
*/
public Enumeration keys();
/*
* Returns all the available parameter names.
*
* @return A object array with the keys.
*/
public Object[] getKeys();
/**
* Return a boolean for the given name. If the name does not
* exist, return defaultValue.
*
* @param name A String with the name.
* @param defaultValue The default value.
* @return A boolean.
*/
public boolean getBoolean(String name,
boolean defaultValue);
/**
* Return a boolean for the given name. If the name does not
* exist, return false.
*
* @param name A String with the name.
* @return A boolean.
*/
public boolean getBoolean(String name);
/**
* Return a Boolean for the given name. If the name does not
* exist, return defaultValue.
*
* @param name A String with the name.
* @param defaultValue The default value.
* @return A Boolean.
*/
public Boolean getBool(String name,
boolean defaultValue);
/**
* Return a Boolean for the given name. If the name does not
* exist, return false.
*
* @param name A String with the name.
* @return A Boolean.
*/
public Boolean getBool(String name);
/**
* Return a double for the given name. If the name does not
* exist, return defaultValue.
*
* @param name A String with the name.
* @param defaultValue The default value.
* @return A double.
*/
public double getDouble(String name,
double defaultValue);
/**
* Return a double for the given name. If the name does not
* exist, return 0.0.
*
* @param name A String with the name.
* @return A double.
*/
public double getDouble(String name);
/**
* Return a float for the given name. If the name does not
* exist, return defaultValue.
*
* @param name A String with the name.
* @param defaultValue The default value.
* @return A float.
*/
public float getFloat(String name,
float defaultValue);
/**
* Return a float for the given name. If the name does not
* exist, return 0.0.
*
* @param name A String with the name.
* @return A float.
*/
public float getFloat(String name);
/**
* Return a BigDecimal for the given name. If the name does not
* exist, return 0.0.
*
* @param name A String with the name.
* @param defaultValue The default value.
* @return A BigDecimal.
*/
public BigDecimal getBigDecimal(String name,
BigDecimal defaultValue);
/**
* Return a BigDecimal for the given name. If the name does not
* exist, return 0.0.
*
* @param name A String with the name.
* @return A BigDecimal.
*/
public BigDecimal getBigDecimal(String name);
/**
* Return an array of BigDecimals for the given name. If the name
* does not exist, return null.
*
* @param name A String with the name.
* @return A BigDecimal[].
*/
public BigDecimal[] getBigDecimals(String name);
/**
* Return an int for the given name. If the name does not exist,
* return defaultValue.
*
* @param name A String with the name.
* @param defaultValue The default value.
* @return An int.
*/
public int getInt(String name,
int defaultValue );
/**
* Return an int for the given name. If the name does not exist,
* return 0.
*
* @param name A String with the name.
* @return An int.
*/
public int getInt(String name);
/**
* Return an Integer for the given name. If the name does not
* exist, return defaultValue.
*
* @param name A String with the name.
* @param defaultValue The default value.
* @return An Integer.
*/
public Integer getInteger(String name,
int defaultValue);
/**
* Return an Integer for the given name. If the name does not
* exist, return defaultValue. You cannot pass in a null here for
* the default value.
*
* @param name A String with the name.
* @param defaultValue The default value.
* @return An Integer.
*/
public Integer getInteger(String name,
Integer def);
/**
* Return an Integer for the given name. If the name does not
* exist, return 0.
*
* @param name A String with the name.
* @return An Integer.
*/
public Integer getInteger(String name);
/**
* Return an array of ints for the given name. If the name does
* not exist, return null.
*
* @param name A String with the name.
* @return An int[].
*/
public int[] getInts(String name);
/**
* Return an array of Integers for the given name. If the name
* does not exist, return null.
*
* @param name A String with the name.
* @return An Integer[].
*/
public Integer[] getIntegers(String name);
/**
* Return a long for the given name. If the name does not exist,
* return defaultValue.
*
* @param name A String with the name.
* @param defaultValue The default value.
* @return A long.
*/
public long getLong(String name,
long defaultValue );
/**
* Return a long for the given name. If the name does not exist,
* return 0.
*
* @param name A String with the name.
* @return A long.
*/
public long getLong(String name);
/**
* Return an array of longs for the given name. If the name does
* not exist, return null.
*
* @param name A String with the name.
* @return A long[].
*/
public long[] getLongs(String name);
/**
* Return an array of Longs for the given name. If the name does
* not exist, return null.
*
* @param name A String with the name.
* @return A Long[].
*/
public Long[] getLongObjects(String name);
/**
* Return a byte for the given name. If the name does not exist,
* return defaultValue.
*
* @param name A String with the name.
* @param defaultValue The default value.
* @return A byte.
*/
public byte getByte(String name,
byte defaultValue );
/**
* Return a byte for the given name. If the name does not exist,
* return 0.
*
* @param name A String with the name.
* @return A byte.
*/
public byte getByte(String name);
/**
* Return an array of bytes for the given name. If the name does
* not exist, return null. The array is returned according to the
* HttpRequest's character encoding.
*
* @param name A String with the name.
* @return A byte[].
* @exception UnsupportedEncodingException.
*/
public byte[] getBytes(String name)
throws UnsupportedEncodingException;
/**
* Return a String for the given name. If the name does not
* exist, return null.
*
* @param name A String with the name.
* @return A String.
*/
public String getString(String name);
/**
* Return a String for the given name. If the name does not
* exist, return null. It is the same as the getString() method
* however has been added for simplicity when working with
* template tools such as Velocity which allow you to do
* something like this:
*
* <code>$data.Parameters.form_variable_name</code>
*
* @param name A String with the name.
* @return A String.
*/
public String get (String name);
/**
* Return a String for the given name. If the name does not
* exist, return the defaultValue.
*
* @param name A String with the name.
* @param defaultValue The default value.
* @return A String.
*/
public String getString(String name,
String defaultValue);
/**
* Set a parameter to a specific value.
*
* This is useful if you want your action to override the values
* of the parameters for the screen to use.
* @param name The name of the parameter.
* @param value The value to set.
*/
public void setString(String name, String value);
/**
* Return an array of Strings for the given name. If the name
* does not exist, return null.
*
* @param name A String with the name.
* @return A String[].
*/
public String[] getStrings(String name);
/**
* Return an array of Strings for the given name. If the name
* does not exist, return the defaultValue.
*
* @param name A String with the name.
* @param defaultValue The default value.
* @return A String[].
*/
public String[] getStrings(String name,
String[] defaultValue);
/**
* Set a parameter to a specific value.
*
* This is useful if you want your action to override the values
* of the parameters for the screen to use.
* @param name The name of the parameter.
* @param values The value to set.
*/
public void setStrings(String name, String[] values);
/**
* Return an Object for the given name. If the name does not
* exist, return null.
*
* @param name A String with the name.
* @return An Object.
*/
public Object getObject(String name);
/**
* Return an array of Objects for the given name. If the name
* does not exist, return null.
*
* @param name A String with the name.
* @return An Object[].
*/
public Object[] getObjects(String name);
/**
* Returns a java.util.Date object. String is parsed by supplied
* DateFormat. If the name does not exist, return the
* defaultValue.
*
* @param name A String with the name.
* @param df A DateFormat.
* @param defaultValue The default value.
* @return A Date.
*/
public Date getDate(String name,
DateFormat df,
Date defaultValue);
/**
* Returns a java.util.Date object. If there are DateSelector
* style parameters then these are used. If not and there is a
* parameter 'name' then this is parsed by DateFormat. If the
* name does not exist, return null.
*
* @param name A String with the name.
* @return A Date.
*/
public Date getDate(String name);
/**
* Returns a java.util.Date object. String is parsed by supplied
* DateFormat. If the name does not exist, return null.
*
* @param name A String with the name.
* @param df A DateFormat.
* @return A Date.
*/
public Date getDate(String name,
DateFormat df);
/**
* Return an NumberKey for the given name. If the name does not
* exist, return null.
*
* @param name A String with the name.
* @return An NumberKey.
*/
public NumberKey getNumberKey(String name);
/**
* Return an NumberKey for the given name. If the name does not
* exist, return null.
*
* @param name A String with the name.
* @return An StringKey.
*/
public StringKey getStringKey(String name);
/**
* Uses bean introspection to set writable properties of bean from
* the parameters, where a (case-insensitive) name match between
* the bean property and the parameter is looked for.
*
* @param bean An Object.
* @exception Exception, a generic exception.
*/
public void setProperties(Object bean)
throws Exception;
/**
* Simple method that attempts to get a toString() representation
* of this object. It doesn't do well with String[]'s though.
*
* @return A String.
*/
public String toString();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org