You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2006/01/12 18:13:34 UTC
svn commit: r368410 [9/10] - in
/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry: ./ bean/
binding/ callback/ coerce/ components/ describe/ engine/ engine/state/
enhance/ error/ event/ form/ form/translator/ form/validator/ html/ link/
li...
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/text/ICharacterTranslatorSource.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/text/ICharacterTranslatorSource.java?rev=368410&r1=368409&r2=368410&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/text/ICharacterTranslatorSource.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/text/ICharacterTranslatorSource.java Thu Jan 12 09:12:21 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -20,8 +20,10 @@
* @author mb
* @since 4.0
*/
-public interface ICharacterTranslatorSource
+public interface ICharacterTranslatorSource
{
- ICharacterTranslator getDefaultTranslator();
- ICharacterTranslator getTranslator(String encoding);
+
+ ICharacterTranslator getDefaultTranslator();
+
+ ICharacterTranslator getTranslator(String encoding);
}
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/text/LocalizedProperties.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/text/LocalizedProperties.java?rev=368410&r1=368409&r2=368410&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/text/LocalizedProperties.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/text/LocalizedProperties.java Thu Jan 12 09:12:21 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -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,54 @@
{
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: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/text/LocalizedPropertiesLoader.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/text/LocalizedPropertiesLoader.java?rev=368410&r1=368409&r2=368410&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/text/LocalizedPropertiesLoader.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/text/LocalizedPropertiesLoader.java Thu Jan 12 09:12:21 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -23,198 +23,222 @@
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_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;
- return LINE_SEPARATOR.matches((char) nextChar);
- }
-
-
- private String readQuotedLine(ICharacterMatcher terminators) throws IOException
+ if (nextChar < 0) return true;
+ return LINE_SEPARATOR.matches((char)nextChar);
+ }
+
+ 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();
- char ch = (char) nextChar;
-
+ 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)
+ 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;
+
+ 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();
-
- 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;
- 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 't':
+ return '\t';
+ case 'n':
+ return '\n';
+ case 'r':
+ return '\r';
+ default:
+ return ch;
}
}
-
- private static class IgnoreCharacterException extends Exception
+ /**
+ * Exception thrown (blech) as a control flow mechanism when an ignorable
+ * character is found.
+ */
+ private static class IgnoreCharacterException extends Exception
{
- private static final long serialVersionUID = 8366308710256427596L;
- }
+
+ private static final long serialVersionUID = 8366308710256427596L;
+ }
}
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/text/MarkupCharacterTranslator.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/text/MarkupCharacterTranslator.java?rev=368410&r1=368409&r2=368410&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/text/MarkupCharacterTranslator.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/text/MarkupCharacterTranslator.java Thu Jan 12 09:12:21 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -15,77 +15,69 @@
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"
- + "\t\n\r !#$%'()*+,-./:;=?@[\\]^_`{|}~";
-
- private static final String[][] ENTITIES = {
- { "\"", """ },
- { "<", "<" },
- { ">", ">" },
- { "&", "&" }
- };
-
+
+ private static final String SAFE_CHARACTERS = "01234567890abcdefghijklmnopqrstuvwxyz"
+ + "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 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)
+
+ public MarkupCharacterTranslator(boolean encodeNonAscii, ICharacterMatcher safeMatcher,
+ ICharacterTranslator entityTranslator)
{
- _encodeNonAscii = encodeNonAscii;
- _safeMatcher = safeMatcher;
- _entityTranslator = entityTranslator;
+ _encodeNonAscii = encodeNonAscii;
+ _safeMatcher = safeMatcher;
+ _entityTranslator = entityTranslator;
}
public MarkupCharacterTranslator(boolean encodeNonAscii, String safeCharacters, String[][] entities)
{
- _encodeNonAscii = encodeNonAscii;
- _safeMatcher = new AsciiCharacterMatcher(safeCharacters);
- _entityTranslator = new AsciiCharacterTranslator(entities);
+ _encodeNonAscii = encodeNonAscii;
+ _safeMatcher = new AsciiCharacterMatcher(safeCharacters);
+ _entityTranslator = new AsciiCharacterTranslator(entities);
+ }
+
+ /**
+ * @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 + ";";
}
-
- /**
- * @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: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/text/WhitespaceMatcher.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/text/WhitespaceMatcher.java?rev=368410&r1=368409&r2=368410&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/text/WhitespaceMatcher.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/text/WhitespaceMatcher.java Thu Jan 12 09:12:21 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -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: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/xml/DocumentParseException.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/xml/DocumentParseException.java?rev=368410&r1=368409&r2=368410&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/xml/DocumentParseException.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/xml/DocumentParseException.java Thu Jan 12 09:12:21 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -30,11 +30,12 @@
public class DocumentParseException extends ApplicationRuntimeException
{
+
private static final long serialVersionUID = 4630222650675402789L;
- public DocumentParseException(String message)
+ public DocumentParseException(String message)
{
- this(message, (Resource) null);
+ this(message, (Resource)null);
}
public DocumentParseException(String message, Throwable rootCause)
@@ -54,17 +55,17 @@
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)
{
- this(message, resource, (Throwable) null);
+ this(message, resource, (Throwable)null);
}
public DocumentParseException(String message, Resource resource, Throwable rootCause)
{
this(message, resource == null ? null : new LocationImpl(resource), rootCause);
}
-}
\ No newline at end of file
+}
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/xml/IRule.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/xml/IRule.java?rev=368410&r1=368409&r2=368410&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/xml/IRule.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/xml/IRule.java Thu Jan 12 09:12:21 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -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.
+ */
+ 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);
}
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/xml/InvalidStringException.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/xml/InvalidStringException.java?rev=368410&r1=368409&r2=368410&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/xml/InvalidStringException.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/util/xml/InvalidStringException.java Thu Jan 12 09:12:21 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -18,7 +18,8 @@
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
@@ -26,9 +27,10 @@
public class InvalidStringException extends DocumentParseException implements Locatable
{
+
private static final long serialVersionUID = 8199998733585358584L;
-
- private String _invalidString;
+
+ private String _invalidString;
public InvalidStringException(String message, String invalidString, Location location)
{
@@ -41,4 +43,4 @@
{
return _invalidString;
}
-}
\ No newline at end of file
+}
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/AbstractNumericValidator.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/AbstractNumericValidator.java?rev=368410&r1=368409&r2=368410&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/AbstractNumericValidator.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/AbstractNumericValidator.java Thu Jan 12 09:12:21 2006
@@ -1,4 +1,4 @@
-// Copyright 2005 The Apache Software Foundation
+// Copyright 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -17,15 +17,28 @@
import org.apache.tapestry.form.IFormComponent;
/**
- * Base class for a number of implementations of {@link org.apache.tapestry.valid.IValidator},
- * meant to replace the awkward {@link org.apache.tapestry.valid.NumberValidator}.
+ * Base class for a number of implementations of
+ * {@link org.apache.tapestry.valid.IValidator}, meant to replace the awkward
+ * {@link org.apache.tapestry.valid.NumberValidator}.
*
* @author Howard M. Lewis Ship
*/
-public abstract class AbstractNumericValidator extends BaseValidator
-{
+public abstract class AbstractNumericValidator extends BaseValidator {
+
private boolean _zeroIsNull;
+ private String _scriptPath = getDefaultScriptPath();
+
+ private String _invalidNumericFormatMessage;
+
+ private String _invalidIntegerFormatMessage;
+
+ private String _numberTooSmallMessage;
+
+ private String _numberTooLargeMessage;
+
+ private String _numberRangeMessage;
+
public AbstractNumericValidator()
{
super();
@@ -42,8 +55,8 @@
}
/**
- * If true, then when rendering, a zero is treated as a non-value, and null is returned. If
- * false, the default, then zero is rendered as zero.
+ * If true, then when rendering, a zero is treated as a non-value, and null
+ * is returned. If false, the default, then zero is rendered as zero.
*/
public boolean getZeroIsNull()
@@ -56,20 +69,6 @@
_zeroIsNull = zeroIsNull;
}
- private String _scriptPath =
- getDefaultScriptPath();
-
-
- private String _invalidNumericFormatMessage;
-
- private String _invalidIntegerFormatMessage;
-
- private String _numberTooSmallMessage;
-
- private String _numberTooLargeMessage;
-
- private String _numberRangeMessage;
-
/**
* @since 2.2
*/
@@ -79,9 +78,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>).
*
* @since 2.2
@@ -122,8 +122,8 @@
}
/**
- * Overrides the <code>invalid-numeric-format</code> bundle key. Parameter {0} is the display
- * name of the field.
+ * Overrides the <code>invalid-numeric-format</code> bundle key. Parameter
+ * {0} is the display name of the field.
*
* @since 3.0
*/
@@ -133,8 +133,8 @@
}
/**
- * Overrides the <code>invalid-int-format</code> bundle key. Parameter {0} is the display name
- * of the field.
+ * Overrides the <code>invalid-int-format</code> bundle key. Parameter {0}
+ * is the display name of the field.
*
* @since 3.0
*/
@@ -144,8 +144,9 @@
}
/**
- * Overrides the <code>number-range</code> bundle key. Parameter [0} is the display name of
- * the field. Parameter {1} is the minimum value. Parameter {2} is the maximum value.
+ * Overrides the <code>number-range</code> bundle key. Parameter [0} is
+ * the display name of the field. Parameter {1} is the minimum value.
+ * Parameter {2} is the maximum value.
*
* @since 3.0
*/
@@ -155,8 +156,9 @@
}
/**
- * Overrides the <code>number-too-large</code> bundle key. Parameter {0} is the display name
- * of the field. Parameter {1} is the maximum allowed value.
+ * Overrides the <code>number-too-large</code> bundle key. Parameter {0}
+ * is the display name of the field. Parameter {1} is the maximum allowed
+ * value.
*
* @since 3.0
*/
@@ -166,8 +168,9 @@
}
/**
- * Overrides the <code>number-too-small</code> bundle key. Parameter {0} is the display name
- * of the field. Parameter {1} is the minimum allowed value.
+ * Overrides the <code>number-too-small</code> bundle key. Parameter {0}
+ * is the display name of the field. Parameter {1} is the minimum allowed
+ * value.
*
* @since 3.0
*/
@@ -179,18 +182,17 @@
/** @since 3.0 */
protected String buildInvalidNumericFormatMessage(IFormComponent field)
{
- String pattern = getPattern(
- getInvalidNumericFormatMessage(),
- "invalid-numeric-format",
- field.getPage().getLocale());
+ String pattern = getPattern(getInvalidNumericFormatMessage(),
+ "invalid-numeric-format", field.getPage().getLocale());
return formatString(pattern, field.getDisplayName());
}
- protected String buildNumberTooSmallMessage(IFormComponent field, Number minimum)
+ protected String buildNumberTooSmallMessage(IFormComponent field,
+ Number minimum)
{
- String pattern = getPattern(getNumberTooSmallMessage(), "number-too-small", field.getPage()
- .getLocale());
+ String pattern = getPattern(getNumberTooSmallMessage(),
+ "number-too-small", field.getPage().getLocale());
return formatString(pattern, field.getDisplayName(), minimum);
}
@@ -198,42 +200,44 @@
/** @since 3.0 */
protected String buildInvalidIntegerFormatMessage(IFormComponent field)
{
- String pattern = getPattern(getInvalidIntegerFormatMessage(), "invalid-int-format", field
- .getPage().getLocale());
-
+ String pattern = getPattern(getInvalidIntegerFormatMessage(),
+ "invalid-int-format", field.getPage().getLocale());
+
return formatString(pattern, field.getDisplayName());
}
/**
* @since 3.0
*/
- protected String buildNumberTooLargeMessage(IFormComponent field, Number maximum)
+ protected String buildNumberTooLargeMessage(IFormComponent field,
+ Number maximum)
{
- String pattern = getPattern(getNumberTooLargeMessage(), "number-too-large", field.getPage()
- .getLocale());
-
+ String pattern = getPattern(getNumberTooLargeMessage(),
+ "number-too-large", field.getPage().getLocale());
+
return formatString(pattern, field.getDisplayName(), maximum);
}
- protected String buildNumberRangeMessage(IFormComponent field, Number mininum, Number maximum)
+ protected String buildNumberRangeMessage(IFormComponent field,
+ Number mininum, Number maximum)
{
- String pattern = getPattern(getNumberRangeMessage(), "number-range", field.getPage()
- .getLocale());
-
- return formatString(pattern, new Object[]
- { field.getDisplayName(), mininum, maximum });
+ String pattern = getPattern(getNumberRangeMessage(), "number-range",
+ field.getPage().getLocale());
+
+ return formatString(pattern, new Object[] { field.getDisplayName(),
+ mininum, maximum });
}
- protected String buildRangeMessage(IFormComponent field, Number minimum, Number maximum)
+ protected String buildRangeMessage(IFormComponent field, Number minimum,
+ Number maximum)
{
if (minimum != null && maximum != null)
return buildNumberRangeMessage(field, minimum, maximum);
-
- if (maximum != null)
- return buildNumberTooLargeMessage(field, maximum);
-
+
+ if (maximum != null) return buildNumberTooLargeMessage(field, maximum);
+
return buildNumberTooSmallMessage(field, minimum);
}
-
+
protected abstract String getDefaultScriptPath();
-}
\ No newline at end of file
+}
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/IValidationDelegate.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/IValidationDelegate.java?rev=368410&r1=368409&r2=368410&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/IValidationDelegate.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/IValidationDelegate.java Thu Jan 12 09:12:21 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -27,50 +27,57 @@
* {@link IFormComponent form element component}s (including
* {@link org.apache.tapestry.form.AbstractTextField} and its subclasses).
* <p>
- * In addition, controls how fields that are in error are presented (they can be <em>decorated</em>
- * in various ways by the delegate; the default implementation adds two red asterisks to the right
- * of the field).
+ * In addition, controls how fields that are in error are presented (they can be
+ * <em>decorated</em> in various ways by the delegate; the default
+ * implementation adds two red asterisks to the right of the field).
* <p>
- * Each {@link org.apache.tapestry.form.Form} must have its own validation delegate instance.
+ * Each {@link org.apache.tapestry.form.Form} must have its own validation
+ * delegate instance.
* <p>
- * Starting with release 1.0.8, this interface was extensively revised (in a non-backwards
- * compatible way) to move the tracking of errors and invalid values (during a request cycle) to the
- * delegate. It has evolved from a largely stateless conduit for error messages into a very stateful
- * tracker of field state.
+ * Starting with release 1.0.8, this interface was extensively revised (in a
+ * non-backwards compatible way) to move the tracking of errors and invalid
+ * values (during a request cycle) to the delegate. It has evolved from a
+ * largely stateless conduit for error messages into a very stateful tracker of
+ * field state.
* <p>
- * Starting with release 1.0.9, this interface was <em>again</em> reworked, to allow tracking of
- * errors in {@link IFormComponent form components}, and to allow unassociated errors to be
- * tracked. Unassociated errors are "global", they don't apply to any particular field.
+ * Starting with release 1.0.9, this interface was <em>again</em> reworked, to
+ * allow tracking of errors in {@link IFormComponent form components}, and to
+ * allow unassociated errors to be tracked. Unassociated errors are "global",
+ * they don't apply to any particular field.
* <p>
* <b>Fields vs. Form Element Components </b> <br>
- * For most simple forms, these terms are pretty much synonymous. Your form will render normally,
- * and each form element component will render only once. Some of your form components will be
- * {@link ValidField} components and handle most of their validation internally (with the help
- * of {@link IValidator} objects). In addition, your form listener may do additional
- * validation and notify the validation delegate of additional errors, some of which are associated
- * with a particular field, some of which are unassociated with any particular field.
+ * For most simple forms, these terms are pretty much synonymous. Your form will
+ * render normally, and each form element component will render only once. Some
+ * of your form components will be {@link ValidField} components and
+ * handle most of their validation internally (with the help of
+ * {@link IValidator} objects). In addition, your form listener may do
+ * additional validation and notify the validation delegate of additional
+ * errors, some of which are associated with a particular field, some of which
+ * are unassociated with any particular field.
* <p>
* But what happens if you use a {@link org.apache.tapestry.components.Foreach} or
- * {@link org.apache.tapestry.form.ListEdit} inside your form? Some of your components will
- * render multiple times. In this case you will have multiple <em>fields</em>. Each field will
- * have a unique field name (the
- * {@link org.apache.tapestry.form.FormSupport#getElementId(IFormComponent) element id}, which you
- * can see this in the generated HTML). It is this field name that the delegate keys off of, which
- * means that some fields generated by a component may have errors and some may not, it all works
- * fine (with one exception).
+ * {@link org.apache.tapestry.form.ListEdit} inside your form? Some of
+ * your components will render multiple times. In this case you will have
+ * multiple <em>fields</em>. Each field will have a unique field name (the
+ * {@link org.apache.tapestry.form.FormSupport#getElementId(IFormComponent) element id},
+ * which you can see this in the generated HTML). It is this field name that the
+ * delegate keys off of, which means that some fields generated by a component
+ * may have errors and some may not, it all works fine (with one exception).
* <p>
* <b>The Exception </b> <br>
- * The problem is that a component doesn't know its field name until its <code>render()</code>
- * method is invoked (at which point, it allocates a unique field name from the
- * {@link org.apache.tapestry.IForm#getElementId(org.apache.tapestry.form.IFormComponent)}. This is
- * not a problem for the field or its {@link IValidator}, but screws things up for the
- * {@link FieldLabel}.
+ * The problem is that a component doesn't know its field name until its
+ * <code>render()</code> method is invoked (at which point, it allocates a
+ * unique field name from the
+ * {@link org.apache.tapestry.IForm#getElementId(org.apache.tapestry.form.IFormComponent)}.
+ * This is not a problem for the field or its {@link IValidator}, but screws
+ * things up for the {@link FieldLabel}.
* <p>
- * Typically, the label is rendered <em>before</em> the corresponding form component. Form
- * components leave their last assigned field name in their
- * {@link IFormComponent#getName() name property}. So if the form component is in any kind of loop,
- * the {@link FieldLabel}will key its name, {@link IFormComponent#getDisplayName() display name}
- * and error status off of its last renderred value. So the moral of the story is don't use
+ * Typically, the label is rendered <em>before</em> the corresponding form
+ * component. Form components leave their last assigned field name in their
+ * {@link IFormComponent#getName() name property}. So if the form component is
+ * in any kind of loop, the {@link FieldLabel}will key its name,
+ * {@link IFormComponent#getDisplayName() display name} and error status off of
+ * its last renderred value. So the moral of the story is don't use
* {@link FieldLabel}in this situation.
*
* @author Howard Lewis Ship
@@ -78,53 +85,59 @@
public interface IValidationDelegate extends Serializable
{
+
/**
- * Invoked before other methods to configure the delegate for the given form component. Sets the
- * current field based on the {@link IFormComponent#getName() name} of the form component.
+ * Invoked before other methods to configure the delegate for the given form
+ * component. Sets the current field based on the
+ * {@link IFormComponent#getName() name} of the form component.
* <p>
- * The caller should invoke this with a parameter of null to record unassociated global errors
- * (errors not associated with any particular field).
+ * The caller should invoke this with a parameter of null to record
+ * unassociated global errors (errors not associated with any particular
+ * field).
*
* @since 1.0.8
*/
- public void setFormComponent(IFormComponent component);
+ void setFormComponent(IFormComponent component);
/**
- * Returns true if the current field is in error (that is, had bad input submitted by the end
- * user).
+ * Returns true if the current field is in error (that is, had bad input
+ * submitted by the end user).
*
* @since 1.0.8
*/
- public boolean isInError();
+ boolean isInError();
/**
- * Returns the string submitted by the client as the value for the current field.
+ * Returns the string submitted by the client as the value for the current
+ * field.
*
* @since 1.0.8
*/
- public String getFieldInputValue();
+ String getFieldInputValue();
/**
- * Returns a {@link List} of {@link IFieldTracking}, in default order (the order in which
- * fields are renderred). A caller should not change the values (the List is immutable). May
- * return null if no fields are in error.
+ * Returns a {@link List} of {@link IFieldTracking}, in default order (the
+ * order in which fields are renderred). A caller should not change the
+ * values (the List is immutable). May return null if no fields are in
+ * error.
*
* @since 1.0.8
*/
- public List getFieldTracking();
+ List getFieldTracking();
/**
- * Resets any tracking information for the current field. This will clear the field's inError
- * flag, and set its error message and invalid input value to null.
+ * Resets any tracking information for the current field. This will clear
+ * the field's inError flag, and set its error message and invalid input
+ * value to null.
*
* @since 1.0.8
*/
- public void reset();
+ void reset();
/**
* Clears all tracking information.
@@ -132,46 +145,51 @@
* @since 1.0.10
*/
- public void clear();
+ void clear();
/**
- * Clears all errors, but maintains user input. This is useful when a form has been submitted
- * for a semantic other than "process this data". A common example of this is a dependent drop
- * down list; selecting an option in one drop down list forces a refresh submit of the form, to
- * repopulate the options in a second, dependent drop down list.
+ * Clears all errors, but maintains user input. This is useful when a form
+ * has been submitted for a semantic other than "process this data". A
+ * common example of this is a dependent drop down list; selecting an option
+ * in one drop down list forces a refresh submit of the form, to repopulate
+ * the options in a second, dependent drop down list.
* <p>
- * In these cases, the user input provided in the request is maintained, but any errors should
- * be cleared out (to prevent unwanted error messages and decorations).
+ * In these cases, the user input provided in the request is maintained, but
+ * any errors should be cleared out (to prevent unwanted error messages and
+ * decorations).
*
* @since 3.0.1
*/
- public void clearErrors();
+ void clearErrors();
/**
- * Records the user's input for the current form component. Input should be recorded even if
- * there isn't an explicit error, since later form-wide validations may discover an error in the
- * field.
+ * Records the user's input for the current form component. Input should be
+ * recorded even if there isn't an explicit error, since later form-wide
+ * validations may discover an error in the field.
*
* @since 3.0
*/
- public void recordFieldInputValue(String input);
+ void recordFieldInputValue(String input);
/**
- * The error notification method, invoked during the rewind phase (that is, while HTTP
- * parameters are being extracted from the request and assigned to various object properties).
+ * The error notification method, invoked during the rewind phase (that is,
+ * while HTTP parameters are being extracted from the request and assigned
+ * to various object properties).
* <p>
- * Typically, the delegate simply invokes {@link #record(String, ValidationConstraint)}or
- * {@link #record(IRender, ValidationConstraint)}, but special delegates may override this
- * behavior to provide (in some cases) different error messages or more complicated error
- * renderers.
+ * Typically, the delegate simply invokes
+ * {@link #record(String, ValidationConstraint)}or
+ * {@link #record(IRender, ValidationConstraint)}, but special delegates
+ * may override this behavior to provide (in some cases) different error
+ * messages or more complicated error renderers.
*/
- public void record(ValidatorException ex);
+ void record(ValidatorException ex);
/**
- * Records an error in the current field, or an unassociated error if there is no current field.
+ * Records an error in the current field, or an unassociated error if there
+ * is no current field.
*
* @param message
* message to display (@see RenderString}
@@ -180,24 +198,24 @@
* @since 1.0.9
*/
- public void record(String message, ValidationConstraint constraint);
+ void record(String message, ValidationConstraint constraint);
/**
* Convienience for recording a standard string messages against a field.
*
* @param field
- * the field to record the error message against, or null to record an unassociated
- * error
+ * the field to record the error message against, or null to
+ * record an unassociated error
* @param message
* the error message to record
* @since 4.0
*/
- public void record(IFormComponent field, String message);
+ void record(IFormComponent field, String message);
/**
- * Records an error in the current component, or an unassociated error. The maximum flexibility
- * recorder.
+ * Records an error in the current component, or an unassociated error. The
+ * maximum flexibility recorder.
*
* @param errorRenderer
* object that will render the error message (@see RenderString}
@@ -205,11 +223,12 @@
* the constraint that was violated, or null if not known
*/
- public void record(IRender errorRenderer, ValidationConstraint constraint);
+ void record(IRender errorRenderer, ValidationConstraint constraint);
/**
- * Invoked before the field is rendered. If the field is in error, the delegate may decorate the
- * field in some way (to highlight its error state).
+ * Invoked before the field is rendered. If the field is in error, the
+ * delegate may decorate the field in some way (to highlight its error
+ * state).
*
* @param writer
* the writer to which output should be sent
@@ -218,17 +237,17 @@
* @param component
* the component being decorated
* @param validator
- * the validator for the component, or null if the component does have (or doesn't
- * support) a validator
+ * the validator for the component, or null if the component does
+ * have (or doesn't support) a validator
*/
- public void writePrefix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component,
- IValidator validator);
+ void writePrefix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component, IValidator validator);
/**
- * Invoked just before the <input> element is closed. The delegate can write additional
- * attributes. This is often used to set the CSS class of the field so that it can be displayed
- * differently, if in error (or required). *
+ * Invoked just before the <input> element is closed. The delegate can
+ * write additional attributes. This is often used to set the CSS class of
+ * the field so that it can be displayed differently, if in error (or
+ * required). *
*
* @param writer
* the writer to which output should be sent
@@ -237,17 +256,16 @@
* @param component
* the component being decorated
* @param validator
- * the validator for the component, or null if the component does have (or doesn't
- * support) a validator
+ * the validator for the component, or null if the component does
+ * have (or doesn't support) a validator
* @since 1.0.5
*/
- public void writeAttributes(IMarkupWriter writer, IRequestCycle cycle,
- IFormComponent component, IValidator validator);
+ void writeAttributes(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component, IValidator validator);
/**
- * Invoked after the form component is rendered, so that the delegate may decorate the form
- * component (if it is in error). *
+ * Invoked after the form component is rendered, so that the delegate may
+ * decorate the form component (if it is in error). *
*
* @param writer
* the writer to which output should be sent
@@ -256,24 +274,25 @@
* @param component
* the component being decorated
* @param validator
- * the validator for the component, or null if the component does have (or doesn't
- * support) a validator
+ * the validator for the component, or null if the component does
+ * have (or doesn't support) a validator
*/
- public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component,
- IValidator validator);
+ void writeSuffix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component, IValidator validator);
/**
- * Invoked by a {@link FieldLabel} just before writing the name of the form component.
+ * Invoked by a {@link FieldLabel} just before writing the name of the form
+ * component.
*/
- public void writeLabelPrefix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle);
+ void writeLabelPrefix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle);
/**
- * Invoked just before the <label> element is closed. The delegate can write additional
- * attributes. This is often used to set the CSS class of the label so that it can be displayed
- * differently, if in error (or required). Any attributes written here will be overriden by any
- * informal parameters specified in the {@link FieldLabel} implementation.
+ * Invoked just before the <label> element is closed. The delegate can
+ * write additional attributes. This is often used to set the CSS class of
+ * the label so that it can be displayed differently, if in error (or
+ * required). Any attributes written here will be overriden by any informal
+ * parameters specified in the {@link FieldLabel} implementation.
*
* @param writer
* the writer to which output should be sent
@@ -284,53 +303,55 @@
* @since 4.0.1
*/
- public void writeLabelAttributes(IMarkupWriter writer, IRequestCycle cycle,
- IFormComponent component);
-
+ void writeLabelAttributes(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component);
+
/**
- * Invoked by a {@link FieldLabel} just after writing the name of the form component.
+ * Invoked by a {@link FieldLabel} just after writing the name of the form
+ * component.
*/
- public void writeLabelSuffix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle);
+ void writeLabelSuffix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle);
/**
* Returns true if any form component has errors.
*/
- public boolean getHasErrors();
+ boolean getHasErrors();
/**
- * Returns the {@link IFieldTracking} for the current component, if any. Useful when
- * displaying error messages for individual fields.
+ * Returns the {@link IFieldTracking} for the current component, if
+ * any. Useful when displaying error messages for individual fields.
*
* @since 3.0.2
*/
- public IFieldTracking getCurrentFieldTracking();
+ IFieldTracking getCurrentFieldTracking();
/**
- * Returns a list of {@link org.apache.tapestry.IRender} objects, each of which will render an
- * error message for a field tracked by the delegate, plus any unassociated errors (for which no
- * specific field is identified). These objects can be rendered or converted to a string (via
- * toString()).
+ * Returns a list of {@link org.apache.tapestry.IRender} objects, each of
+ * which will render an error message for a field tracked by the delegate,
+ * plus any unassociated errors (for which no specific field is identified).
+ * These objects can be rendered or converted to a string (via toString()).
*
* @return non-empty List of {@link org.apache.tapestry.IRender}.
*/
- public List getErrorRenderers();
+ List getErrorRenderers();
/**
- * Registers a field for automatic focus. The goal is for the first field that is in error to
- * get focus; failing that, the first required field; failing that, any field.
+ * Registers a field for automatic focus. The goal is for the first field
+ * that is in error to get focus; failing that, the first required field;
+ * failing that, any field.
*
* @param field
* the field requesting focus
* @param priority
- * a priority level used to determine whether the registered field becomes the focus
- * field. Constants for this purpose are defined in {@link ValidationConstants}.
+ * a priority level used to determine whether the registered
+ * field becomes the focus field. Constants for this purpose are
+ * defined in {@link ValidationConstants}.
* @since 4.0
*/
- public void registerForFocus(IFormComponent field, int priority);
+ void registerForFocus(IFormComponent field, int priority);
/**
* Returns the field to focus upon, based on prior calls to
@@ -339,6 +360,6 @@
* @return the field name, or null if no field should receive focus.
* @since 4.0
*/
- public String getFocusField();
+ String getFocusField();
-}
\ No newline at end of file
+}
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/NumberValidator.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/NumberValidator.java?rev=368410&r1=368409&r2=368410&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/NumberValidator.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/NumberValidator.java Thu Jan 12 09:12:21 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -29,8 +29,8 @@
import org.apache.tapestry.form.IFormComponent;
/**
- * Simple validation for standard number classes. This is probably insufficient for anything tricky
- * and application specific, such as parsing currency.
+ * Simple validation for standard number classes. This is probably insufficient
+ * for anything tricky and application specific, such as parsing currency.
*
* @author Howard Lewis Ship
* @since 1.0.8
@@ -38,6 +38,7 @@
public class NumberValidator extends AbstractNumericValidator
{
+
private static final Map TYPES = new HashMap();
static
@@ -83,13 +84,15 @@
public final static int NUMBER_TYPE_REAL = 1;
/**
- * This class is not meant for use outside of NumberValidator; it is public only to fascilitate
- * some unit testing.
+ * This class is not meant for use outside of NumberValidator; it is public
+ * only to fascilitate some unit testing.
*/
public static abstract class NumberStrategy
{
+
/**
- * Parses a non-empty {@link String}into the correct subclass of {@link Number}.
+ * Parses a non-empty {@link String}into the correct subclass of
+ * {@link Number}.
*
* @throws NumberFormatException
* if the String can not be parsed.
@@ -98,9 +101,10 @@
abstract public Number parse(String value);
/**
- * Indicates the type of the number represented -- integer or real. The information is used
- * to build the client-side validator. This method could return a boolean, but returns an
- * int to allow future extensions of the validator.
+ * Indicates the type of the number represented -- integer or real. The
+ * information is used to build the client-side validator. This method
+ * could return a boolean, but returns an int to allow future extensions
+ * of the validator.
*
* @return one of the predefined number types
*/
@@ -108,41 +112,46 @@
public int compare(Number left, Number right)
{
- if (!left.getClass().equals(right.getClass()))
- right = coerce(right);
+ if (!left.getClass().equals(right.getClass())) right = coerce(right);
- Comparable lc = (Comparable) left;
+ Comparable lc = (Comparable)left;
return lc.compareTo(right);
}
/**
- * Invoked when comparing two Numbers of different types. The number is cooerced from its
- * ordinary type to the correct type for comparison.
+ * Invoked when comparing two Numbers of different types. The number is
+ * cooerced from its ordinary type to the correct type for comparison.
*
* @since 3.0
*/
protected abstract Number coerce(Number number);
}
+ /** Placeholder comment. */
private static abstract class IntegerNumberAdaptor extends NumberStrategy
{
+
public int getNumberType()
{
return NUMBER_TYPE_INTEGER;
}
}
+ /** Placeholder comment. */
private static abstract class RealNumberAdaptor extends NumberStrategy
{
+
public int getNumberType()
{
return NUMBER_TYPE_REAL;
}
}
+ /** Placeholder comment. */
private static class ByteAdaptor extends IntegerNumberAdaptor
{
+
public Number parse(String value)
{
return new Byte(value);
@@ -154,8 +163,10 @@
}
}
+ /** Placeholder comment. */
private static class ShortAdaptor extends IntegerNumberAdaptor
{
+
public Number parse(String value)
{
return new Short(value);
@@ -167,8 +178,10 @@
}
}
+ /** Placeholder comment. */
private static class IntAdaptor extends IntegerNumberAdaptor
{
+
public Number parse(String value)
{
return new Integer(value);
@@ -180,8 +193,10 @@
}
}
+ /** Placeholder comment. */
private static class LongAdaptor extends IntegerNumberAdaptor
{
+
public Number parse(String value)
{
return new Long(value);
@@ -193,8 +208,10 @@
}
}
+ /** Placeholder comment. */
private static class FloatAdaptor extends RealNumberAdaptor
{
+
public Number parse(String value)
{
return new Float(value);
@@ -206,8 +223,10 @@
}
}
+ /** Placeholder comment. */
private static class DoubleAdaptor extends RealNumberAdaptor
{
+
public Number parse(String value)
{
return new Double(value);
@@ -219,8 +238,10 @@
}
}
+ /** Placeholder comment. */
private static class BigDecimalAdaptor extends RealNumberAdaptor
{
+
public Number parse(String value)
{
return new BigDecimal(value);
@@ -232,8 +253,10 @@
}
}
+ /** Placeholder comment. */
private static class BigIntegerAdaptor extends IntegerNumberAdaptor
{
+
public Number parse(String value)
{
return new BigInteger(value);
@@ -277,7 +300,8 @@
}
/**
- * Initializes the NumberValidator with properties defined by the initializer.
+ * Initializes the NumberValidator with properties defined by the
+ * initializer.
*
* @since 4.0
*/
@@ -289,15 +313,13 @@
public String toString(IFormComponent field, Object value)
{
- if (value == null)
- return null;
+ if (value == null) return null;
if (getZeroIsNull())
{
- Number number = (Number) value;
+ Number number = (Number)value;
- if (number.doubleValue() == 0.0)
- return null;
+ if (number.doubleValue() == 0.0) return null;
}
return value.toString();
@@ -308,9 +330,7 @@
NumberStrategy result = getStrategy(_valueTypeClass);
if (result == null)
- throw new ApplicationRuntimeException(Tapestry.format(
- "NumberValidator.no-adaptor-for-field",
- field,
+ throw new ApplicationRuntimeException(Tapestry.format("NumberValidator.no-adaptor-for-field", field,
_valueTypeClass.getName()));
return result;
@@ -319,8 +339,8 @@
/**
* Returns an strategy for the given type.
* <p>
- * Note: this method exists only for testing purposes. It is not meant to be invoked by user
- * code and is subject to change at any time.
+ * Note: this method exists only for testing purposes. It is not meant to be
+ * invoked by user code and is subject to change at any time.
*
* @param type
* the type (a Number subclass) for which to return an adaptor
@@ -329,13 +349,13 @@
*/
public static NumberStrategy getStrategy(Class type)
{
- return (NumberStrategy) _numberAdaptors.getStrategy(type);
+ return (NumberStrategy)_numberAdaptors.getStrategy(type);
}
- public Object toObject(IFormComponent field, String value) throws ValidatorException
+ public Object toObject(IFormComponent field, String value)
+ throws ValidatorException
{
- if (checkRequired(field, value))
- return null;
+ if (checkRequired(field, value)) return null;
NumberStrategy adaptor = getStrategy(field);
Number result = null;
@@ -346,17 +366,14 @@
}
catch (NumberFormatException ex)
{
- throw new ValidatorException(buildInvalidNumericFormatMessage(field),
- ValidationConstraint.NUMBER_FORMAT);
+ throw new ValidatorException(buildInvalidNumericFormatMessage(field), ValidationConstraint.NUMBER_FORMAT);
}
if (_minimum != null && adaptor.compare(result, _minimum) < 0)
- throw new ValidatorException(buildNumberTooSmallMessage(field, _minimum),
- ValidationConstraint.TOO_SMALL);
+ throw new ValidatorException(buildNumberTooSmallMessage(field, _minimum), ValidationConstraint.TOO_SMALL);
if (_maximum != null && adaptor.compare(result, _maximum) > 0)
- throw new ValidatorException(buildNumberTooLargeMessage(field, _maximum),
- ValidationConstraint.TOO_LARGE);
+ throw new ValidatorException(buildNumberTooLargeMessage(field, _maximum), ValidationConstraint.TOO_LARGE);
return result;
}
@@ -395,24 +412,19 @@
* @since 2.2
*/
- public void renderValidatorContribution(IFormComponent field, IMarkupWriter writer,
- IRequestCycle cycle)
+ public void renderValidatorContribution(IFormComponent field, IMarkupWriter writer, IRequestCycle cycle)
{
- if (!isClientScriptingEnabled())
- return;
+ if (!isClientScriptingEnabled()) return;
- if (!(isRequired() || _minimum != null || _maximum != null))
- return;
+ if (!(isRequired() || _minimum != null || _maximum != null)) return;
Map symbols = new HashMap();
- if (isRequired())
- symbols.put("requiredMessage", buildRequiredMessage(field));
+ if (isRequired()) symbols.put("requiredMessage", buildRequiredMessage(field));
if (isIntegerNumber())
symbols.put("formatMessage", buildInvalidIntegerFormatMessage(field));
- else
- symbols.put("formatMessage", buildInvalidNumericFormatMessage(field));
+ else symbols.put("formatMessage", buildInvalidNumericFormatMessage(field));
if (_minimum != null || _maximum != null)
symbols.put("rangeMessage", buildRangeMessage(field, _minimum, _maximum));
@@ -421,21 +433,19 @@
}
/**
- * Sets the value type from a string type name. The name may be a scalar numeric type, a fully
- * qualified class name, or the name of a numeric wrapper type from java.lang (with the package
- * name omitted).
+ * Sets the value type from a string type name. The name may be a scalar
+ * numeric type, a fully qualified class name, or the name of a numeric
+ * wrapper type from java.lang (with the package name omitted).
*
* @since 3.0
*/
public void setValueType(String typeName)
{
- Class typeClass = (Class) TYPES.get(typeName);
+ Class typeClass = (Class)TYPES.get(typeName);
if (typeClass == null)
- throw new ApplicationRuntimeException(Tapestry.format(
- "NumberValidator.unknown-type",
- typeName));
+ throw new ApplicationRuntimeException(Tapestry.format("NumberValidator.unknown-type", typeName));
_valueTypeClass = typeClass;
}
@@ -462,9 +472,8 @@
public boolean isIntegerNumber()
{
- NumberStrategy strategy = (NumberStrategy) _numberAdaptors.getStrategy(_valueTypeClass);
- if (strategy == null)
- return false;
+ NumberStrategy strategy = (NumberStrategy)_numberAdaptors.getStrategy(_valueTypeClass);
+ if (strategy == null) return false;
return strategy.getNumberType() == NUMBER_TYPE_INTEGER;
}
@@ -473,4 +482,4 @@
{
return "/org/apache/tapestry/valid/NumberValidator.script";
}
-}
\ No newline at end of file
+}
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/UrlValidator.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/UrlValidator.java?rev=368410&r1=368409&r2=368410&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/UrlValidator.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/UrlValidator.java Thu Jan 12 09:12:21 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@
*/
public class UrlValidator extends BaseValidator
{
+
private int _minimumLength;
private String _minimumLengthMessage;
@@ -63,30 +64,24 @@
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),
- ValidationConstraint.MINIMUM_WIDTH);
+ throw new ValidatorException(buildMinimumLengthMessage(field), ValidationConstraint.MINIMUM_WIDTH);
if (!isValidUrl(input))
- throw new ValidatorException(buildInvalidUrlFormatMessage(field),
- ValidationConstraint.URL_FORMAT);
+ throw new ValidatorException(buildInvalidUrlFormatMessage(field), ValidationConstraint.URL_FORMAT);
- if (!isAllowedProtocol(input))
- {
- throw new ValidatorException(buildDisallowedProtocolMessage(field),
- ValidationConstraint.DISALLOWED_PROTOCOL);
- }
+ if (!isAllowedProtocol(input)) { throw new ValidatorException(buildDisallowedProtocolMessage(field),
+ ValidationConstraint.DISALLOWED_PROTOCOL); }
return input;
}
@@ -101,20 +96,16 @@
_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();
- if (isRequired())
- symbols.put("requiredMessage", buildRequiredMessage(field)); //$NON-NLS-1$
+ if (isRequired()) symbols.put("requiredMessage", buildRequiredMessage(field)); //$NON-NLS-1$
- if (_minimumLength > 0)
- symbols.put("minimumLengthMessage", //$NON-NLS-1$
- buildMinimumLengthMessage(field));
+ if (_minimumLength > 0) symbols.put("minimumLengthMessage", //$NON-NLS-1$
+ buildMinimumLengthMessage(field));
symbols.put("urlFormatMessage", buildInvalidUrlFormatMessage(field)); //$NON-NLS-1$
@@ -128,15 +119,12 @@
private String buildUrlRegexpProtocols()
{
- if (_allowedProtocols == null)
- {
- return null;
- }
+ if (_allowedProtocols == null) { return null; }
String regexp = "/("; //$NON-NLS-1$
Iterator iter = _allowedProtocols.iterator();
- while (iter.hasNext())
+ while(iter.hasNext())
{
- String protocol = (String) iter.next();
+ String protocol = (String)iter.next();
regexp += protocol;
if (iter.hasNext())
{
@@ -188,9 +176,9 @@
}
String actualProtocol = oUrl.getProtocol();
Iterator iter = _allowedProtocols.iterator();
- while (iter.hasNext())
+ while(iter.hasNext())
{
- String protocol = (String) iter.next();
+ String protocol = (String)iter.next();
if (protocol.equals(actualProtocol))
{
bIsAllowed = true;
@@ -253,18 +241,15 @@
protected String buildDisallowedProtocolMessage(IFormComponent field)
{
- if (_allowedProtocols == null)
- {
- return null;
- }
+ if (_allowedProtocols == null) { return null; }
String pattern = getPattern(_disallowedProtocolMessage, "disallowed-protocol", //$NON-NLS-1$
field.getPage().getLocale());
String allowedProtocols = ""; //$NON-NLS-1$
Iterator iter = _allowedProtocols.iterator();
- while (iter.hasNext())
+ while(iter.hasNext())
{
- String protocol = (String) iter.next();
+ String protocol = (String)iter.next();
if (!allowedProtocols.equals("")) { //$NON-NLS-1$
if (iter.hasNext())
{
@@ -283,12 +268,9 @@
protected String getPattern(String override, String key, Locale locale)
{
- if (override != null)
- return override;
+ if (override != null) return override;
- ResourceBundle strings = ResourceBundle.getBundle(
- "org.apache.tapestry.valid.ValidationStrings",
- locale);
+ ResourceBundle strings = ResourceBundle.getBundle("org.apache.tapestry.valid.ValidationStrings", locale);
return strings.getString(key);
}
@@ -302,10 +284,10 @@
// String[] aProtocols = protocols.split(","); //$NON-NLS-1$
String[] aProtocols = spliter.splitToArray(protocols); //$NON-NLS-1$
_allowedProtocols = new Vector();
- for (int i = 0; i < aProtocols.length; i++)
+ for(int i = 0; i < aProtocols.length; i++)
{
_allowedProtocols.add(aProtocols[i]);
}
}
-}
\ No newline at end of file
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org