You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2006/05/05 18:21:09 UTC
svn commit: r400102 [3/5] - in /tapestry/tapestry4/trunk: .settings/
examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/
examples/Workbench/src/java/org/apache/tapestry/workbench/tree/examples/
examples/Workbench/src/java/org/apache/tapestry/work...
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/ObjectIdentityMap.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/ObjectIdentityMap.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/ObjectIdentityMap.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/ObjectIdentityMap.java Fri May 5 09:20:58 2006
@@ -15,14 +15,16 @@
package org.apache.tapestry.util;
/**
- * A simple map-like collection, similar to (but more more limited than) JDK 1.4's IdentityHashMap.
- * It is designed for <em>small</em> collections of objects.
+ * A simple map-like collection, similar to (but more more limited than) JDK
+ * 1.4's IdentityHashMap. It is designed for <em>small</em> collections of
+ * objects.
*
* @author Howard Lewis Ship
* @since 4.0
*/
public class ObjectIdentityMap
{
+
private int _pairCount = 0;
// Alternates between keys and values
@@ -33,13 +35,14 @@
* Adds or updates a key in the bag.
*
* @param key
- * the key to store a value under; an existing value with the key is discarded
+ * the key to store a value under; an existing value with the key
+ * is discarded
* @param value
* the value to store
*/
public void put(Object key, Object value)
{
- for (int i = 0; i < _pairCount; i++)
+ for(int i = 0; i < _pairCount; i++)
{
int index = 2 * i;
@@ -68,14 +71,11 @@
public Object get(Object key)
{
- for (int i = 0; i < _pairCount; i++)
+ for(int i = 0; i < _pairCount; i++)
{
int index = 2 * i;
- if (_pairs[index] == key)
- {
- return _pairs[index + 1];
- }
+ if (_pairs[index] == key) { return _pairs[index + 1]; }
}
return null;
@@ -89,7 +89,8 @@
if (newLength >= currentSize)
{
- // Expand to dobule current size. Allocate room for 5 keys and 5 values
+ // Expand to dobule current size. Allocate room for 5 keys and 5
+ // values
// initially.
int newSize = Math.max(10, 2 * currentSize);
@@ -102,4 +103,4 @@
_pairs = newPairsArray;
}
}
-}
\ No newline at end of file
+}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/QueryParameterMap.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/QueryParameterMap.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/QueryParameterMap.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/QueryParameterMap.java Fri May 5 09:20:58 2006
@@ -22,14 +22,15 @@
import org.apache.hivemind.util.Defense;
/**
- * A wrapper around a Map that stores query parameter values. Map keys are strings. Map values can
- * be simple strings or array of string (or null).
+ * A wrapper around a Map that stores query parameter values. Map keys are
+ * strings. Map values can be simple strings or array of string (or null).
*
* @author Howard M. Lewis Ship
* @since 4.0
*/
public class QueryParameterMap
{
+
private final Map _parameters;
public QueryParameterMap()
@@ -38,9 +39,9 @@
}
/**
- * Constructor around an existing Map whose keys and values are expected to conform expected use
- * (keys are strings, values are null, string or string array). The map passed in is retained (
- * not copied).
+ * Constructor around an existing Map whose keys and values are expected to
+ * conform expected use (keys are strings, values are null, string or string
+ * array). The map passed in is retained ( not copied).
*/
public QueryParameterMap(Map parameterMap)
@@ -51,7 +52,8 @@
}
/**
- * Replaces the parameter value for the given name wit the new value (which may be null).
+ * Replaces the parameter value for the given name wit the new value (which
+ * may be null).
*/
public void setParameterValue(String name, String value)
@@ -62,8 +64,8 @@
}
/**
- * Replaces the parameter value for the given name wit the new list of values (which may be
- * empty or null).
+ * Replaces the parameter value for the given name wit the new list of
+ * values (which may be empty or null).
*/
public void setParameterValues(String name, String[] values)
@@ -74,8 +76,8 @@
}
/**
- * Gets a query parameter value. If an array of values was stored, this returns the first value.
- * May return null.
+ * Gets a query parameter value. If an array of values was stored, this
+ * returns the first value. May return null.
*/
public String getParameterValue(String name)
@@ -84,8 +86,7 @@
Object values = _parameters.get(name);
- if (values == null || values instanceof String)
- return (String) values;
+ if (values == null || values instanceof String) return (String) values;
String[] array = (String[]) values;
@@ -93,9 +94,9 @@
}
/**
- * Returns the array of values for the specified parameter. If only a lone value was stored (via
- * {@link #setParameterValue(String, String)}, then the value is wrapped as a string array and
- * returned.
+ * Returns the array of values for the specified parameter. If only a lone
+ * value was stored (via {@link #setParameterValue(String, String)}, then
+ * the value is wrapped as a string array and returned.
*/
public String[] getParameterValues(String name)
{
@@ -108,8 +109,7 @@
String loneValue = (String) values;
- return new String[]
- { loneValue };
+ return new String[] { loneValue };
}
/**
@@ -119,11 +119,11 @@
{
int count = _parameters.size();
- String[] result = (String[]) _parameters.keySet().toArray(new String[count]);
-
- if (!TreeMap.class.isInstance(_parameters))
- Arrays.sort(result);
-
+ String[] result = (String[]) _parameters.keySet().toArray(
+ new String[count]);
+
+ if (!TreeMap.class.isInstance(_parameters)) Arrays.sort(result);
+
return result;
}
-}
\ No newline at end of file
+}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/StringSplitter.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/StringSplitter.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/StringSplitter.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/StringSplitter.java Fri May 5 09:20:58 2006
@@ -15,35 +15,33 @@
package org.apache.tapestry.util;
/**
- * Used to split a string into substrings based on a single character
- * delimiter. A fast, simple version of
- * {@link java.util.StringTokenizer}.
- *
- * @author Howard Lewis Ship
+ * Used to split a string into substrings based on a single character delimiter.
+ * A fast, simple version of {@link java.util.StringTokenizer}.
*
- **/
+ * @author Howard Lewis Ship
+ */
public class StringSplitter
{
- private char delimiter;
+
+ private char _delimiter;
public StringSplitter(char delimiter)
{
- this.delimiter = delimiter;
+ this._delimiter = delimiter;
}
public char getDelimiter()
{
- return delimiter;
+ return _delimiter;
}
/**
- * Splits a string on the delimter into an array of String
- * tokens. The delimiters are not included in the tokens. Null
- * tokens (caused by two consecutive delimiter) are reduced to an
- * empty string. Leading delimiters are ignored.
- *
- **/
+ * Splits a string on the delimter into an array of String tokens. The
+ * delimiters are not included in the tokens. Null tokens (caused by two
+ * consecutive delimiter) are reduced to an empty string. Leading delimiters
+ * are ignored.
+ */
public String[] splitToArray(String value)
{
@@ -64,9 +62,9 @@
start = 0;
length = 0;
- for (i = 0; i < buffer.length; i++)
+ for(i = 0; i < buffer.length; i++)
{
- if (buffer[i] != delimiter)
+ if (buffer[i] != _delimiter)
{
length++;
continue;
@@ -96,9 +94,9 @@
length = 0;
}
- // Special case: if the string contains no delimiters
- // then it isn't really split. Wrap the input string
- // in an array and return. This is a little optimization
+ // Special case: if the string contains no delimiters
+ // then it isn't really split. Wrap the input string
+ // in an array and return. This is a little optimization
// to prevent a new String instance from being
// created unnecessarily.
@@ -120,4 +118,4 @@
return newResult;
}
-}
\ No newline at end of file
+}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/UtilMessages.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/UtilMessages.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/UtilMessages.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/UtilMessages.java Fri May 5 09:20:58 2006
@@ -20,10 +20,13 @@
* @author Howard M. Lewis Ship
* @since 4.0
*/
-class UtilMessages
+final class UtilMessages
{
private static final MessageFormatter _formatter = new MessageFormatter(UtilMessages.class);
+ /* defeat instantiation */
+ private UtilMessages() { }
+
static String valueNotFound(Object value)
{
return _formatter.format("value-not-found", value);
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/UtilStrings.properties
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/UtilStrings.properties?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/UtilStrings.properties (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/UtilStrings.properties Fri May 5 09:20:58 2006
@@ -13,4 +13,4 @@
# limitations under the License.
value-not-found=Value {0} not found.
-key-already-exists=Key ''{0}'' already exists in this primary key converter.
\ No newline at end of file
+key-already-exists=Key ''{0}'' already exists in this primary key converter.
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/exception/ExceptionProperty.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/exception/ExceptionProperty.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/exception/ExceptionProperty.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/exception/ExceptionProperty.java Fri May 5 09:20:58 2006
@@ -17,36 +17,38 @@
import java.io.Serializable;
/**
- * Captures a name/value property pair from an exception. Part of an {@link ExceptionDescription}.
+ * Captures a name/value property pair from an exception. Part of an
+ * {@link ExceptionDescription}.
*
* @author Howard Lewis Ship
*/
public class ExceptionProperty implements Serializable
{
+
private static final long serialVersionUID = 5260773289683550374L;
/**
* @since 2.0.4
*/
- private String name;
+ private String _name;
- private Object value;
+ private Object _value;
public ExceptionProperty(String name, Object value)
{
- this.name = name;
- this.value = value;
+ this._name = name;
+ this._value = value;
}
public String getName()
{
- return name;
+ return _name;
}
public Object getValue()
{
- return value;
+ return _value;
}
-}
\ No newline at end of file
+}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/DoubleAdaptor.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/DoubleAdaptor.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/DoubleAdaptor.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/DoubleAdaptor.java Fri May 5 09:20:58 2006
@@ -24,6 +24,7 @@
public class DoubleAdaptor implements SqueezeAdaptor
{
+
private static final String PREFIX = "d";
public String getPrefix()
@@ -37,8 +38,8 @@
}
/**
- * Invoked <code>toString()</code> on data (which is type {@link Double}), and prefixs the
- * result.
+ * Invoked <code>toString()</code> on data (which is type {@link Double}),
+ * and prefixs the result.
*/
public String squeeze(DataSqueezer squeezer, Object data)
@@ -55,4 +56,4 @@
return new Double(string.substring(1));
}
-}
\ No newline at end of file
+}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/FloatAdaptor.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/FloatAdaptor.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/FloatAdaptor.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/FloatAdaptor.java Fri May 5 09:20:58 2006
@@ -24,6 +24,7 @@
public class FloatAdaptor implements SqueezeAdaptor
{
+
private static final String PREFIX = "f";
public String getPrefix()
@@ -37,8 +38,8 @@
}
/**
- * Invoked <code>toString()</code> on data (which is type {@link Float}), and prefixs the
- * result.
+ * Invoked <code>toString()</code> on data (which is type {@link Float}),
+ * and prefixs the result.
*/
public String squeeze(DataSqueezer squeezer, Object data)
@@ -55,4 +56,4 @@
return new Float(string.substring(1));
}
-}
\ No newline at end of file
+}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/IntegerAdaptor.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/IntegerAdaptor.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/IntegerAdaptor.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/IntegerAdaptor.java Fri May 5 09:20:58 2006
@@ -17,8 +17,8 @@
import org.apache.tapestry.services.DataSqueezer;
/**
- * Squeezes a {@link Integer}. This adaptor claims all the digits as prefix characters, so its the
- * very simplest conversion of all!
+ * Squeezes a {@link Integer}. This adaptor claims all the digits as prefix
+ * characters, so its the very simplest conversion of all!
*
* @author Howard Lewis Ship
*/
@@ -37,7 +37,8 @@
}
/**
- * Simply invokes <code>toString()</code> on the data, which is actually type {@link Integer}.
+ * Simply invokes <code>toString()</code> on the data, which is actually
+ * type {@link Integer}.
*/
public String squeeze(DataSqueezer squeezer, Object data)
@@ -54,4 +55,4 @@
return new Integer(string);
}
-}
\ No newline at end of file
+}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/IoMessages.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/IoMessages.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/IoMessages.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/IoMessages.java Fri May 5 09:20:58 2006
@@ -16,10 +16,17 @@
import org.apache.hivemind.impl.MessageFormatter;
-class IoMessages
+/**
+ *
+ * @author hls
+ */
+final class IoMessages
{
private static final MessageFormatter _formatter = new MessageFormatter(IoMessages.class);
+ /* defeat instantiation */
+ private IoMessages() { }
+
static String encodeFailure(Object object, Throwable cause)
{
return _formatter.format("encode-failure", object, cause);
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/LongAdaptor.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/LongAdaptor.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/LongAdaptor.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/LongAdaptor.java Fri May 5 09:20:58 2006
@@ -24,6 +24,7 @@
public class LongAdaptor implements SqueezeAdaptor
{
+
private static final String PREFIX = "l";
public String getPrefix()
@@ -37,8 +38,8 @@
}
/**
- * Invoked <code>toString()</code> on data (which is type {@link Long}), and prefixs the
- * result.
+ * Invoked <code>toString()</code> on data (which is type {@link Long}),
+ * and prefixs the result.
*/
public String squeeze(DataSqueezer squeezer, Object data)
@@ -55,4 +56,4 @@
return new Long(string.substring(1));
}
-}
\ No newline at end of file
+}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/ResolvingObjectInputStream.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/ResolvingObjectInputStream.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/ResolvingObjectInputStream.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/ResolvingObjectInputStream.java Fri May 5 09:20:58 2006
@@ -23,9 +23,9 @@
import org.apache.hivemind.util.Defense;
/**
- * Specialized subclass of {@link java.io.ObjectInputStream}that knows how to resolve classes with
- * a non-default class loader (represented by an instance of
- * {@link org.apache.hivemind.ClassResolver}).
+ * Specialized subclass of {@link java.io.ObjectInputStream}that knows how to
+ * resolve classes with a non-default class loader (represented by an instance
+ * of {@link org.apache.hivemind.ClassResolver}).
*
* @author Howard Lewis Ship
* @since 3.0
@@ -33,9 +33,11 @@
public class ResolvingObjectInputStream extends ObjectInputStream
{
+
private ClassResolver _resolver;
- public ResolvingObjectInputStream(ClassResolver resolver, InputStream input) throws IOException
+ public ResolvingObjectInputStream(ClassResolver resolver, InputStream input)
+ throws IOException
{
super(input);
@@ -45,11 +47,13 @@
}
/**
- * Overrides the default implementation to have the resource resolver find the class.
+ * Overrides the default implementation to have the resource resolver find
+ * the class.
*/
- protected Class resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException
+ protected Class resolveClass(ObjectStreamClass v)
+ throws IOException, ClassNotFoundException
{
return _resolver.findClass(v.getName());
}
-}
\ No newline at end of file
+}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/SerializableAdaptor.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/SerializableAdaptor.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/SerializableAdaptor.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/SerializableAdaptor.java Fri May 5 09:20:58 2006
@@ -40,8 +40,6 @@
public class SerializableAdaptor implements SqueezeAdaptor
{
- private ClassResolver _resolver;
-
private static final char BYTESTREAM_PREFIX = 'O';
private static final char GZIP_BYTESTREAM_PREFIX = 'Z';
@@ -51,6 +49,8 @@
private static final String PREFIX = "OZ";
+ private ClassResolver _resolver;
+
public String getPrefix()
{
return PREFIX;
@@ -133,4 +133,4 @@
_resolver = resolver;
}
-}
\ No newline at end of file
+}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/ShortAdaptor.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/ShortAdaptor.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/ShortAdaptor.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/ShortAdaptor.java Fri May 5 09:20:58 2006
@@ -24,6 +24,7 @@
public class ShortAdaptor implements SqueezeAdaptor
{
+
private static final String PREFIX = "s";
public String getPrefix()
@@ -37,8 +38,8 @@
}
/**
- * Invoked <code>toString()</code> on data (which is type {@link Short}), and prefixs the
- * result.
+ * Invoked <code>toString()</code> on data (which is type {@link Short}),
+ * and prefixs the result.
*/
public String squeeze(DataSqueezer squeezer, Object data)
@@ -55,4 +56,4 @@
return new Short(string.substring(1));
}
-}
\ No newline at end of file
+}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/StringAdaptor.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/StringAdaptor.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/StringAdaptor.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/StringAdaptor.java Fri May 5 09:20:58 2006
@@ -24,6 +24,7 @@
public class StringAdaptor implements SqueezeAdaptor
{
+
private static final String PREFIX = "S";
public String getPrefix()
@@ -45,14 +46,14 @@
/**
* Strips the prefix from the string. This method is only invoked by the
- * {@link DataSqueezerImpl} if the string leads with its normal prefix (an 'S').
+ * {@link DataSqueezerImpl} if the string leads with its normal prefix (an
+ * 'S').
*/
public Object unsqueeze(DataSqueezer squeezer, String string)
{
- if (string.length() == 1)
- return "";
+ if (string.length() == 1) return "";
return string.substring(1);
}
-}
\ No newline at end of file
+}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/TeeOutputStream.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/TeeOutputStream.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/TeeOutputStream.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/io/TeeOutputStream.java Fri May 5 09:20:58 2006
@@ -20,13 +20,15 @@
import org.apache.hivemind.util.Defense;
/**
- * An output stream that copies bytes pushed through it to two other output streams.
+ * An output stream that copies bytes pushed through it to two other output
+ * streams.
*
* @author Howard M. Lewis Ship
* @since 4.0
*/
public class TeeOutputStream extends OutputStream
{
+
private final OutputStream _os1;
private final OutputStream _os2;
@@ -40,33 +42,38 @@
_os2 = os2;
}
- public void close() throws IOException
+ public void close()
+ throws IOException
{
_os1.close();
_os2.close();
}
- public void flush() throws IOException
+ public void flush()
+ throws IOException
{
_os1.flush();
_os2.flush();
}
- public void write(byte[] b, int off, int len) throws IOException
+ public void write(byte[] b, int off, int len)
+ throws IOException
{
_os1.write(b, off, len);
_os2.write(b, off, len);
}
- public void write(byte[] b) throws IOException
+ public void write(byte[] b)
+ throws IOException
{
_os1.write(b);
_os1.write(b);
}
- public void write(int b) throws IOException
+ public void write(int b)
+ throws IOException
{
_os1.write(b);
_os2.write(b);
}
-}
\ No newline at end of file
+}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/ICharacterMatcher.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/ICharacterMatcher.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/ICharacterMatcher.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/ICharacterMatcher.java Fri May 5 09:20:58 2006
@@ -20,13 +20,15 @@
* @author mb
* @since 4.0
*/
-public interface ICharacterMatcher
+public interface ICharacterMatcher
{
+
/**
- * Determine whether the given character matches the implemented rule
+ * Determine whether the given character matches the implemented rule.
*
- * @param ch the character to be matched
+ * @param ch
+ * the character to be matched
* @return true if the character matches the rule
*/
boolean matches(char ch);
-}
\ No newline at end of file
+}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/ICharacterTranslator.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/ICharacterTranslator.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/ICharacterTranslator.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/ICharacterTranslator.java Fri May 5 09:20:58 2006
@@ -20,15 +20,17 @@
* @author mb
* @since 4.0
*/
-public interface ICharacterTranslator
+public interface ICharacterTranslator
{
- /**
- * Translates the provided character into a string
- *
- * @param ch the character to be translated
- * @return null if the character is not to be translated,
- * an empty string if the character is to be ignored,
- * or another string to represent the character translation
- */
- String translate(char ch);
+
+ /**
+ * Translates the provided character into a string
+ *
+ * @param ch
+ * the character to be translated
+ * @return null if the character is not to be translated, an empty string if
+ * the character is to be ignored, or another string to represent
+ * the character translation
+ */
+ String translate(char ch);
}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/ICharacterTranslatorSource.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/ICharacterTranslatorSource.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/ICharacterTranslatorSource.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/ICharacterTranslatorSource.java Fri May 5 09:20:58 2006
@@ -15,13 +15,15 @@
package org.apache.tapestry.util.text;
/**
- * A factory for creating character translators depending on the encoding
+ * A factory for creating character translators depending on the encoding.
*
* @author mb
* @since 4.0
*/
-public interface ICharacterTranslatorSource
+public interface ICharacterTranslatorSource
{
- ICharacterTranslator getDefaultTranslator();
- ICharacterTranslator getTranslator(String encoding);
+
+ ICharacterTranslator getDefaultTranslator();
+
+ ICharacterTranslator getTranslator(String encoding);
}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/LocalizedProperties.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/LocalizedProperties.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/LocalizedProperties.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/LocalizedProperties.java Fri May 5 09:20:58 2006
@@ -23,22 +23,22 @@
/**
* A version of java.util.Properties that can read the properties from files
- * using an encoding other than ISO-8859-1. All non-latin characters are read
- * correctly using the given encoding and no longer need to be quoted using native2ascii.
- *
- * In addition, the properties may be stored in an arbitrary map, rather than
- * only in Properties. For example, using LinkedHashMap will preserve the order
- * of the properties as defined in the file.
+ * using an encoding other than ISO-8859-1. All non-latin characters are read
+ * correctly using the given encoding and no longer need to be quoted using
+ * native2ascii. In addition, the properties may be stored in an arbitrary map,
+ * rather than only in Properties. For example, using LinkedHashMap will
+ * preserve the order of the properties as defined in the file.
*
* @author mb
* @since 4.0
*/
public class LocalizedProperties
{
+
private Map _propertyMap;
-
+
/**
- * Create a new object with an empty property storage
+ * Create a new object with an empty property storage
*/
public LocalizedProperties()
{
@@ -46,63 +46,70 @@
}
/**
- * Use the provided argument as the storage location for the properties managed
- * by this object. This allows different types of Map implementations to be used,
- * such as a LinkedHashMap to preserve the order of the keys, for example.
- * The provided map may contain the default property values as well.
+ * Use the provided argument as the storage location for the properties
+ * managed by this object. This allows different types of Map
+ * implementations to be used, such as a LinkedHashMap to preserve the order
+ * of the keys, for example. The provided map may contain the default
+ * property values as well.
*
- * @param propertyMap the map where properties are to be stored
+ * @param propertyMap
+ * the map where properties are to be stored
*/
public LocalizedProperties(Map propertyMap)
{
_propertyMap = propertyMap;
}
-
+
/**
- * Returns the property value corresponding the provided key. If there is no such property,
- * or the value in the provided map is not of type String, null is returned.
+ * Returns the property value corresponding the provided key. If there is no
+ * such property, or the value in the provided map is not of type String,
+ * null is returned.
*
- * @param key the property key
+ * @param key
+ * the property key
* @return the value of the property, or null if there is no such property
*/
public String getProperty(String key)
{
- Object value = _propertyMap.get(key);
- if (value instanceof String)
- return (String) value;
- return null;
- }
-
- /**
- * Returns the property value corresponding to the provided key,
- * or the provided default value if no such property exists.
- *
- * @param key the property key
- * @param defaultValue the default value of the property
- * @return the value of the property, or the default value if there is no such property
+ Object value = _propertyMap.get(key);
+ if (value instanceof String) return (String) value;
+ return null;
+ }
+
+ /**
+ * Returns the property value corresponding to the provided key, or the
+ * provided default value if no such property exists.
+ *
+ * @param key
+ * the property key
+ * @param defaultValue
+ * the default value of the property
+ * @return the value of the property, or the default value if there is no
+ * such property
*/
public String getProperty(String key, String defaultValue)
{
String value = getProperty(key);
- if (value != null)
- return value;
+ if (value != null) return value;
return defaultValue;
}
-
+
/**
* Stores a property value
*
- * @param key the property key
- * @param value the property value
+ * @param key
+ * the property key
+ * @param value
+ * the property value
*/
public void setProperty(String key, String value)
{
_propertyMap.put(key, value);
}
-
+
/**
- * Returns the map containing all properties. The map can be used to enumerate the
- * properties or their keys.
+ * Returns the map containing all properties. The map can be used to
+ * enumerate the properties or their keys.
*
* @return a map containing the properties
*/
@@ -110,47 +117,55 @@
{
return _propertyMap;
}
-
+
/**
- * Loads the properties from the given stream using the default character encoding.
- * This method operates in the same way as the equivalent method in {@link java.util.Properties},
- * but it also handles non-ascii symbols.
+ * Loads the properties from the given stream using the default character
+ * encoding. This method operates in the same way as the equivalent method
+ * in {@link java.util.Properties}, but it also handles non-ascii symbols.
*
- * @param ins the stream to load the properties from
+ * @param ins
+ * the stream to load the properties from
* @throws IOException
*/
- public void load(InputStream ins) throws IOException
+ public void load(InputStream ins)
+ throws IOException
{
- LocalizedPropertiesLoader loader = new LocalizedPropertiesLoader(ins);
+ LocalizedPropertiesLoader loader = new LocalizedPropertiesLoader(ins);
loader.load(_propertyMap);
}
-
+
/**
- * Loads the properties from the given stream using the provided character encoding.
- * This method operates in the same way as the equivalent method in {@link java.util.Properties},
- * but it also handles non-ascii symbols.
- *
- * @param ins the stream to load the properties from
- * @param encoding the encoding the use when parsing the stream
+ * Loads the properties from the given stream using the provided character
+ * encoding. This method operates in the same way as the equivalent method
+ * in {@link java.util.Properties}, but it also handles non-ascii symbols.
+ *
+ * @param ins
+ * the stream to load the properties from
+ * @param encoding
+ * the encoding the use when parsing the stream
* @throws IOException
*/
- public void load(InputStream ins, String encoding) throws UnsupportedEncodingException, IOException
+ public void load(InputStream ins, String encoding)
+ throws UnsupportedEncodingException, IOException
{
- LocalizedPropertiesLoader loader = new LocalizedPropertiesLoader(ins, encoding);
+ LocalizedPropertiesLoader loader = new LocalizedPropertiesLoader(ins,
+ encoding);
loader.load(_propertyMap);
}
-
+
/**
- * Loads the properties from the given reader.
- * This method operates in the same way as the equivalent method in {@link java.util.Properties},
- * but it also handles non-ascii symbols.
+ * Loads the properties from the given reader. This method operates in the
+ * same way as the equivalent method in {@link java.util.Properties}, but
+ * it also handles non-ascii symbols.
*
- * @param reader the reader to load the properties from
+ * @param reader
+ * the reader to load the properties from
* @throws IOException
*/
- public void load(Reader reader) throws IOException
+ public void load(Reader reader)
+ throws IOException
{
- LocalizedPropertiesLoader loader = new LocalizedPropertiesLoader(reader);
+ LocalizedPropertiesLoader loader = new LocalizedPropertiesLoader(reader);
loader.load(_propertyMap);
}
}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/LocalizedPropertiesLoader.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/LocalizedPropertiesLoader.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/LocalizedPropertiesLoader.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/LocalizedPropertiesLoader.java Fri May 5 09:20:58 2006
@@ -23,198 +23,234 @@
import java.util.Map;
/**
- * An object that loads a properties file from the provided input stream or reader.
- * This class reads the property file exactly like java.util.Properties,
+ * An object that loads a properties file from the provided input stream or
+ * reader. This class reads the property file exactly like java.util.Properties,
* except that it also allows the files to use an encoding other than ISO-8859-1
- * and all non-ASCII characters are read correctly using the given encoding.
- * In short, non-latin characters no longer need to be quoted using native2ascii.
+ * and all non-ASCII characters are read correctly using the given encoding. In
+ * short, non-latin characters no longer need to be quoted using native2ascii.
*
* @author mb
* @since 4.0
*/
public class LocalizedPropertiesLoader
{
+
private static final String HEX_DIGITS = "0123456789ABCDEF";
-
- private static final ICharacterMatcher WHITESPACE = new WhitespaceMatcher(false);
- private static final ICharacterMatcher LINE_SEPARATOR = new AsciiCharacterMatcher("\n\r");
- private static final ICharacterMatcher NOT_LINE_SEPARATOR = new InverseMatcher(LINE_SEPARATOR);
- private static final ICharacterMatcher KEY_VALUE_SEPARATOR = new AsciiCharacterMatcher("=:");
- private static final ICharacterMatcher SEPARATOR = new AsciiCharacterMatcher("=:\r\n");
- private static final ICharacterMatcher COMMENT = new AsciiCharacterMatcher("#!");
- private static final ICharacterMatcher WHITESPACE_OR_SEPARATOR =
- new CompoundMatcher(new ICharacterMatcher[] { WHITESPACE, SEPARATOR });
+
+ private static final ICharacterMatcher WHITESPACE = new WhitespaceMatcher(
+ false);
+ private static final ICharacterMatcher LINE_SEPARATOR = new AsciiCharacterMatcher(
+ "\n\r");
+ private static final ICharacterMatcher NOT_LINE_SEPARATOR = new InverseMatcher(
+ LINE_SEPARATOR);
+ private static final ICharacterMatcher KEY_VALUE_SEPARATOR = new AsciiCharacterMatcher(
+ "=:");
+ private static final ICharacterMatcher SEPARATOR = new AsciiCharacterMatcher(
+ "=:\r\n");
+ private static final ICharacterMatcher COMMENT = new AsciiCharacterMatcher(
+ "#!");
+ private static final ICharacterMatcher WHITESPACE_OR_SEPARATOR = new CompoundMatcher(
+ new ICharacterMatcher[] { WHITESPACE, SEPARATOR });
private ExtendedReader _extendedReader;
-
+
/**
- * Creates a new loader that will load the properties from the given input stream
- * using the default character encoding
+ * Creates a new loader that will load the properties from the given input
+ * stream using the default character encoding
*
- * @param ins the input stream to load the properties from
+ * @param ins
+ * the input stream to load the properties from
*/
public LocalizedPropertiesLoader(InputStream ins)
{
this(new InputStreamReader(ins));
}
-
+
/**
- * Creates a new loader that will load the properties from the given input stream
- * using the provided character encoding
+ * Creates a new loader that will load the properties from the given input
+ * stream using the provided character encoding
*
- * @param ins the input stream to load the properties from
- * @param encoding the character encoding the be used when reading from the stream
- * @throws UnsupportedEncodingException if the name of the encoding cannot be recognized
+ * @param ins
+ * the input stream to load the properties from
+ * @param encoding
+ * the character encoding the be used when reading from the
+ * stream
+ * @throws UnsupportedEncodingException
+ * if the name of the encoding cannot be recognized
*/
- public LocalizedPropertiesLoader(InputStream ins, String encoding) throws UnsupportedEncodingException
+ public LocalizedPropertiesLoader(InputStream ins, String encoding)
+ throws UnsupportedEncodingException
{
this(new InputStreamReader(ins, encoding));
}
-
+
/**
* Creates a new loader that will load the properties from the given reader
*
- * @param reader the Reader to load the properties from
+ * @param reader
+ * the Reader to load the properties from
*/
public LocalizedPropertiesLoader(Reader reader)
{
_extendedReader = new ExtendedReader(new BufferedReader(reader));
}
-
+
/**
- * Read the properties from the provided stream and store them into the given map
+ * Read the properties from the provided stream and store them into the
+ * given map
*
- * @param properties the map where the properties will be stored
- * @throws IOException if an error occurs
+ * @param properties
+ * the map where the properties will be stored
+ * @throws IOException
+ * if an error occurs
*/
- public void load(Map properties) throws IOException
+ public void load(Map properties)
+ throws IOException
{
- while (!isAtEndOfStream()) {
- // we are at the beginning of a line.
- // check whether it is a comment and if it is, skip it
+ while(!isAtEndOfStream())
+ {
+ // we are at the beginning of a line.
+ // check whether it is a comment and if it is, skip it
int nextChar = _extendedReader.peek();
- if (COMMENT.matches((char) nextChar)) {
+ if (COMMENT.matches((char) nextChar))
+ {
_extendedReader.skipCharacters(NOT_LINE_SEPARATOR);
continue;
}
-
+
_extendedReader.skipCharacters(WHITESPACE);
- if (!isAtEndOfLine()) {
- // this line does not consist only of whitespace. the next word is the key
+ if (!isAtEndOfLine())
+ {
+ // this line does not consist only of whitespace. the next word
+ // is the key
String key = readQuotedLine(WHITESPACE_OR_SEPARATOR);
_extendedReader.skipCharacters(WHITESPACE);
-
- // if the next char is a key-value separator, read it and skip the following spaces
+
+ // if the next char is a key-value separator, read it and skip
+ // the following spaces
nextChar = _extendedReader.peek();
- if (nextChar > 0 && KEY_VALUE_SEPARATOR.matches((char) nextChar)) {
+ if (nextChar > 0
+ && KEY_VALUE_SEPARATOR.matches((char) nextChar))
+ {
_extendedReader.read();
_extendedReader.skipCharacters(WHITESPACE);
}
// finally, read the value
String value = readQuotedLine(LINE_SEPARATOR);
-
+
properties.put(key, value);
}
_extendedReader.skipCharacters(LINE_SEPARATOR);
}
}
-
-
- private boolean isAtEndOfStream() throws IOException
+
+ private boolean isAtEndOfStream()
+ throws IOException
{
int nextChar = _extendedReader.peek();
return (nextChar < 0);
}
-
-
- private boolean isAtEndOfLine() throws IOException
+
+ private boolean isAtEndOfLine()
+ throws IOException
{
int nextChar = _extendedReader.peek();
- if (nextChar < 0)
- return true;
+ if (nextChar < 0) return true;
return LINE_SEPARATOR.matches((char) nextChar);
}
-
-
- private String readQuotedLine(ICharacterMatcher terminators) throws IOException
+
+ private String readQuotedLine(ICharacterMatcher terminators)
+ throws IOException
{
StringBuffer buf = new StringBuffer();
-
- while (true) {
+
+ while(true)
+ {
// see what the next char is
int nextChar = _extendedReader.peek();
-
+
// if at end of stream or the char is one of the terminators, stop
- if (nextChar < 0 || terminators.matches((char) nextChar))
- break;
+ if (nextChar < 0 || terminators.matches((char) nextChar)) break;
- try {
+ try
+ {
// read the char (and possibly unquote it)
char ch = readQuotedChar();
buf.append(ch);
- } catch (IgnoreCharacterException e) {
+ }
+ catch (IgnoreCharacterException e)
+ {
// simply ignore -- no character was read
}
}
-
+
return buf.toString();
}
-
- private char readQuotedChar() throws IOException, IgnoreCharacterException
+ private char readQuotedChar()
+ throws IOException, IgnoreCharacterException
{
int nextChar = _extendedReader.read();
- if (nextChar < 0)
- throw new IgnoreCharacterException();
+ if (nextChar < 0) throw new IgnoreCharacterException();
char ch = (char) nextChar;
-
+
// if the char is not the quotation char, simply return it
- if (ch != '\\')
- return ch;
+ if (ch != '\\') return ch;
// the character is a quotation character. unquote it
nextChar = _extendedReader.read();
// if at the end of the stream, stop
- if (nextChar < 0)
- throw new IgnoreCharacterException();
-
+ if (nextChar < 0) throw new IgnoreCharacterException();
+
ch = (char) nextChar;
- switch (ch) {
- case 'u' :
- char res = 0;
- for (int i = 0; i < 4; i++) {
- nextChar = _extendedReader.read();
- if (nextChar < 0)
- throw new IllegalArgumentException("Malformed \\uxxxx encoding.");
- char digitChar = (char) nextChar;
- int digit = HEX_DIGITS.indexOf(Character.toUpperCase(digitChar));
- if (digit < 0)
- throw new IllegalArgumentException("Malformed \\uxxxx encoding.");
- res = (char) (res * 16 + digit);
- }
- return res;
+ switch(ch)
+ {
+ case 'u':
+ char res = 0;
+ for(int i = 0; i < 4; i++)
+ {
+ nextChar = _extendedReader.read();
+ if (nextChar < 0)
+ throw new IllegalArgumentException(
+ "Malformed \\uxxxx encoding.");
+ char digitChar = (char) nextChar;
+ int digit = HEX_DIGITS
+ .indexOf(Character.toUpperCase(digitChar));
+ if (digit < 0)
+ throw new IllegalArgumentException(
+ "Malformed \\uxxxx encoding.");
+ res = (char) (res * 16 + digit);
+ }
+ return res;
- case '\r' :
- // if the next char is \n, read it and fall through
- nextChar = _extendedReader.peek();
- if (nextChar == '\n')
- _extendedReader.read();
- case '\n' :
- _extendedReader.skipCharacters(WHITESPACE);
- throw new IgnoreCharacterException();
-
- case 't' : return '\t';
- case 'n' : return '\n';
- case 'r' : return '\r';
- default: return ch;
+ case '\r':
+ // if the next char is \n, read it and fall through
+ nextChar = _extendedReader.peek();
+ if (nextChar == '\n') _extendedReader.read();
+ case '\n':
+ _extendedReader.skipCharacters(WHITESPACE);
+ throw new IgnoreCharacterException();
+
+ case 't':
+ return '\t';
+ case 'n':
+ return '\n';
+ case 'r':
+ return '\r';
+ default:
+ return ch;
}
}
-
- private static class IgnoreCharacterException extends Exception
+ /**
+ *
+ * @author unknown
+ */
+ private static class IgnoreCharacterException extends Exception
{
- private static final long serialVersionUID = 8366308710256427596L;
- }
+
+ private static final long serialVersionUID = 8366308710256427596L;
+ }
}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/MarkupCharacterTranslator.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/MarkupCharacterTranslator.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/MarkupCharacterTranslator.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/MarkupCharacterTranslator.java Fri May 5 09:20:58 2006
@@ -15,77 +15,74 @@
package org.apache.tapestry.util.text;
/**
- * An object that encodes a character according to rules of the HTML specification,
- * so that it will be properly parsed by a browser irrespectively of the character
- * encoding used in the HTML output.
+ * An object that encodes a character according to rules of the HTML
+ * specification, so that it will be properly parsed by a browser irrespectively
+ * of the character encoding used in the HTML output.
*
* @author mb
* @since 4.0
*/
public class MarkupCharacterTranslator implements ICharacterTranslator
{
- private static final String SAFE_CHARACTERS =
- "01234567890"
- + "abcdefghijklmnopqrstuvwxyz"
- + "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+
+ private static final String SAFE_CHARACTERS = "01234567890"
+ + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "\t\n\r !#$%'()*+,-./:;=?@[\\]^_`{|}~";
- private static final String[][] ENTITIES = {
- { "\"", """ },
- { "<", "<" },
- { ">", ">" },
- { "&", "&" }
- };
-
- private static final ICharacterMatcher SAFE_MATCHER = new AsciiCharacterMatcher(SAFE_CHARACTERS);
- private static final ICharacterTranslator ENTITY_TRANSLATOR = new AsciiCharacterTranslator(ENTITIES);
-
+ private static final String[][] ENTITIES = { { "\"", """ },
+ { "<", "<" }, { ">", ">" }, { "&", "&" } };
+
+ private static final ICharacterMatcher SAFE_MATCHER = new AsciiCharacterMatcher(
+ SAFE_CHARACTERS);
+ private static final ICharacterTranslator ENTITY_TRANSLATOR = new AsciiCharacterTranslator(
+ ENTITIES);
+
private boolean _encodeNonAscii;
private ICharacterMatcher _safeMatcher;
private ICharacterTranslator _entityTranslator;
-
+
public MarkupCharacterTranslator()
{
- this(true);
+ this(true);
}
-
+
public MarkupCharacterTranslator(boolean encodeNonAscii)
{
- this(encodeNonAscii, SAFE_MATCHER, ENTITY_TRANSLATOR);
+ this(encodeNonAscii, SAFE_MATCHER, ENTITY_TRANSLATOR);
+ }
+
+ public MarkupCharacterTranslator(boolean encodeNonAscii,
+ ICharacterMatcher safeMatcher, ICharacterTranslator entityTranslator)
+ {
+ _encodeNonAscii = encodeNonAscii;
+ _safeMatcher = safeMatcher;
+ _entityTranslator = entityTranslator;
}
-
- public MarkupCharacterTranslator(boolean encodeNonAscii, ICharacterMatcher safeMatcher, ICharacterTranslator entityTranslator)
+
+ public MarkupCharacterTranslator(boolean encodeNonAscii,
+ String safeCharacters, String[][] entities)
{
- _encodeNonAscii = encodeNonAscii;
- _safeMatcher = safeMatcher;
- _entityTranslator = entityTranslator;
+ _encodeNonAscii = encodeNonAscii;
+ _safeMatcher = new AsciiCharacterMatcher(safeCharacters);
+ _entityTranslator = new AsciiCharacterTranslator(entities);
}
- public MarkupCharacterTranslator(boolean encodeNonAscii, String safeCharacters, String[][] entities)
+ /**
+ * @see org.apache.tapestry.util.text.IMarkupCharacterTranslator#translateAttribute(char)
+ */
+ public String translate(char ch)
{
- _encodeNonAscii = encodeNonAscii;
- _safeMatcher = new AsciiCharacterMatcher(safeCharacters);
- _entityTranslator = new AsciiCharacterTranslator(entities);
+ // IE and Firefox do not handle characters between 128 and 159 well,
+ // so they have to be quoted as well
+ if (ch >= 160 && !_encodeNonAscii) return null;
+
+ if (_safeMatcher.matches(ch)) return null;
+
+ String entity = _entityTranslator.translate(ch);
+ if (entity != null) return entity;
+
+ // needs to use a NumberFormat here to be fully compliant,
+ // but this is accepted fine by the browsers
+ return "&#" + (int) ch + ";";
}
-
- /**
- * @see org.apache.tapestry.util.text.IMarkupCharacterTranslator#translateAttribute(char)
- */
- public String translate(char ch) {
- // IE and Firefox do not handle characters between 128 and 159 well,
- // so they have to be quoted as well
- if (ch >= 160 && !_encodeNonAscii)
- return null;
-
- if (_safeMatcher.matches(ch))
- return null;
-
- String entity = _entityTranslator.translate(ch);
- if (entity != null)
- return entity;
-
- // needs to use a NumberFormat here to be fully compliant,
- // but this is accepted fine by the browsers
- return "&#" + (int) ch + ";";
- }
}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/WhitespaceMatcher.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/WhitespaceMatcher.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/WhitespaceMatcher.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/text/WhitespaceMatcher.java Fri May 5 09:20:58 2006
@@ -20,41 +20,42 @@
* @author mb
* @since 4.0
*/
-public class WhitespaceMatcher implements ICharacterMatcher
+public class WhitespaceMatcher implements ICharacterMatcher
{
+
private boolean _matchEndLines;
-
+
/**
- * Creates an object that matches all whitespace characters, line terminators included
+ * Creates an object that matches all whitespace characters, line
+ * terminators included.
*/
public WhitespaceMatcher()
{
this(true);
}
-
+
/**
- * Creates an object that matches whitespace characters.
- * Line terminators are included only if this is specified.
+ * Creates an object that matches whitespace characters. Line terminators
+ * are included only if this is specified.
*
- * @param matchEndLines match line terminators as well
+ * @param matchEndLines
+ * match line terminators as well
*/
public WhitespaceMatcher(boolean matchEndLines)
{
_matchEndLines = matchEndLines;
}
-
+
/**
- * Matches whitespace characters. Line terminators may be matched
- * depending on the constructor used to create the object.
+ * Matches whitespace characters. Line terminators may be matched depending
+ * on the constructor used to create the object.
*
* @see org.apache.tapestry.util.text.ICharacterMatcher#matches(char)
*/
public boolean matches(char ch)
{
- if (!_matchEndLines)
- if (ch == '\n' || ch == '\r')
- return false;
-
+ if (!_matchEndLines) if (ch == '\n' || ch == '\r') return false;
+
return Character.isWhitespace(ch);
}
-}
\ No newline at end of file
+}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/xml/DocumentParseException.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/xml/DocumentParseException.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/xml/DocumentParseException.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/xml/DocumentParseException.java Fri May 5 09:20:58 2006
@@ -30,9 +30,10 @@
public class DocumentParseException extends ApplicationRuntimeException
{
+
private static final long serialVersionUID = 4630222650675402789L;
- public DocumentParseException(String message)
+ public DocumentParseException(String message)
{
this(message, (Resource) null);
}
@@ -47,15 +48,18 @@
super(message, location, null);
}
- public DocumentParseException(String message, Location location, Throwable rootCause)
+ public DocumentParseException(String message, Location location,
+ Throwable rootCause)
{
super(message, location, rootCause);
}
- public DocumentParseException(String message, Resource resource, SAXParseException rootCause)
+ public DocumentParseException(String message, Resource resource,
+ SAXParseException rootCause)
{
- this(message, resource == null ? null : new LocationImpl(resource, rootCause
- .getLineNumber(), rootCause.getColumnNumber()), rootCause);
+ this(message, resource == null ? null : new LocationImpl(resource,
+ rootCause.getLineNumber(), rootCause.getColumnNumber()),
+ rootCause);
}
public DocumentParseException(String message, Resource resource)
@@ -63,8 +67,10 @@
this(message, resource, (Throwable) null);
}
- public DocumentParseException(String message, Resource resource, Throwable rootCause)
+ public DocumentParseException(String message, Resource resource,
+ Throwable rootCause)
{
- this(message, resource == null ? null : new LocationImpl(resource), rootCause);
+ this(message, resource == null ? null : new LocationImpl(resource),
+ rootCause);
}
-}
\ No newline at end of file
+}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/xml/IRule.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/xml/IRule.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/xml/IRule.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/xml/IRule.java Fri May 5 09:20:58 2006
@@ -17,39 +17,42 @@
import org.xml.sax.Attributes;
/**
- * A rule that may be pushed onto the {@link org.apache.tapestry.util.xml.RuleDirectedParser}'s
- * rule stack. A rule is associated with an XML element. It is pushed onto the stack when the
- * open tag for the rule is encountered. It is is popped off the stack after the end-tag is
- * encountered. It is notified about any text it directly wraps around.
+ * A rule that may be pushed onto the
+ * {@link org.apache.tapestry.util.xml.RuleDirectedParser}'s rule stack. A rule
+ * is associated with an XML element. It is pushed onto the stack when the open
+ * tag for the rule is encountered. It is is popped off the stack after the
+ * end-tag is encountered. It is notified about any text it directly wraps
+ * around.
+ * <p>
+ * Rules should be stateless, because a rule instance may appear multiple times
+ * in the rule stack (if elements can be recusively nested).
*
- * <p>Rules should be stateless, because a rule instance may appear multiple times in the
- * rule stack (if elements can be recusively nested).
- *
* @author Howard Lewis Ship
* @since 3.0
- **/
+ */
public interface IRule
{
- /**
- * Invoked just after the rule is pushed onto the rule stack. Typically, a Rule will
- * use the information to create a new object and push it onto the object stack.
- * If the rule needs to know about the element (rather than the attributes), it
- * may obtain the URI, localName and qName from the parser.
- *
- */
- public void startElement(RuleDirectedParser parser, Attributes attributes);
-
- /**
- * Invoked just after the rule is popped off the rule stack.
- */
- public void endElement(RuleDirectedParser parser);
-
-
- /**
- * Invoked when real content is found. The parser is responsible for aggregating
- * all content provided by the underlying SAX parser into a single string.
- */
-
- public void content(RuleDirectedParser parser, String content);
+
+ /**
+ * Invoked just after the rule is pushed onto the rule stack. Typically, a
+ * Rule will use the information to create a new object and push it onto the
+ * object stack. If the rule needs to know about the element (rather than
+ * the attributes), it may obtain the URI, localName and qName from the
+ * parser.
+ */
+ void startElement(RuleDirectedParser parser, Attributes attributes);
+
+ /**
+ * Invoked just after the rule is popped off the rule stack.
+ */
+ void endElement(RuleDirectedParser parser);
+
+ /**
+ * Invoked when real content is found. The parser is responsible for
+ * aggregating all content provided by the underlying SAX parser into a
+ * single string.
+ */
+
+ void content(RuleDirectedParser parser, String content);
}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/xml/InvalidStringException.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/xml/InvalidStringException.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/xml/InvalidStringException.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/xml/InvalidStringException.java Fri May 5 09:20:58 2006
@@ -18,7 +18,7 @@
import org.apache.hivemind.Location;
/**
- * Exception thrown if there is any kind of error validating a string during document parsing
+ * Exception thrown if there is any kind of error validating a string during document parsing.
*
* @author Geoffrey Longman
* @since 2.2
@@ -28,7 +28,7 @@
{
private static final long serialVersionUID = 8199998733585358584L;
- private String _invalidString;
+ private final String _invalidString;
public InvalidStringException(String message, String invalidString, Location location)
{
@@ -41,4 +41,4 @@
{
return _invalidString;
}
-}
\ No newline at end of file
+}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/xml/RuleDirectedParser.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/xml/RuleDirectedParser.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/xml/RuleDirectedParser.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/util/xml/RuleDirectedParser.java Fri May 5 09:20:58 2006
@@ -47,8 +47,7 @@
* many bells and whistles but has some key features needed when parsing a document (rather than a
* configuration file): <br>
* <ul>
- * <li>Notifications for each bit of text
- * </ul>
+ * <li>Notifications for each bit of text</li>
* <li>Tracking of exact location within the document.</li>
* </ul>
* <p>
@@ -65,6 +64,8 @@
{
private static final Log LOG = LogFactory.getLog(RuleDirectedParser.class);
+ private static SAXParserFactory _parserFactory;
+
private Resource _documentLocation;
private List _ruleStack = new ArrayList();
@@ -81,8 +82,6 @@
private Location _location;
- private static SAXParserFactory _parserFactory;
-
private SAXParser _parser;
private RegexpMatcher _matcher;
@@ -513,7 +512,6 @@
*/
public void validate(String value, String pattern, String errorKey)
- throws DocumentParseException
{
if (_matcher == null)
_matcher = new RegexpMatcher();
@@ -571,4 +569,4 @@
peekRule().content(this, content);
}
-}
\ No newline at end of file
+}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/valid/BaseValidator.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/valid/BaseValidator.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/valid/BaseValidator.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/valid/BaseValidator.java Fri May 5 09:20:58 2006
@@ -20,7 +20,6 @@
import java.util.Map;
import java.util.ResourceBundle;
-import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.hivemind.HiveMind;
import org.apache.hivemind.Resource;
import org.apache.hivemind.impl.DefaultClassResolver;
@@ -34,7 +33,6 @@
import org.apache.tapestry.TapestryUtils;
import org.apache.tapestry.engine.IScriptSource;
import org.apache.tapestry.form.IFormComponent;
-import org.apache.tapestry.html.Body;
/**
* Abstract base class for {@link IValidator}. Supports a required and locale property.
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/valid/EmailValidator.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/valid/EmailValidator.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/valid/EmailValidator.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/valid/EmailValidator.java Fri May 5 09:20:58 2006
@@ -23,8 +23,9 @@
import org.apache.tapestry.form.IFormComponent;
/**
- * Simple validation of email strings, to enforce required, and minimum length (maximum length is
- * enforced in the client browser, by setting a maximum input length on the text field).
+ * Simple validation of email strings, to enforce required, and minimum length
+ * (maximum length is enforced in the client browser, by setting a maximum input
+ * length on the text field).
*
* @author Malcolm Edgar
* @since 2.3
@@ -32,6 +33,7 @@
public class EmailValidator extends BaseValidator
{
+
private int _minimumLength;
private String _minimumLengthMessage;
@@ -45,7 +47,8 @@
}
/**
- * Initializes the EmailValidator with properties defined by the initializer.
+ * Initializes the EmailValidator with properties defined by the
+ * initializer.
*
* @since 4.0
*/
@@ -57,16 +60,15 @@
public String toString(IFormComponent field, Object value)
{
- if (value == null)
- return null;
+ if (value == null) return null;
return value.toString();
}
- public Object toObject(IFormComponent field, String input) throws ValidatorException
+ public Object toObject(IFormComponent field, String input)
+ throws ValidatorException
{
- if (checkRequired(field, input))
- return null;
+ if (checkRequired(field, input)) return null;
if (_minimumLength > 0 && input.length() < _minimumLength)
throw new ValidatorException(buildMinimumLengthMessage(field),
@@ -89,11 +91,10 @@
_minimumLength = minimumLength;
}
- public void renderValidatorContribution(IFormComponent field, IMarkupWriter writer,
- IRequestCycle cycle)
+ public void renderValidatorContribution(IFormComponent field,
+ IMarkupWriter writer, IRequestCycle cycle)
{
- if (!isClientScriptingEnabled())
- return;
+ if (!isClientScriptingEnabled()) return;
Map symbols = new HashMap();
@@ -104,9 +105,11 @@
symbols.put("requiredMessage", buildRequiredMessage(field));
if (_minimumLength > 0)
- symbols.put("minimumLengthMessage", buildMinimumLengthMessage(field));
+ symbols.put("minimumLengthMessage",
+ buildMinimumLengthMessage(field));
- String pattern = getPattern(getInvalidEmailFormatMessage(), "invalid-email-format", locale);
+ String pattern = getPattern(getInvalidEmailFormatMessage(),
+ "invalid-email-format", locale);
symbols.put("emailFormatMessage", formatString(pattern, displayName));
@@ -119,9 +122,10 @@
}
/**
- * Allows a developer to use the existing validation logic with a different client-side script.
- * This is often sufficient to allow application-specific error presentation (perhaps by using
- * DHTML to update the content of a <span> tag, or to use a more sophisticated pop-up
+ * Allows a developer to use the existing validation logic with a different
+ * client-side script. This is often sufficient to allow
+ * application-specific error presentation (perhaps by using DHTML to update
+ * the content of a <span> tag, or to use a more sophisticated pop-up
* window than <code>window.alert()</code>).
*/
@@ -160,8 +164,8 @@
}
/**
- * Overrides the <code>invalid-email-format</code> bundle key. Parameter {0} is the display
- * name of the field.
+ * Overrides the <code>invalid-email-format</code> bundle key. Parameter
+ * {0} is the display name of the field.
*
* @since 3.0
*/
@@ -172,8 +176,8 @@
}
/**
- * Overrides the <code>field-too-short</code> bundle key. Parameter {0} is the minimum length.
- * Parameter {1} is the display name of the field.
+ * Overrides the <code>field-too-short</code> bundle key. Parameter {0} is
+ * the minimum length. Parameter {1} is the display name of the field.
*
* @since 3.0
*/
@@ -186,19 +190,20 @@
protected String buildMinimumLengthMessage(IFormComponent field)
{
- String pattern = getPattern(_minimumLengthMessage, "field-too-short", field.getPage()
- .getLocale());
+ String pattern = getPattern(_minimumLengthMessage, "field-too-short",
+ field.getPage().getLocale());
- return formatString(pattern, Integer.toString(_minimumLength), field.getDisplayName());
+ return formatString(pattern, Integer.toString(_minimumLength), field
+ .getDisplayName());
}
/** @since 3.0 */
protected String buildInvalidEmailFormatMessage(IFormComponent field)
{
- String pattern = getPattern(_invalidEmailFormatMessage, "invalid-email-format", field
- .getPage().getLocale());
+ String pattern = getPattern(_invalidEmailFormatMessage,
+ "invalid-email-format", field.getPage().getLocale());
return formatString(pattern, field.getDisplayName());
}
-}
\ No newline at end of file
+}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/valid/FieldLabel.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/valid/FieldLabel.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/valid/FieldLabel.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/valid/FieldLabel.java Fri May 5 09:20:58 2006
@@ -24,35 +24,37 @@
import org.apache.tapestry.form.IFormComponent;
/**
- * Used to label an {@link IFormComponent}. Because such fields know their displayName
- * (user-presentable name), there's no reason to hard code the label in a page's HTML template (this
- * also helps with localization). [ <a
- * href="../../../../../ComponentReference/FieldLabel.html">Component Reference </a>]
+ * Used to label an {@link IFormComponent}. Because such fields know their
+ * displayName (user-presentable name), there's no reason to hard code the label
+ * in a page's HTML template (this also helps with localization). [ <a
+ * href="../../../../../ComponentReference/FieldLabel.html">Component Reference
+ * </a>]
*
* @author Howard Lewis Lewis Ship
*/
public abstract class FieldLabel extends AbstractComponent
{
+
// Parameter
public abstract boolean isPrerender();
/**
- * Gets the {@link IForm} and {@link IValidationDelegate delegate}, then renders the
- * label obtained from the field. Does nothing when rewinding.
+ * Gets the {@link IForm} and {@link IValidationDelegate delegate},
+ * then renders the label obtained from the field. Does nothing when
+ * rewinding.
*/
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
{
IForm form = TapestryUtils.getForm(cycle, this);
-
+
IFormComponent field = getField();
-
+
if (field != null && isPrerender())
form.prerenderField(writer, field, getLocation());
- if (cycle.isRewinding())
- return;
+ if (cycle.isRewinding()) return;
String displayName = getDisplayName();
@@ -64,8 +66,8 @@
displayName = field.getDisplayName();
if (displayName == null)
- throw new BindingException(ValidMessages.noDisplayName(this, field), this, null,
- getBinding("field"), null);
+ throw new BindingException(ValidMessages.noDisplayName(this,
+ field), this, null, getBinding("field"), null);
}
IValidationDelegate delegate = form.getDelegate();
@@ -76,9 +78,8 @@
writer.begin("label");
- if (id != null)
- writer.attribute("for", id);
-
+ if (id != null) writer.attribute("for", id);
+
delegate.writeLabelAttributes(writer, cycle, field);
renderInformalParameters(writer, cycle);
@@ -97,4 +98,4 @@
/** raw parameter */
public abstract boolean getRaw();
-}
\ No newline at end of file
+}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/valid/FieldTracking.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/valid/FieldTracking.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/valid/FieldTracking.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/valid/FieldTracking.java Fri May 5 09:20:58 2006
@@ -29,6 +29,7 @@
public class FieldTracking implements IFieldTracking, Serializable
{
+
private static final long serialVersionUID = -5397563163968532716L;
private transient IFormComponent _component;
@@ -42,8 +43,8 @@
private ValidationConstraint _constraint;
/**
- * Constructor used for unassociated errors; errors that are not about any particular field
- * within the form.
+ * Constructor used for unassociated errors; errors that are not about any
+ * particular field within the form.
*/
FieldTracking()
@@ -51,7 +52,8 @@
}
/**
- * Standard constructor for a field (with the given name), rendered by the specified component.
+ * Standard constructor for a field (with the given name), rendered by the
+ * specified component.
*/
FieldTracking(String fieldName, IFormComponent component)
@@ -110,4 +112,4 @@
return _renderer != null;
}
-}
\ No newline at end of file
+}
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/valid/IFieldTracking.java
URL: http://svn.apache.org/viewcvs/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/valid/IFieldTracking.java?rev=400102&r1=400101&r2=400102&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/valid/IFieldTracking.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/valid/IFieldTracking.java Fri May 5 09:20:58 2006
@@ -18,14 +18,17 @@
import org.apache.tapestry.form.IFormComponent;
/**
- * Defines the interface for an object that tracks input fields. This interface is now poorly named,
- * in that it tracks errors that may <em>not</em> be associated with a specific field.
+ * Defines the interface for an object that tracks input fields. This interface
+ * is now poorly named, in that it tracks errors that may <em>not</em> be
+ * associated with a specific field.
* <p>
- * For each field, a flag is stored indicating if the field is, in fact, in error. The input
- * supplied by the client is stored so that if the form is re-rendered (as is typically done when
- * there are input errors), the value entered by the user can be displayed back to the user. An
- * error message renderer is stored; this is an object that can render the error message (it is
- * usually a {@link org.apache.tapestry.valid.RenderString} wrapper around a simple string).
+ * For each field, a flag is stored indicating if the field is, in fact, in
+ * error. The input supplied by the client is stored so that if the form is
+ * re-rendered (as is typically done when there are input errors), the value
+ * entered by the user can be displayed back to the user. An error message
+ * renderer is stored; this is an object that can render the error message (it
+ * is usually a {@link org.apache.tapestry.valid.RenderString} wrapper
+ * around a simple string).
*
* @author Howard Lewis Ship
* @since 1.0.8
@@ -33,50 +36,56 @@
public interface IFieldTracking
{
+
/**
- * Returns true if the field is in error (that is, if it has an error message
- * {@link #getErrorRenderer() renderer}.
+ * Returns true if the field is in error (that is, if it has an error
+ * message {@link #getErrorRenderer() renderer}.
*/
- public boolean isInError();
+ boolean isInError();
/**
- * Returns the field component. This may return null if the error is not associated with any
- * particular field. Note: may return null after the field tracking object is serialized and
- * deserialized (the underlying component reference is transient); this metehod is primarily
- * used for testing.
+ * Returns the field component. This may return null if the error is not
+ * associated with any particular field. Note: may return null after the
+ * field tracking object is serialized and deserialized (the underlying
+ * component reference is transient); this metehod is primarily used for
+ * testing.
*/
- public IFormComponent getComponent();
+ IFormComponent getComponent();
/**
- * Returns an object that will render the error message. The renderer <em>must</em> implement
- * a simple <code>toString()</code> that does not produce markup, but is a simple message.
+ * Returns an object that will render the error message. The renderer
+ * <em>must</em> implement a simple <code>toString()</code> that does
+ * not produce markup, but is a simple message.
*
- * @see ValidatorException#ValidatorException(String, IRender, ValidationConstraint)
+ * @see ValidatorException#ValidatorException(String, IRender,
+ * ValidationConstraint)
* @since 1.0.9
*/
- public IRender getErrorRenderer();
+ IRender getErrorRenderer();
/**
- * Returns the invalid input recorded for the field. This is stored so that, on a subsequent
- * render, the smae invalid input can be presented to the client to be corrected.
+ * Returns the invalid input recorded for the field. This is stored so that,
+ * on a subsequent render, the smae invalid input can be presented to the
+ * client to be corrected.
*/
- public String getInput();
+ String getInput();
/**
- * Returns the name of the field, that is, the name assigned by the form (this will differ from
- * the component's id when any kind of looping operation is in effect).
+ * Returns the name of the field, that is, the name assigned by the form
+ * (this will differ from the component's id when any kind of looping
+ * operation is in effect).
*/
- public String getFieldName();
+ String getFieldName();
/**
- * Returns the validation constraint that was violated by the input. This may be null if the
- * constraint isn't known.
+ * Returns the validation constraint that was violated by the input. This
+ * may be null if the constraint isn't known.
*/
- public ValidationConstraint getConstraint();
-}
\ No newline at end of file
+ ValidationConstraint getConstraint();
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org