You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/07/03 22:58:48 UTC
svn commit: r673801 - in /myfaces/commons/trunk:
myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/
myfaces-commons-converters/src/test/java/org/apache/myfaces/commons/converter/
myfaces-commons-examples/src/main/java/org/ap...
Author: skitching
Date: Thu Jul 3 13:58:48 2008
New Revision: 673801
URL: http://svn.apache.org/viewvc?rev=673801&view=rev
Log:
Tabs to spaces only
Modified:
myfaces/commons/trunk/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/EnumConverter.java
myfaces/commons/trunk/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/TypedNumberConverter.java
myfaces/commons/trunk/myfaces-commons-converters/src/test/java/org/apache/myfaces/commons/converter/TypedNumberConverterTest.java
myfaces/commons/trunk/myfaces-commons-examples/src/main/java/org/apache/myfaces/examples/validate/ValidateForm.java
myfaces/commons/trunk/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/ExternalContextUtils.java
myfaces/commons/trunk/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/MessageUtils.java
myfaces/commons/trunk/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/RequestType.java
myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCSVValidator.java
myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCompareToValidator.java
myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCreditCardValidator.java
myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractRegExprValidator.java
myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractUrlValidator.java
myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/EmailValidator.java
myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/ISBNValidator.java
Modified: myfaces/commons/trunk/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/EnumConverter.java
URL: http://svn.apache.org/viewvc/myfaces/commons/trunk/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/EnumConverter.java?rev=673801&r1=673800&r2=673801&view=diff
==============================================================================
--- myfaces/commons/trunk/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/EnumConverter.java (original)
+++ myfaces/commons/trunk/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/EnumConverter.java Thu Jul 3 13:58:48 2008
@@ -91,14 +91,14 @@
}
}
- private void checkTargetClass(FacesContext facesContext, UIComponent uiComponent, Object value) {
- if (targetClass == null) {
+ private void checkTargetClass(FacesContext facesContext, UIComponent uiComponent, Object value) {
+ if (targetClass == null) {
Object[] params = new Object[]{value, MessageUtils.getLabel(facesContext, uiComponent)};
throw new ConverterException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,
ENUM_NO_CLASS_ID,
params));
}
- }
+ }
// find the first constant value of the targetClass and return as a String
private String firstConstantOfEnum() {
Modified: myfaces/commons/trunk/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/TypedNumberConverter.java
URL: http://svn.apache.org/viewvc/myfaces/commons/trunk/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/TypedNumberConverter.java?rev=673801&r1=673800&r2=673801&view=diff
==============================================================================
--- myfaces/commons/trunk/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/TypedNumberConverter.java (original)
+++ myfaces/commons/trunk/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/TypedNumberConverter.java Thu Jul 3 13:58:48 2008
@@ -54,63 +54,63 @@
*/
public class TypedNumberConverter implements javax.faces.convert.Converter, StateHolder
{
- public static final String CONVERTER_ID = "org.apache.myfaces.custom.convertNumber.TypedNumberConverter";
+ public static final String CONVERTER_ID = "org.apache.myfaces.custom.convertNumber.TypedNumberConverter";
- private Class destType;
+ private Class destType;
- public TypedNumberConverter()
- {
- }
-
- public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value)
- {
- Object convertedValue = _getAsObject(facesContext, uiComponent, value);
- if (convertedValue == null)
- {
- return null;
- }
-
- Class destType = getDestType();
- if (destType == null)
- {
- ValueExpression valueBinding = uiComponent.getValueExpression("value");
- if (valueBinding != null)
- {
- destType = valueBinding.getType(facesContext.getELContext());
- }
- }
-
- if (destType != null)
- {
- Converter converter = ConvertUtils.lookup(destType);
- if (converter == null)
- {
- throw new UnsupportedOperationException("cant deal with " + destType);
- }
-
- // setting type to null, in fact the documentation is wrong here and this type is never used
- convertedValue = converter.convert(null, convertedValue);
- }
-
-
- return convertedValue;
- }
-
- public void restoreState(FacesContext facesContext, Object state)
- {
- Object[] states = (Object[]) state;
- _restoreState(facesContext, states[0]);
- destType = (Class) states[1];
- }
-
- public Object saveState(FacesContext facesContext)
- {
- return new Object[]
- {
- _saveState(facesContext),
- destType
- };
- }
+ public TypedNumberConverter()
+ {
+ }
+
+ public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value)
+ {
+ Object convertedValue = _getAsObject(facesContext, uiComponent, value);
+ if (convertedValue == null)
+ {
+ return null;
+ }
+
+ Class destType = getDestType();
+ if (destType == null)
+ {
+ ValueExpression valueBinding = uiComponent.getValueExpression("value");
+ if (valueBinding != null)
+ {
+ destType = valueBinding.getType(facesContext.getELContext());
+ }
+ }
+
+ if (destType != null)
+ {
+ Converter converter = ConvertUtils.lookup(destType);
+ if (converter == null)
+ {
+ throw new UnsupportedOperationException("cant deal with " + destType);
+ }
+
+ // setting type to null, in fact the documentation is wrong here and this type is never used
+ convertedValue = converter.convert(null, convertedValue);
+ }
+
+
+ return convertedValue;
+ }
+
+ public void restoreState(FacesContext facesContext, Object state)
+ {
+ Object[] states = (Object[]) state;
+ _restoreState(facesContext, states[0]);
+ destType = (Class) states[1];
+ }
+
+ public Object saveState(FacesContext facesContext)
+ {
+ return new Object[]
+ {
+ _saveState(facesContext),
+ destType
+ };
+ }
/**
* The java class name the value should be converted to.
@@ -119,18 +119,18 @@
*
* @JSFProperty
*/
- public Class getDestType()
- {
- return destType;
- }
-
- public void setDestType(Class destType)
- {
- this.destType = destType;
- }
+ public Class getDestType()
+ {
+ return destType;
+ }
- /* ORIGINAL STUFF COPIED FROM javax.faces.convert.NumberConverter */
-
+ public void setDestType(Class destType)
+ {
+ this.destType = destType;
+ }
+
+ /* ORIGINAL STUFF COPIED FROM javax.faces.convert.NumberConverter */
+
// internal constants
private static final String CONVERSION_MESSAGE_ID = "javax.faces.convert.NumberConverter.CONVERSION";
@@ -180,9 +180,9 @@
}
catch (ParseException e)
{
- FacesMessage message = MessageUtils.getMessage(facesContext, CONVERSION_MESSAGE_ID, new Object[]{uiComponent.getId(),value});
- message.setSeverity(FacesMessage.SEVERITY_ERROR);
-
+ FacesMessage message = MessageUtils.getMessage(facesContext, CONVERSION_MESSAGE_ID, new Object[]{uiComponent.getId(),value});
+ message.setSeverity(FacesMessage.SEVERITY_ERROR);
+
throw new ConverterException(message, e);
}
}
Modified: myfaces/commons/trunk/myfaces-commons-converters/src/test/java/org/apache/myfaces/commons/converter/TypedNumberConverterTest.java
URL: http://svn.apache.org/viewvc/myfaces/commons/trunk/myfaces-commons-converters/src/test/java/org/apache/myfaces/commons/converter/TypedNumberConverterTest.java?rev=673801&r1=673800&r2=673801&view=diff
==============================================================================
--- myfaces/commons/trunk/myfaces-commons-converters/src/test/java/org/apache/myfaces/commons/converter/TypedNumberConverterTest.java (original)
+++ myfaces/commons/trunk/myfaces-commons-converters/src/test/java/org/apache/myfaces/commons/converter/TypedNumberConverterTest.java Thu Jul 3 13:58:48 2008
@@ -32,41 +32,41 @@
* @version $Revision$ $Date$
*/
public class TypedNumberConverterTest extends AbstractJsfTestCase{
-
- private TypedNumberConverter converter;
-
- public TypedNumberConverterTest(String testName) {
- super(testName);
- }
-
- public void setUp() throws Exception{
- super.setUp();
- converter = new TypedNumberConverter();
- }
-
- public void tearDown() throws Exception{
- super.tearDown();
- converter = null;
- }
-
- public static Test suite() {
- return new TestSuite(TypedNumberConverterTest.class);
- }
-
- public void testSeverityLevelOfMessageShouldBeErrorInCaseConversionFails() {
- UIInput input = new UIInput();
- input.setId("txt_test");
-
- converter.setIntegerOnly(true);
-
- try {
- converter.getAsObject(facesContext, input, "test_invalid_input");
-
- fail();
- }catch (ConverterException exception) {
- FacesMessage facesMessage = exception.getFacesMessage();
- assertEquals(FacesMessage.SEVERITY_ERROR, facesMessage.getSeverity());
- }
-
- }
+
+ private TypedNumberConverter converter;
+
+ public TypedNumberConverterTest(String testName) {
+ super(testName);
+ }
+
+ public void setUp() throws Exception{
+ super.setUp();
+ converter = new TypedNumberConverter();
+ }
+
+ public void tearDown() throws Exception{
+ super.tearDown();
+ converter = null;
+ }
+
+ public static Test suite() {
+ return new TestSuite(TypedNumberConverterTest.class);
+ }
+
+ public void testSeverityLevelOfMessageShouldBeErrorInCaseConversionFails() {
+ UIInput input = new UIInput();
+ input.setId("txt_test");
+
+ converter.setIntegerOnly(true);
+
+ try {
+ converter.getAsObject(facesContext, input, "test_invalid_input");
+
+ fail();
+ }catch (ConverterException exception) {
+ FacesMessage facesMessage = exception.getFacesMessage();
+ assertEquals(FacesMessage.SEVERITY_ERROR, facesMessage.getSeverity());
+ }
+
+ }
}
Modified: myfaces/commons/trunk/myfaces-commons-examples/src/main/java/org/apache/myfaces/examples/validate/ValidateForm.java
URL: http://svn.apache.org/viewvc/myfaces/commons/trunk/myfaces-commons-examples/src/main/java/org/apache/myfaces/examples/validate/ValidateForm.java?rev=673801&r1=673800&r2=673801&view=diff
==============================================================================
--- myfaces/commons/trunk/myfaces-commons-examples/src/main/java/org/apache/myfaces/examples/validate/ValidateForm.java (original)
+++ myfaces/commons/trunk/myfaces-commons-examples/src/main/java/org/apache/myfaces/examples/validate/ValidateForm.java Thu Jul 3 13:58:48 2008
@@ -24,93 +24,93 @@
*/
public class ValidateForm {
- private String email = null;
- private String email2 = null;
- private String creditCardNumber = null;
- private String url = null;
- private String regExpr = null;
-
- private String equal = null;
- private String equal2 = null;
-
- private String isbn =null;
-
-
- public String getEmail() {
- return email;
- }
-
- public void setEmail(String string) {
- email = string;
- }
-
- public String submit(){
- System.out.println("Action was called.");
- return ("valid");
- }
-
- public String getCreditCardNumber() {
- return creditCardNumber;
- }
- public String getUrl(){
- return url;
- }
- public void setCreditCardNumber(String string) {
- creditCardNumber = string;
- }
- public void setUrl(String string) {
- url = string;
- }
-
- public String getEmail2() {
- return email2;
- }
-
- public void setEmail2(String string) {
- email2 = string;
- }
-
- /**
- * @return
- */
- public String getRegExpr() {
- return regExpr;
- }
-
- /**
- * @param string
- */
- public void setRegExpr(String string) {
- regExpr = string;
- }
-
- /**
- * @return
- */
- public String getEqual2() {
- return equal2;
- }
-
- /**
- * @param string
- */
- public void setEqual2(String string) {
- equal2 = string;
- }
-
- /**
- * @return
- */
- public String getEqual() {
- return equal;
- }
-
- /**
- * @param string
- */
- public void setEqual(String string) {
- equal = string;
- }
+ private String email = null;
+ private String email2 = null;
+ private String creditCardNumber = null;
+ private String url = null;
+ private String regExpr = null;
+
+ private String equal = null;
+ private String equal2 = null;
+
+ private String isbn =null;
+
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String string) {
+ email = string;
+ }
+
+ public String submit(){
+ System.out.println("Action was called.");
+ return ("valid");
+ }
+
+ public String getCreditCardNumber() {
+ return creditCardNumber;
+ }
+ public String getUrl(){
+ return url;
+ }
+ public void setCreditCardNumber(String string) {
+ creditCardNumber = string;
+ }
+ public void setUrl(String string) {
+ url = string;
+ }
+
+ public String getEmail2() {
+ return email2;
+ }
+
+ public void setEmail2(String string) {
+ email2 = string;
+ }
+
+ /**
+ * @return
+ */
+ public String getRegExpr() {
+ return regExpr;
+ }
+
+ /**
+ * @param string
+ */
+ public void setRegExpr(String string) {
+ regExpr = string;
+ }
+
+ /**
+ * @return
+ */
+ public String getEqual2() {
+ return equal2;
+ }
+
+ /**
+ * @param string
+ */
+ public void setEqual2(String string) {
+ equal2 = string;
+ }
+
+ /**
+ * @return
+ */
+ public String getEqual() {
+ return equal;
+ }
+
+ /**
+ * @param string
+ */
+ public void setEqual(String string) {
+ equal = string;
+ }
public String getIsbn() {
return isbn;
Modified: myfaces/commons/trunk/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/ExternalContextUtils.java
URL: http://svn.apache.org/viewvc/myfaces/commons/trunk/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/ExternalContextUtils.java?rev=673801&r1=673800&r2=673801&view=diff
==============================================================================
--- myfaces/commons/trunk/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/ExternalContextUtils.java (original)
+++ myfaces/commons/trunk/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/ExternalContextUtils.java Thu Jul 3 13:58:48 2008
@@ -37,156 +37,156 @@
*/
public final class ExternalContextUtils
{
- // prevent this from being instantiated
- private ExternalContextUtils()
- {
- }
-
- /**
- * Returns the content length or -1 if the unknown.
- *
- * @param externalContext
- * the ExternalContext
- * @return the length or -1
- */
- public static final int getContentLength(ExternalContext externalContext)
- {
- RequestType type = getRequestType(externalContext);
-
- if(type.isRequestFromClient())
- {
- try
- {
- Object request = externalContext.getRequest();
- Method contentLenMethod = request.getClass().getMethod("getContentLength");
- return (Integer) contentLenMethod.invoke(request); //this will autobox
- }
- catch(Exception e)
- {
- _LOG.error("Unsupported request type.", e);
- }
- }
-
- return -1;
- }
-
- /**
- * Returns the request input stream if one is available
- *
- * @param externalContext
- * @return
- * @throws IOException
- */
- public static final InputStream getRequestInputStream(ExternalContext externalContext)
- throws IOException
- {
- RequestType type = getRequestType(externalContext);
-
- if(type.isRequestFromClient())
- {
- try
- {
- Object request = externalContext.getRequest();
-
- Method method = request.getClass().getMethod(type.isPortlet()?"getPortletInputStream":"getInputStream");
- return (InputStream) method.invoke(request);
- }
- catch (Exception e)
- {
- _LOG.error("Unable to get the request input stream because of an error", e);
- }
- }
- return null;
- }
-
- /**
- * Returns the requestType of this ExternalContext.
- *
- * @param externalContext the current external context
- * @return the appropriate RequestType for this external context
- * @see RequestType
- */
- public static final RequestType getRequestType(ExternalContext externalContext)
- {
- //Stuff is laid out strangely in this class in order to optimize
- //performance. We want to do as few instanceof's as possible so
- //things are laid out according to the expected frequency of the
- //various requests occurring.
- if(_PORTLET_CONTEXT_CLASS != null)
- {
- if (_PORTLET_CONTEXT_CLASS.isInstance(externalContext.getContext()))
- {
- //We are inside of a portlet container
- Object request = externalContext.getRequest();
-
- if(_PORTLET_RENDER_REQUEST_CLASS.isInstance(request))
- {
- return RequestType.RENDER;
- }
-
- if(_PORTLET_RESOURCE_REQUEST_CLASS != null)
- {
- if(_PORTLET_ACTION_REQUEST_CLASS.isInstance(request))
- {
- return RequestType.ACTION;
- }
-
- //We are in a JSR-286 container
- if(_PORTLET_RESOURCE_REQUEST_CLASS.isInstance(request))
- {
- return RequestType.RESOURCE;
- }
-
- return RequestType.EVENT;
- }
-
- return RequestType.ACTION;
- }
- }
-
- return RequestType.SERVLET;
- }
+ // prevent this from being instantiated
+ private ExternalContextUtils()
+ {
+ }
+
+ /**
+ * Returns the content length or -1 if the unknown.
+ *
+ * @param externalContext
+ * the ExternalContext
+ * @return the length or -1
+ */
+ public static final int getContentLength(ExternalContext externalContext)
+ {
+ RequestType type = getRequestType(externalContext);
+
+ if(type.isRequestFromClient())
+ {
+ try
+ {
+ Object request = externalContext.getRequest();
+ Method contentLenMethod = request.getClass().getMethod("getContentLength");
+ return (Integer) contentLenMethod.invoke(request); //this will autobox
+ }
+ catch(Exception e)
+ {
+ _LOG.error("Unsupported request type.", e);
+ }
+ }
+
+ return -1;
+ }
+
+ /**
+ * Returns the request input stream if one is available
+ *
+ * @param externalContext
+ * @return
+ * @throws IOException
+ */
+ public static final InputStream getRequestInputStream(ExternalContext externalContext)
+ throws IOException
+ {
+ RequestType type = getRequestType(externalContext);
+
+ if(type.isRequestFromClient())
+ {
+ try
+ {
+ Object request = externalContext.getRequest();
+
+ Method method = request.getClass().getMethod(type.isPortlet()?"getPortletInputStream":"getInputStream");
+ return (InputStream) method.invoke(request);
+ }
+ catch (Exception e)
+ {
+ _LOG.error("Unable to get the request input stream because of an error", e);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the requestType of this ExternalContext.
+ *
+ * @param externalContext the current external context
+ * @return the appropriate RequestType for this external context
+ * @see RequestType
+ */
+ public static final RequestType getRequestType(ExternalContext externalContext)
+ {
+ //Stuff is laid out strangely in this class in order to optimize
+ //performance. We want to do as few instanceof's as possible so
+ //things are laid out according to the expected frequency of the
+ //various requests occurring.
+ if(_PORTLET_CONTEXT_CLASS != null)
+ {
+ if (_PORTLET_CONTEXT_CLASS.isInstance(externalContext.getContext()))
+ {
+ //We are inside of a portlet container
+ Object request = externalContext.getRequest();
+
+ if(_PORTLET_RENDER_REQUEST_CLASS.isInstance(request))
+ {
+ return RequestType.RENDER;
+ }
+
+ if(_PORTLET_RESOURCE_REQUEST_CLASS != null)
+ {
+ if(_PORTLET_ACTION_REQUEST_CLASS.isInstance(request))
+ {
+ return RequestType.ACTION;
+ }
+
+ //We are in a JSR-286 container
+ if(_PORTLET_RESOURCE_REQUEST_CLASS.isInstance(request))
+ {
+ return RequestType.RESOURCE;
+ }
+
+ return RequestType.EVENT;
+ }
+
+ return RequestType.ACTION;
+ }
+ }
+
+ return RequestType.SERVLET;
+ }
private static final Log _LOG = LogFactory.getLog(TagUtils.class);
- private static final Class<?> _PORTLET_ACTION_REQUEST_CLASS;
- private static final Class<?> _PORTLET_RENDER_REQUEST_CLASS;
- private static final Class<?> _PORTLET_RESOURCE_REQUEST_CLASS; //Will be present in JSR-286 containers only
- private static final Class<?> _PORTLET_CONTEXT_CLASS;
-
- static
- {
- Class<?> context;
- Class<?> actionRequest;
- Class<?> renderRequest;
- Class<?> resourceRequest;
- try
- {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- context = loader.loadClass("javax.portlet.PortletContext");
- actionRequest = loader.loadClass("javax.portlet.ActionRequest");
- renderRequest = loader.loadClass("javax.portlet.RenderRequest");
-
- try
- {
- resourceRequest = loader.loadClass("javax.portlet.ResourceRequest");
- }
- catch (ClassNotFoundException e)
- {
- resourceRequest = null;
- }
- }
- catch (ClassNotFoundException e)
- {
- context = null;
- actionRequest = null;
- renderRequest = null;
- resourceRequest = null;
- }
-
- _PORTLET_CONTEXT_CLASS = context;
- _PORTLET_ACTION_REQUEST_CLASS = actionRequest;
- _PORTLET_RENDER_REQUEST_CLASS = renderRequest;
- _PORTLET_RESOURCE_REQUEST_CLASS = resourceRequest;
- }
+ private static final Class<?> _PORTLET_ACTION_REQUEST_CLASS;
+ private static final Class<?> _PORTLET_RENDER_REQUEST_CLASS;
+ private static final Class<?> _PORTLET_RESOURCE_REQUEST_CLASS; //Will be present in JSR-286 containers only
+ private static final Class<?> _PORTLET_CONTEXT_CLASS;
+
+ static
+ {
+ Class<?> context;
+ Class<?> actionRequest;
+ Class<?> renderRequest;
+ Class<?> resourceRequest;
+ try
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ context = loader.loadClass("javax.portlet.PortletContext");
+ actionRequest = loader.loadClass("javax.portlet.ActionRequest");
+ renderRequest = loader.loadClass("javax.portlet.RenderRequest");
+
+ try
+ {
+ resourceRequest = loader.loadClass("javax.portlet.ResourceRequest");
+ }
+ catch (ClassNotFoundException e)
+ {
+ resourceRequest = null;
+ }
+ }
+ catch (ClassNotFoundException e)
+ {
+ context = null;
+ actionRequest = null;
+ renderRequest = null;
+ resourceRequest = null;
+ }
+
+ _PORTLET_CONTEXT_CLASS = context;
+ _PORTLET_ACTION_REQUEST_CLASS = actionRequest;
+ _PORTLET_RENDER_REQUEST_CLASS = renderRequest;
+ _PORTLET_RESOURCE_REQUEST_CLASS = resourceRequest;
+ }
}
Modified: myfaces/commons/trunk/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/MessageUtils.java
URL: http://svn.apache.org/viewvc/myfaces/commons/trunk/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/MessageUtils.java?rev=673801&r1=673800&r2=673801&view=diff
==============================================================================
--- myfaces/commons/trunk/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/MessageUtils.java (original)
+++ myfaces/commons/trunk/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/MessageUtils.java Thu Jul 3 13:58:48 2008
@@ -51,10 +51,10 @@
public final class MessageUtils
{
/** Utility class, do not instatiate */
- private MessageUtils()
- {
- // nope
- }
+ private MessageUtils()
+ {
+ // nope
+ }
/** Default bundle for messages (<code>org.apache.myfaces.commons.Messages</code>) */
private static final String DEFAULT_BUNDLE = "org.apache.myfaces.commons.Messages";//javax.faces.Messages
Modified: myfaces/commons/trunk/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/RequestType.java
URL: http://svn.apache.org/viewvc/myfaces/commons/trunk/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/RequestType.java?rev=673801&r1=673800&r2=673801&view=diff
==============================================================================
--- myfaces/commons/trunk/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/RequestType.java (original)
+++ myfaces/commons/trunk/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/RequestType.java Thu Jul 3 13:58:48 2008
@@ -27,100 +27,100 @@
*/
public enum RequestType
{
- /**
- * The type for all servlet requests. SERVLET request types are
- * both client requests and response writable.
- */
- SERVLET(true, true, false),
-
- /**
- * The type for a portlet RenderRequest. RENDER request types are
- * for portlets and are response writable but are NOT client
- * requests.
- */
- RENDER(false, true, true),
-
- /**
- * The type for a portlet ActionRequest. ACTION request types are
- * for portlets and are client requests but are NOT response
- * writable.
- */
- ACTION(true, false, true),
-
- /**
- * The type for a portlet ResourceRequest. RESOURCE request types
- * are for portlets and are both client requests and response
- * writable. RESOURCE request types will only be returned in a
- * Portlet 2.0 portlet container.
- */
- RESOURCE(true, true, true),
-
- /**
- * The type for a portlet EventRequest. EVENT request types
- * are for portlets and are neither client requests nor response
- * writable. EVENT request types will only be returned in a
- * Portlet 2.0 portlet container.
- */
- EVENT(false, false, true);
-
- private boolean _client;
- private boolean _writable;
- private boolean _portlet;
-
- RequestType(boolean client, boolean writable, boolean portlet)
- {
- _client = client;
- _writable = writable;
- _portlet = portlet;
- }
-
- /**
- * Returns <code>true</code> if this request was a direct
- * result of a call from the client. This implies that
- * the current application is the "owner" of the current
- * request and that it has access to the inputStream, can
- * get and set character encodings, etc. Currently all
- * SERVLET, ACTION, and RESOURCE RequestTypes are client
- * requests.
- *
- * @return <code>true</code> if the current request is a
- * client data type request and <code>false</code>
- * if it is not.
- */
- public boolean isRequestFromClient()
- {
- return _client;
- }
-
- /**
- * Returns <code>true</code> if the response for this
- * RequestType is intended to produce output to the client.
- * Currently the SERVLET, RENDER, and RESOURCE request are
- * response writable.
- *
- * @return <code>true</code> if the current request is
- * intended to produce output and <code>false</code>
- * if it is not.
- */
- public boolean isResponseWritable()
- {
- return _writable;
- }
-
- /**
- * Returns <code>true</code> if the response for this
- * RequestType originated from a JSR-168 or JSR-286
- * portlet container. Currently RENDER, ACTION,
- * RESOURCE, and EVENT RequestTypes are all portlet
- * requests.
- *
- * @return <code>true</code> if the current request
- * originated inside of a JSR-168 or JSR-286
- * Portlet Container or <code>false</code> if
- * it did not.
- */
- public boolean isPortlet()
- {
- return _portlet;
- }
+ /**
+ * The type for all servlet requests. SERVLET request types are
+ * both client requests and response writable.
+ */
+ SERVLET(true, true, false),
+
+ /**
+ * The type for a portlet RenderRequest. RENDER request types are
+ * for portlets and are response writable but are NOT client
+ * requests.
+ */
+ RENDER(false, true, true),
+
+ /**
+ * The type for a portlet ActionRequest. ACTION request types are
+ * for portlets and are client requests but are NOT response
+ * writable.
+ */
+ ACTION(true, false, true),
+
+ /**
+ * The type for a portlet ResourceRequest. RESOURCE request types
+ * are for portlets and are both client requests and response
+ * writable. RESOURCE request types will only be returned in a
+ * Portlet 2.0 portlet container.
+ */
+ RESOURCE(true, true, true),
+
+ /**
+ * The type for a portlet EventRequest. EVENT request types
+ * are for portlets and are neither client requests nor response
+ * writable. EVENT request types will only be returned in a
+ * Portlet 2.0 portlet container.
+ */
+ EVENT(false, false, true);
+
+ private boolean _client;
+ private boolean _writable;
+ private boolean _portlet;
+
+ RequestType(boolean client, boolean writable, boolean portlet)
+ {
+ _client = client;
+ _writable = writable;
+ _portlet = portlet;
+ }
+
+ /**
+ * Returns <code>true</code> if this request was a direct
+ * result of a call from the client. This implies that
+ * the current application is the "owner" of the current
+ * request and that it has access to the inputStream, can
+ * get and set character encodings, etc. Currently all
+ * SERVLET, ACTION, and RESOURCE RequestTypes are client
+ * requests.
+ *
+ * @return <code>true</code> if the current request is a
+ * client data type request and <code>false</code>
+ * if it is not.
+ */
+ public boolean isRequestFromClient()
+ {
+ return _client;
+ }
+
+ /**
+ * Returns <code>true</code> if the response for this
+ * RequestType is intended to produce output to the client.
+ * Currently the SERVLET, RENDER, and RESOURCE request are
+ * response writable.
+ *
+ * @return <code>true</code> if the current request is
+ * intended to produce output and <code>false</code>
+ * if it is not.
+ */
+ public boolean isResponseWritable()
+ {
+ return _writable;
+ }
+
+ /**
+ * Returns <code>true</code> if the response for this
+ * RequestType originated from a JSR-168 or JSR-286
+ * portlet container. Currently RENDER, ACTION,
+ * RESOURCE, and EVENT RequestTypes are all portlet
+ * requests.
+ *
+ * @return <code>true</code> if the current request
+ * originated inside of a JSR-168 or JSR-286
+ * Portlet Container or <code>false</code> if
+ * it did not.
+ */
+ public boolean isPortlet()
+ {
+ return _portlet;
+ }
}
\ No newline at end of file
Modified: myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCSVValidator.java
URL: http://svn.apache.org/viewvc/myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCSVValidator.java?rev=673801&r1=673800&r2=673801&view=diff
==============================================================================
--- myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCSVValidator.java (original)
+++ myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCSVValidator.java Thu Jul 3 13:58:48 2008
@@ -42,120 +42,120 @@
* @version $Revision$ $Date$
*/
public abstract class AbstractCSVValidator extends ValidatorBase {
- /**
- * <p>The standard converter id for this converter.</p>
- */
- public static final String VALIDATOR_ID = "org.apache.myfaces.commons.validator.csv";
- /**
- * <p>The message identifiers of the {@link FacesMessage} to be created if
- * the check fails.</p>
- */
- public static final String CSV_NOT_STRING_MESSAGE_ID = "org.apache.myfaces.commons.validator.csv.NOT_STRING";
- public static final String CSV_INVALID_SEPARATOR_MESSAGE_ID = "org.apache.myfaces.commons.validator.csv.INVALID_SEPARATOR";
- public static final String CSV_SUFFIX_MESSAGE_ID = "org.apache.myfaces.commons.validator.csv.SUFFIX";
- private static final String DEFAULT_SEPARATOR = ",";
-
- /**
- * @JSFProperty
- * @return the VALIDATOR_ID of the actual validator to be used
- */
+ /**
+ * <p>The standard converter id for this converter.</p>
+ */
+ public static final String VALIDATOR_ID = "org.apache.myfaces.commons.validator.csv";
+ /**
+ * <p>The message identifiers of the {@link FacesMessage} to be created if
+ * the check fails.</p>
+ */
+ public static final String CSV_NOT_STRING_MESSAGE_ID = "org.apache.myfaces.commons.validator.csv.NOT_STRING";
+ public static final String CSV_INVALID_SEPARATOR_MESSAGE_ID = "org.apache.myfaces.commons.validator.csv.INVALID_SEPARATOR";
+ public static final String CSV_SUFFIX_MESSAGE_ID = "org.apache.myfaces.commons.validator.csv.SUFFIX";
+ private static final String DEFAULT_SEPARATOR = ",";
+
+ /**
+ * @JSFProperty
+ * @return the VALIDATOR_ID of the actual validator to be used
+ */
public abstract String getSubvalidatorId();
- /**
- * @param the VALIDATOR_ID of the actual validator to be used
- */
- public abstract void setSubvalidatorId(String subvalidatorId);
-
- /**
- * @JSFProperty
- * literalOnly = "true"
- * @return the separator character to separate values
- */
- public abstract String getSeparator();
-
- /**
- * @param the separator character to separate values
- */
- public abstract void setSeparator(String separator);
-
- private FacesMessage addMessage(FacesMessage oldMsg, FacesMessage newMsg, int index, String suffixMessageKey) {
- if (oldMsg != null && newMsg.getSeverity().getOrdinal() < oldMsg.getSeverity().getOrdinal())
- return oldMsg;
- String summaryMessageText = null;
- String detailMessageText = null;
- if (oldMsg == null || newMsg.getSeverity().getOrdinal() > oldMsg.getSeverity().getOrdinal()) {
- summaryMessageText = null;
- detailMessageText = null;
- }
- else {
- summaryMessageText = oldMsg.getSummary();
- detailMessageText = oldMsg.getDetail();
- }
- Object[] args = { new Integer(index + 1) };
- FacesMessage suffixMessage = MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, suffixMessageKey, args);
- String summarySuffix = suffixMessage.getSummary();
- String detailSuffix = suffixMessage.getDetail();
- if (summarySuffix == null)
- summarySuffix = detailSuffix;
- else if (detailSuffix == null)
- detailSuffix = summarySuffix;
- String summary = newMsg.getSummary();
- if (summaryMessageText == null)
- summaryMessageText = summary + summarySuffix;
- else
- summaryMessageText += ", " + summary + summarySuffix;
- String detail = newMsg.getDetail();
- if (detailMessageText == null)
- detailMessageText = detail + detailSuffix;
- else
- detailMessageText += ", " + detail + detailSuffix;
- return new FacesMessage(newMsg.getSeverity(), summaryMessageText, detailMessageText);
- }
+ /**
+ * @param the VALIDATOR_ID of the actual validator to be used
+ */
+ public abstract void setSubvalidatorId(String subvalidatorId);
+
+ /**
+ * @JSFProperty
+ * literalOnly = "true"
+ * @return the separator character to separate values
+ */
+ public abstract String getSeparator();
+
+ /**
+ * @param the separator character to separate values
+ */
+ public abstract void setSeparator(String separator);
+
+ private FacesMessage addMessage(FacesMessage oldMsg, FacesMessage newMsg, int index, String suffixMessageKey) {
+ if (oldMsg != null && newMsg.getSeverity().getOrdinal() < oldMsg.getSeverity().getOrdinal())
+ return oldMsg;
+ String summaryMessageText = null;
+ String detailMessageText = null;
+ if (oldMsg == null || newMsg.getSeverity().getOrdinal() > oldMsg.getSeverity().getOrdinal()) {
+ summaryMessageText = null;
+ detailMessageText = null;
+ }
+ else {
+ summaryMessageText = oldMsg.getSummary();
+ detailMessageText = oldMsg.getDetail();
+ }
+ Object[] args = { new Integer(index + 1) };
+ FacesMessage suffixMessage = MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, suffixMessageKey, args);
+ String summarySuffix = suffixMessage.getSummary();
+ String detailSuffix = suffixMessage.getDetail();
+ if (summarySuffix == null)
+ summarySuffix = detailSuffix;
+ else if (detailSuffix == null)
+ detailSuffix = summarySuffix;
+ String summary = newMsg.getSummary();
+ if (summaryMessageText == null)
+ summaryMessageText = summary + summarySuffix;
+ else
+ summaryMessageText += ", " + summary + summarySuffix;
+ String detail = newMsg.getDetail();
+ if (detailMessageText == null)
+ detailMessageText = detail + detailSuffix;
+ else
+ detailMessageText += ", " + detail + detailSuffix;
+ return new FacesMessage(newMsg.getSeverity(), summaryMessageText, detailMessageText);
+ }
- public void validate(FacesContext facesContext, UIComponent uiComponent, Object value) throws ValidatorException {
+ public void validate(FacesContext facesContext, UIComponent uiComponent, Object value) throws ValidatorException {
- if (facesContext == null) throw new NullPointerException("facesContext");
+ if (facesContext == null) throw new NullPointerException("facesContext");
if (uiComponent == null) throw new NullPointerException("uiComponent");
- if (value == null)
- {
- return;
- }
-
- String suffixMessageKey = getMessage();
- if (suffixMessageKey == null)
- suffixMessageKey = CSV_SUFFIX_MESSAGE_ID;
- FacesMessage facesMsg = null;
- // value must be a String
- if (!(value instanceof String)) {
- Object[] args = { value };
+ if (value == null)
+ {
+ return;
+ }
+
+ String suffixMessageKey = getMessage();
+ if (suffixMessageKey == null)
+ suffixMessageKey = CSV_SUFFIX_MESSAGE_ID;
+ FacesMessage facesMsg = null;
+ // value must be a String
+ if (!(value instanceof String)) {
+ Object[] args = { value };
throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, CSV_NOT_STRING_MESSAGE_ID, args));
- }
- Validator validator = facesContext.getApplication().createValidator(getSubvalidatorId());
- if (getSeparator() == null)
- setSeparator(DEFAULT_SEPARATOR);
- String[] values = null;
- try {
- values = ((String)value).split(getSeparator());
- }
- catch (PatternSyntaxException e) {
- Object[] args = { getSeparator() };
+ }
+ Validator validator = facesContext.getApplication().createValidator(getSubvalidatorId());
+ if (getSeparator() == null)
+ setSeparator(DEFAULT_SEPARATOR);
+ String[] values = null;
+ try {
+ values = ((String)value).split(getSeparator());
+ }
+ catch (PatternSyntaxException e) {
+ Object[] args = { getSeparator() };
throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, CSV_INVALID_SEPARATOR_MESSAGE_ID, args));
- }
-
- // loop through the separated values and validate each one
- for (int i = 0; i < values.length; i++) {
- if (values[i].trim().length() == 0) {
- continue;
- }
- else try {
- validator.validate(facesContext, uiComponent, values[i]);
- }
- catch (ValidatorException e) {
- facesMsg = addMessage(facesMsg, e.getFacesMessage(), i, suffixMessageKey);
- }
- }
- if (facesMsg != null)
- throw new ValidatorException(facesMsg);
- }
+ }
+
+ // loop through the separated values and validate each one
+ for (int i = 0; i < values.length; i++) {
+ if (values[i].trim().length() == 0) {
+ continue;
+ }
+ else try {
+ validator.validate(facesContext, uiComponent, values[i]);
+ }
+ catch (ValidatorException e) {
+ facesMsg = addMessage(facesMsg, e.getFacesMessage(), i, suffixMessageKey);
+ }
+ }
+ if (facesMsg != null)
+ throw new ValidatorException(facesMsg);
+ }
}
Modified: myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCompareToValidator.java
URL: http://svn.apache.org/viewvc/myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCompareToValidator.java?rev=673801&r1=673800&r2=673801&view=diff
==============================================================================
--- myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCompareToValidator.java (original)
+++ myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCompareToValidator.java Thu Jul 3 13:58:48 2008
@@ -45,7 +45,7 @@
* Valid operator attribute values:
*
* equals: eq, ==, =,
- * not equals: ne, !=,
+ * not equals: ne, !=,
* greater than: gt, >,
* less than: lt, <,
* greater than or equals: ge, >=,
@@ -84,11 +84,11 @@
*
* faces-config.xml configuration:
*
- * <validator>
- * <description>CompareTo validator</description>
- * <validator-id>org.apache.myfaces.commons.validator.CompareTo</validator-id>
- * <validator-class>org.apache.myfaces.commons.validator.CompareToValidator</validator-class>
- * </validator>
+ * <validator>
+ * <description>CompareTo validator</description>
+ * <validator-id>org.apache.myfaces.commons.validator.CompareTo</validator-id>
+ * <validator-class>org.apache.myfaces.commons.validator.CompareToValidator</validator-class>
+ * </validator>
*
*
* Facelets configuration (inside a taglib.xml file):
@@ -132,7 +132,7 @@
/**
* <p>The standard converter id for this converter.</p>
*/
- public static final String VALIDATOR_ID = "org.apache.myfaces.commons.validator.CompareTo";
+ public static final String VALIDATOR_ID = "org.apache.myfaces.commons.validator.CompareTo";
/**
* <p>The message identifier of the {@link FacesMessage} to be created if
@@ -246,9 +246,9 @@
return;
}
- String foreignComponentName = getFor();
+ String foreignComponentName = getFor();
- UIComponent foreignComponent = (UIComponent) uiComponent.getParent().findComponent(foreignComponentName);
+ UIComponent foreignComponent = (UIComponent) uiComponent.getParent().findComponent(foreignComponentName);
if(foreignComponent == null)
throw new FacesException("Unable to find component '" + foreignComponentName + "' (calling findComponent on component '" + uiComponent.getId() + "')");
Modified: myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCreditCardValidator.java
URL: http://svn.apache.org/viewvc/myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCreditCardValidator.java?rev=673801&r1=673800&r2=673801&view=diff
==============================================================================
--- myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCreditCardValidator.java (original)
+++ myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCreditCardValidator.java Thu Jul 3 13:58:48 2008
@@ -42,93 +42,93 @@
*/
public abstract class AbstractCreditCardValidator extends ValidatorBase {
- /**
- * <p>The standard converter id for this converter.</p>
- */
- public static final String VALIDATOR_ID = "org.apache.myfaces.commons.validator.CreditCard";
-
- /**
- * <p>The message identifier of the {@link FacesMessage} to be created if
- * the creditcard check fails.</p>
- */
- public static final String CREDITCARD_MESSAGE_ID = "org.apache.myfaces.commons.validator.Creditcard.INVALID";
-
- public AbstractCreditCardValidator(){
- }
-
- //Field, to init the desired Validator
- private int _initSum = 0;
-
- private org.apache.commons.validator.CreditCardValidator creditCardValidator = null;
-
- /**
- *
- */
- public void validate(
- FacesContext facesContext,
- UIComponent uiComponent,
- Object value)
- throws ValidatorException {
-
- if (facesContext == null) throw new NullPointerException("facesContext");
- if (uiComponent == null) throw new NullPointerException("uiComponent");
-
- if (value == null)
- {
- return;
- }
- initValidator();
- if (!this.creditCardValidator.isValid(value.toString())){
- Object[] args = {value.toString()};
+ /**
+ * <p>The standard converter id for this converter.</p>
+ */
+ public static final String VALIDATOR_ID = "org.apache.myfaces.commons.validator.CreditCard";
+
+ /**
+ * <p>The message identifier of the {@link FacesMessage} to be created if
+ * the creditcard check fails.</p>
+ */
+ public static final String CREDITCARD_MESSAGE_ID = "org.apache.myfaces.commons.validator.Creditcard.INVALID";
+
+ public AbstractCreditCardValidator(){
+ }
+
+ //Field, to init the desired Validator
+ private int _initSum = 0;
+
+ private org.apache.commons.validator.CreditCardValidator creditCardValidator = null;
+
+ /**
+ *
+ */
+ public void validate(
+ FacesContext facesContext,
+ UIComponent uiComponent,
+ Object value)
+ throws ValidatorException {
+
+ if (facesContext == null) throw new NullPointerException("facesContext");
+ if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+ if (value == null)
+ {
+ return;
+ }
+ initValidator();
+ if (!this.creditCardValidator.isValid(value.toString())){
+ Object[] args = {value.toString()};
throw new ValidatorException(getFacesMessage(CREDITCARD_MESSAGE_ID, args));
- }
- }
+ }
+ }
- // -------------------------------------------------------- Private Methods
+ // -------------------------------------------------------- Private Methods
- /**
- * <p>initializes the desired validator.</p>
- */
-
- private void initValidator() {
- if(isNone()){
- //no cardtypes are allowed
- creditCardValidator = new org.apache.commons.validator.CreditCardValidator(org.apache.commons.validator.CreditCardValidator.NONE);
- }
- else{
- computeValidators();
- creditCardValidator = new org.apache.commons.validator.CreditCardValidator(_initSum);
- }
- }
-
- /**
- * private methode, that counts the desired creditCards
- */
- private void computeValidators(){
- if(isAmex()){
- this._initSum= org.apache.commons.validator.CreditCardValidator.AMEX + _initSum;
- }
- if(isVisa()){
- this._initSum= org.apache.commons.validator.CreditCardValidator.VISA+ _initSum;
- }
- if(isMastercard()){
- this._initSum= org.apache.commons.validator.CreditCardValidator.MASTERCARD+ _initSum;
- }
- if(isDiscover()){
- this._initSum= org.apache.commons.validator.CreditCardValidator.DISCOVER+ _initSum;
- }
- }
-
- //GETTER & SETTER
-
- /**
- * american express cards
- *
- * @JSFProperty
- * defaultValue = "true"
- */
- public abstract boolean isAmex();
+ /**
+ * <p>initializes the desired validator.</p>
+ */
+
+ private void initValidator() {
+ if(isNone()){
+ //no cardtypes are allowed
+ creditCardValidator = new org.apache.commons.validator.CreditCardValidator(org.apache.commons.validator.CreditCardValidator.NONE);
+ }
+ else{
+ computeValidators();
+ creditCardValidator = new org.apache.commons.validator.CreditCardValidator(_initSum);
+ }
+ }
+
+ /**
+ * private methode, that counts the desired creditCards
+ */
+ private void computeValidators(){
+ if(isAmex()){
+ this._initSum= org.apache.commons.validator.CreditCardValidator.AMEX + _initSum;
+ }
+ if(isVisa()){
+ this._initSum= org.apache.commons.validator.CreditCardValidator.VISA+ _initSum;
+ }
+ if(isMastercard()){
+ this._initSum= org.apache.commons.validator.CreditCardValidator.MASTERCARD+ _initSum;
+ }
+ if(isDiscover()){
+ this._initSum= org.apache.commons.validator.CreditCardValidator.DISCOVER+ _initSum;
+ }
+ }
+
+ //GETTER & SETTER
+
+ /**
+ * american express cards
+ *
+ * @JSFProperty
+ * defaultValue = "true"
+ */
+ public abstract boolean isAmex();
/**
* validation for discover
@@ -136,7 +136,7 @@
* @JSFProperty
* defaultValue = "true"
*/
- public abstract boolean isDiscover();
+ public abstract boolean isDiscover();
/**
* validation for mastercard
@@ -144,7 +144,7 @@
* @JSFProperty
* defaultValue = "true"
*/
- public abstract boolean isMastercard();
+ public abstract boolean isMastercard();
/**
* none of the given cardtypes is allowed.
@@ -152,7 +152,7 @@
* @JSFProperty
* defaultValue = "false"
*/
- public abstract boolean isNone();
+ public abstract boolean isNone();
/**
* validation for visa
@@ -160,16 +160,16 @@
* @JSFProperty
* defaultValue = "true"
*/
- public abstract boolean isVisa();
+ public abstract boolean isVisa();
- public abstract void setAmex(boolean b);
+ public abstract void setAmex(boolean b);
- public abstract void setDiscover(boolean b);
+ public abstract void setDiscover(boolean b);
- public abstract void setMastercard(boolean b);
+ public abstract void setMastercard(boolean b);
- public abstract void setNone(boolean b);
+ public abstract void setNone(boolean b);
- public abstract void setVisa(boolean b);
+ public abstract void setVisa(boolean b);
}
Modified: myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractRegExprValidator.java
URL: http://svn.apache.org/viewvc/myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractRegExprValidator.java?rev=673801&r1=673800&r2=673801&view=diff
==============================================================================
--- myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractRegExprValidator.java (original)
+++ myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractRegExprValidator.java Thu Jul 3 13:58:48 2008
@@ -42,53 +42,53 @@
*/
public abstract class AbstractRegExprValidator extends ValidatorBase {
- /**
- * <p>The standard converter id for this converter.</p>
- */
- public static final String VALIDATOR_ID = "org.apache.myfaces.commons.validator.RegExpr";
-
- /**
- * <p>The message identifier of the {@link FacesMessage} to be created if
- * the regex check fails.</p>
- */
- public static final String REGEXPR_MESSAGE_ID = "org.apache.myfaces.commons.validator.RegExpr.INVALID";
-
- public AbstractRegExprValidator(){
- }
-
- public void validate(
- FacesContext facesContext,
- UIComponent uiComponent,
- Object value)
- throws ValidatorException {
-
- if (facesContext == null) throw new NullPointerException("facesContext");
- if (uiComponent == null) throw new NullPointerException("uiComponent");
-
- if (value == null)
- {
- return;
- }
- Object[] args = {value.toString()};
- if(!GenericValidator.matchRegexp(value.toString(),"^"+getPattern()+"$")){
- throw new ValidatorException(getFacesMessage(REGEXPR_MESSAGE_ID, args));
+ /**
+ * <p>The standard converter id for this converter.</p>
+ */
+ public static final String VALIDATOR_ID = "org.apache.myfaces.commons.validator.RegExpr";
+
+ /**
+ * <p>The message identifier of the {@link FacesMessage} to be created if
+ * the regex check fails.</p>
+ */
+ public static final String REGEXPR_MESSAGE_ID = "org.apache.myfaces.commons.validator.RegExpr.INVALID";
+
+ public AbstractRegExprValidator(){
+ }
+
+ public void validate(
+ FacesContext facesContext,
+ UIComponent uiComponent,
+ Object value)
+ throws ValidatorException {
+
+ if (facesContext == null) throw new NullPointerException("facesContext");
+ if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+ if (value == null)
+ {
+ return;
}
- }
+ Object[] args = {value.toString()};
+ if(!GenericValidator.matchRegexp(value.toString(),"^"+getPattern()+"$")){
+ throw new ValidatorException(getFacesMessage(REGEXPR_MESSAGE_ID, args));
+ }
+ }
- // -------------------------------------------------------- GETTER & SETTER
+ // -------------------------------------------------------- GETTER & SETTER
- /**
- * the pattern, which is the base of the validation
- *
- * @JSFProperty
- * literalOnly = "true"
- * @return the pattern, on which a value should be validated
- */
+ /**
+ * the pattern, which is the base of the validation
+ *
+ * @JSFProperty
+ * literalOnly = "true"
+ * @return the pattern, on which a value should be validated
+ */
public abstract String getPattern();
- /**
- * @param string the pattern, on which a value should be validated
- */
- public abstract void setPattern(String string);
+ /**
+ * @param string the pattern, on which a value should be validated
+ */
+ public abstract void setPattern(String string);
}
Modified: myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractUrlValidator.java
URL: http://svn.apache.org/viewvc/myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractUrlValidator.java?rev=673801&r1=673800&r2=673801&view=diff
==============================================================================
--- myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractUrlValidator.java (original)
+++ myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractUrlValidator.java Thu Jul 3 13:58:48 2008
@@ -39,50 +39,50 @@
*/
public abstract class AbstractUrlValidator extends ValidatorBase {
- /**
- * <p>The standard converter id for this converter.</p>
- */
- public static final String VALIDATOR_ID = "org.apache.myfaces.commons.validator.Url";
- /**
- * <p>The message identifier of the {@link FacesMessage} to be created if
- * the maximum length check fails.</p>
- */
- public static final String URL_MESSAGE_ID = "org.apache.myfaces.commons.validator.Url.INVALID";
-
- public AbstractUrlValidator(){
-
- }
-
- /**
- * method that validates an url address.
- * it uses the commons-validator
- */
- public void validate(
- FacesContext facesContext,
- UIComponent uiComponent,
- Object value)
- throws ValidatorException {
-
-
- if (facesContext == null) throw new NullPointerException("facesContext");
- if (uiComponent == null) throw new NullPointerException("uiComponent");
-
- if (value == null)
- {
- return;
- }
-
- org.apache.commons.validator.UrlValidator urlValidator = initValidator();
-
- if (!urlValidator.isValid(value.toString())) {
- Object[] args = {value.toString()};
- throw new ValidatorException(getFacesMessage(URL_MESSAGE_ID, args));
+ /**
+ * <p>The standard converter id for this converter.</p>
+ */
+ public static final String VALIDATOR_ID = "org.apache.myfaces.commons.validator.Url";
+ /**
+ * <p>The message identifier of the {@link FacesMessage} to be created if
+ * the maximum length check fails.</p>
+ */
+ public static final String URL_MESSAGE_ID = "org.apache.myfaces.commons.validator.Url.INVALID";
+
+ public AbstractUrlValidator(){
+
+ }
+
+ /**
+ * method that validates an url address.
+ * it uses the commons-validator
+ */
+ public void validate(
+ FacesContext facesContext,
+ UIComponent uiComponent,
+ Object value)
+ throws ValidatorException {
+
+
+ if (facesContext == null) throw new NullPointerException("facesContext");
+ if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+ if (value == null)
+ {
+ return;
+ }
+
+ org.apache.commons.validator.UrlValidator urlValidator = initValidator();
+
+ if (!urlValidator.isValid(value.toString())) {
+ Object[] args = {value.toString()};
+ throw new ValidatorException(getFacesMessage(URL_MESSAGE_ID, args));
}
- }
-
- private org.apache.commons.validator.UrlValidator initValidator()
- {
+ }
+
+ private org.apache.commons.validator.UrlValidator initValidator()
+ {
int options = 0;
if (isAllow2Slashes())
@@ -107,34 +107,34 @@
org.apache.commons.validator.UrlValidator(schemesList,options);
}
return urlValidator;
- }
-
- private String[] getSchemesList(){
- if (getSchemes() == null)
- {
- return null;
- }
- String [] list = getSchemes().split(",");
- String [] resp = new String [list.length];
-
- for (int i = 0; i < list.length; i++)
- {
- resp[i] = list[i].trim();
- }
- return resp;
- }
-
- public abstract void setSchemes(String _schemes);
-
- /**
- * CSV values that indicates the set of schemes to check this url.
- *
- * If allowAllSchemas = true, the values of this field are ignored.
- *
- * If no schemes are provided, default to this set ("http", "https", "ftp").
- *
- * @JSFProperty
- */
+ }
+
+ private String[] getSchemesList(){
+ if (getSchemes() == null)
+ {
+ return null;
+ }
+ String [] list = getSchemes().split(",");
+ String [] resp = new String [list.length];
+
+ for (int i = 0; i < list.length; i++)
+ {
+ resp[i] = list[i].trim();
+ }
+ return resp;
+ }
+
+ public abstract void setSchemes(String _schemes);
+
+ /**
+ * CSV values that indicates the set of schemes to check this url.
+ *
+ * If allowAllSchemas = true, the values of this field are ignored.
+ *
+ * If no schemes are provided, default to this set ("http", "https", "ftp").
+ *
+ * @JSFProperty
+ */
public abstract String getSchemes();
public abstract void setAllow2Slashes(boolean _allow2Slashes);
Modified: myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/EmailValidator.java
URL: http://svn.apache.org/viewvc/myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/EmailValidator.java?rev=673801&r1=673800&r2=673801&view=diff
==============================================================================
--- myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/EmailValidator.java (original)
+++ myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/EmailValidator.java Thu Jul 3 13:58:48 2008
@@ -41,42 +41,42 @@
*/
public class EmailValidator extends ValidatorBase {
- /**
- * <p>The standard converter id for this converter.</p>
- */
- public static final String VALIDATOR_ID = "org.apache.myfaces.commons.validator.Email";
- /**
- * <p>The message identifier of the {@link FacesMessage} to be created if
- * the maximum length check fails.</p>
- */
- public static final String EMAIL_MESSAGE_ID = "org.apache.myfaces.commons.validator.Email.INVALID";
-
- public EmailValidator(){
- }
-
- /**
- * methode that validates an email-address.
- * it uses the commons-validator
- */
- public void validate(
- FacesContext facesContext,
- UIComponent uiComponent,
- Object value)
- throws ValidatorException {
-
-
- if (facesContext == null) throw new NullPointerException("facesContext");
- if (uiComponent == null) throw new NullPointerException("uiComponent");
-
- if (value == null)
- {
- return;
- }
- if (!GenericValidator.isEmail(value.toString().trim())) {
- Object[] args = {value.toString()};
- throw new ValidatorException(getFacesMessage(EMAIL_MESSAGE_ID, args));
- }
+ /**
+ * <p>The standard converter id for this converter.</p>
+ */
+ public static final String VALIDATOR_ID = "org.apache.myfaces.commons.validator.Email";
+ /**
+ * <p>The message identifier of the {@link FacesMessage} to be created if
+ * the maximum length check fails.</p>
+ */
+ public static final String EMAIL_MESSAGE_ID = "org.apache.myfaces.commons.validator.Email.INVALID";
+
+ public EmailValidator(){
+ }
+
+ /**
+ * methode that validates an email-address.
+ * it uses the commons-validator
+ */
+ public void validate(
+ FacesContext facesContext,
+ UIComponent uiComponent,
+ Object value)
+ throws ValidatorException {
+
+
+ if (facesContext == null) throw new NullPointerException("facesContext");
+ if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+ if (value == null)
+ {
+ return;
+ }
+ if (!GenericValidator.isEmail(value.toString().trim())) {
+ Object[] args = {value.toString()};
+ throw new ValidatorException(getFacesMessage(EMAIL_MESSAGE_ID, args));
+ }
- }
+ }
}
Modified: myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/ISBNValidator.java
URL: http://svn.apache.org/viewvc/myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/ISBNValidator.java?rev=673801&r1=673800&r2=673801&view=diff
==============================================================================
--- myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/ISBNValidator.java (original)
+++ myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/ISBNValidator.java Thu Jul 3 13:58:48 2008
@@ -39,53 +39,53 @@
public class ISBNValidator extends ValidatorBase {
- /**
- * <p>The standard converter id for this converter.</p>
- */
- public static final String VALIDATOR_ID = "org.apache.myfaces.commons.validator.ISBN";
- /**
- * <p>The message identifier of the {@link FacesMessage} to be created if
- * the maximum length check fails.</p>
- */
- public static final String ISBN_MESSAGE_ID = "org.apache.myfaces.commons.validator.ISBN.INVALID";
-
- /**
- * <p>isbnValidator</p>
- */
- private org.apache.commons.validator.ISBNValidator isbnValidator;
-
- public ISBNValidator(){
- isbnValidator = new org.apache.commons.validator.ISBNValidator();
- }
-
- /**
- * methode that validates isbn codes.
- * it uses the commons-validator
- */
- public void validate(
- FacesContext facesContext,
- UIComponent uiComponent,
- Object value)
- throws ValidatorException {
-
-
- if (facesContext == null) throw new NullPointerException("facesContext");
- if (uiComponent == null) throw new NullPointerException("uiComponent");
-
- if (value == null)
- {
- return;
- }
+ /**
+ * <p>The standard converter id for this converter.</p>
+ */
+ public static final String VALIDATOR_ID = "org.apache.myfaces.commons.validator.ISBN";
+ /**
+ * <p>The message identifier of the {@link FacesMessage} to be created if
+ * the maximum length check fails.</p>
+ */
+ public static final String ISBN_MESSAGE_ID = "org.apache.myfaces.commons.validator.ISBN.INVALID";
+
+ /**
+ * <p>isbnValidator</p>
+ */
+ private org.apache.commons.validator.ISBNValidator isbnValidator;
+
+ public ISBNValidator(){
+ isbnValidator = new org.apache.commons.validator.ISBNValidator();
+ }
+
+ /**
+ * methode that validates isbn codes.
+ * it uses the commons-validator
+ */
+ public void validate(
+ FacesContext facesContext,
+ UIComponent uiComponent,
+ Object value)
+ throws ValidatorException {
+
+
+ if (facesContext == null) throw new NullPointerException("facesContext");
+ if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+ if (value == null)
+ {
+ return;
+ }
if (!isbnValidator.isValid( value.toString())) {
- Object[] args = {value.toString()};
+ Object[] args = {value.toString()};
String message = getMessage();
if (null == message) message = ISBN_MESSAGE_ID;
throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, message, args));
- }
-
+ }
+
- }
+ }
}
\ No newline at end of file