mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
Removes metadata as it's useless now
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@1414891 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
-133
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2006,2009 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.opensymphony.xwork2.validator.metadata;
|
||||
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <code>AbstractFieldValidatorDescription</code>
|
||||
*
|
||||
* @author Rainer Hermanns
|
||||
* @version $Id$
|
||||
*/
|
||||
public abstract class AbstractFieldValidatorDescription implements ValidatorDescription {
|
||||
|
||||
/**
|
||||
* Jakarta commons-logging reference.
|
||||
*/
|
||||
protected static Logger log = null;
|
||||
|
||||
public String fieldName;
|
||||
public String key;
|
||||
public String message;
|
||||
public boolean shortCircuit;
|
||||
public boolean simpleValidator;
|
||||
|
||||
|
||||
public AbstractFieldValidatorDescription() {
|
||||
log = LoggerFactory.getLogger(this.getClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an AbstractFieldValidatorDescription with the specified field name.
|
||||
*
|
||||
* @param fieldName
|
||||
*/
|
||||
public AbstractFieldValidatorDescription(String fieldName) {
|
||||
this.fieldName = fieldName;
|
||||
log = LoggerFactory.getLogger(this.getClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the field name for this validator rule.
|
||||
*
|
||||
* @return fieldName the field name for this validator rule
|
||||
*/
|
||||
public String getFieldName() {
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the field name for this validator rule.
|
||||
*
|
||||
* @param fieldName the field name for this validator rule
|
||||
*/
|
||||
public void setFieldName(String fieldName) {
|
||||
this.fieldName = fieldName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the I18N message key.
|
||||
* @param key the I18N message key
|
||||
*/
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default validator failure message.
|
||||
*
|
||||
* @param message the default validator failure message
|
||||
*/
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the shortCircuit flag.
|
||||
*
|
||||
* @param shortCircuit the shortCircuit flag.
|
||||
*/
|
||||
public void setShortCircuit(boolean shortCircuit) {
|
||||
this.shortCircuit = shortCircuit;
|
||||
}
|
||||
|
||||
public void setSimpleValidator(boolean simpleValidator) {
|
||||
this.simpleValidator = simpleValidator;
|
||||
}
|
||||
|
||||
public boolean isSimpleValidator() {
|
||||
return simpleValidator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the validator XML definition.
|
||||
*
|
||||
* @return the validator XML definition.
|
||||
*/
|
||||
public String asXml() {
|
||||
if ( simpleValidator) {
|
||||
return asSimpleXml();
|
||||
}
|
||||
return asFieldXml();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the field validator XML definition.
|
||||
*
|
||||
* @return the field validator XML definition.
|
||||
*/
|
||||
public abstract String asFieldXml();
|
||||
|
||||
/**
|
||||
* Returns the validator XML definition.
|
||||
*
|
||||
* @return the validator XML definition.
|
||||
*/
|
||||
public abstract String asSimpleXml();
|
||||
|
||||
}
|
||||
-118
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2006,2009 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.opensymphony.xwork2.validator.metadata;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**
|
||||
* <code>ConversionErrorFieldValidatorDescription</code>
|
||||
*
|
||||
* @author Rainer Hermanns
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ConversionErrorFieldValidatorDescription extends AbstractFieldValidatorDescription {
|
||||
|
||||
public ConversionErrorFieldValidatorDescription() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an AbstractFieldValidatorDescription with the specified field name.
|
||||
*
|
||||
* @param fieldName
|
||||
*/
|
||||
public ConversionErrorFieldValidatorDescription(String fieldName) {
|
||||
super(fieldName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the field validator XML definition.
|
||||
*
|
||||
* @return the field validator XML definition.
|
||||
*/
|
||||
@Override
|
||||
public String asFieldXml() {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new PrintWriter(sw);
|
||||
|
||||
if (shortCircuit) {
|
||||
writer.println("\t\t<field-validator type=\"conversion\">");
|
||||
} else {
|
||||
writer.println("\t\t<field-validator type=\"conversion\" short-circuit=\"true\">");
|
||||
}
|
||||
|
||||
if (!"".equals(key)) {
|
||||
writer.println("\t\t\t<message key=\"" + key + "\">" + message + "</message>");
|
||||
} else {
|
||||
writer.println("\t\t\t<message>" + message + "</message>");
|
||||
}
|
||||
|
||||
writer.println("\t\t</field-validator>");
|
||||
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the validator XML definition.
|
||||
*
|
||||
* @return the validator XML definition.
|
||||
*/
|
||||
@Override
|
||||
public String asSimpleXml() {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new PrintWriter(sw);
|
||||
|
||||
if (shortCircuit) {
|
||||
writer.println("\t<validator type=\"conversion\">");
|
||||
} else {
|
||||
writer.println("\t<validator type=\"conversion\" short-circuit=\"true\">");
|
||||
}
|
||||
|
||||
writer.println("\t\t<param name=\"fieldName\">" + fieldName + "</param>");
|
||||
|
||||
if (!"".equals(key)) {
|
||||
writer.println("\t\t<message key=\"" + key + "\">" + message + "</message>");
|
||||
} else {
|
||||
writer.println("\t\t<message>" + message + "</message>");
|
||||
}
|
||||
|
||||
writer.println("\t</validator>");
|
||||
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
}
|
||||
-140
@@ -1,140 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2006,2009 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.opensymphony.xwork2.validator.metadata;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**
|
||||
* <code>DateRangeFieldValidatorDescription</code>
|
||||
*
|
||||
* @author Rainer Hermanns
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DateRangeFieldValidatorDescription extends AbstractFieldValidatorDescription {
|
||||
|
||||
public String min;
|
||||
public String max;
|
||||
|
||||
public DateRangeFieldValidatorDescription() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an AbstractFieldValidatorDescription with the specified field name.
|
||||
*
|
||||
* @param fieldName
|
||||
*/
|
||||
public DateRangeFieldValidatorDescription(String fieldName) {
|
||||
super(fieldName);
|
||||
}
|
||||
|
||||
public void setMin(String min) {
|
||||
this.min = min;
|
||||
}
|
||||
|
||||
public void setMax(String max) {
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the field validator XML definition.
|
||||
*
|
||||
* @return the field validator XML definition.
|
||||
*/
|
||||
@Override
|
||||
public String asFieldXml() {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new PrintWriter(sw);
|
||||
|
||||
if ( shortCircuit) {
|
||||
writer.println("\t\t<field-validator type=\"date\">");
|
||||
} else {
|
||||
writer.println("\t\t<field-validator type=\"date\" short-circuit=\"true\">");
|
||||
}
|
||||
if ( min != null && min.length() > 0) {
|
||||
writer.println("\t\t\t<param name=\"min\">" + min + "</param>");
|
||||
}
|
||||
if ( max != null && max.length() > 0) {
|
||||
writer.println("\t\t\t<param name=\"max\">" + max + "</param>");
|
||||
}
|
||||
|
||||
if ( !"".equals(key)) {
|
||||
writer.println("\t\t\t<message key=\"" + key + "\">" + message + "</message>");
|
||||
} else {
|
||||
writer.println("\t\t\t<message>" + message + "</message>");
|
||||
}
|
||||
|
||||
writer.println("\t\t</field-validator>");
|
||||
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the validator XML definition.
|
||||
*
|
||||
* @return the validator XML definition.
|
||||
*/
|
||||
@Override
|
||||
public String asSimpleXml() {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new PrintWriter(sw);
|
||||
|
||||
if ( shortCircuit) {
|
||||
writer.println("\t<validator type=\"date\">");
|
||||
} else {
|
||||
writer.println("\t<validator type=\"date\" short-circuit=\"true\">");
|
||||
}
|
||||
|
||||
writer.println("\t\t<param name=\"fieldName\">" + fieldName+ "</param>");
|
||||
|
||||
|
||||
if ( min != null && min.length() > 0) {
|
||||
writer.println("\t\t<param name=\"min\">" + min + "</param>");
|
||||
}
|
||||
if ( max != null && max.length() > 0) {
|
||||
writer.println("\t\t<param name=\"max\">" + max + "</param>");
|
||||
}
|
||||
|
||||
if ( !"".equals(key)) {
|
||||
writer.println("\t\t<message key=\"" + key + "\">" + message + "</message>");
|
||||
} else {
|
||||
writer.println("\t\t<message>" + message + "</message>");
|
||||
}
|
||||
|
||||
writer.println("\t</validator>");
|
||||
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
}
|
||||
}
|
||||
-142
@@ -1,142 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2006,2009 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.opensymphony.xwork2.validator.metadata;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**
|
||||
* <code>DoubleRangeFieldValidatorDescription</code>
|
||||
*
|
||||
* @author <a href="mailto:hermanns@aixcept.de">Rainer Hermanns</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DoubleRangeFieldValidatorDescription extends AbstractFieldValidatorDescription {
|
||||
|
||||
public String min;
|
||||
public String max;
|
||||
|
||||
public DoubleRangeFieldValidatorDescription() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an DoubleRangeFieldValidatorDescription with the specified field name.
|
||||
*
|
||||
* @param fieldName
|
||||
*/
|
||||
public DoubleRangeFieldValidatorDescription(String fieldName) {
|
||||
super(fieldName);
|
||||
}
|
||||
|
||||
public void setMin(String min) {
|
||||
this.min = min;
|
||||
}
|
||||
|
||||
public void setMax(String max) {
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the field validator XML definition.
|
||||
*
|
||||
* @return the field validator XML definition.
|
||||
*/
|
||||
@Override
|
||||
public String asFieldXml() {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new PrintWriter(sw);
|
||||
|
||||
if ( shortCircuit) {
|
||||
writer.println("\t\t<field-validator type=\"double\">");
|
||||
} else {
|
||||
writer.println("\t\t<field-validator type=\"double\" short-circuit=\"true\">");
|
||||
}
|
||||
if ( min != null && min.length() > 0) {
|
||||
writer.println("\t\t\t<param name=\"min\">" + min + "</param>");
|
||||
}
|
||||
if ( max != null && max.length() > 0) {
|
||||
writer.println("\t\t\t<param name=\"max\">" + max + "</param>");
|
||||
}
|
||||
|
||||
if ( !"".equals(key)) {
|
||||
writer.println("\t\t\t<message key=\"" + key + "\">" + message + "</message>");
|
||||
} else {
|
||||
writer.println("\t\t\t<message>" + message + "</message>");
|
||||
}
|
||||
|
||||
writer.println("\t\t</field-validator>");
|
||||
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the validator XML definition.
|
||||
*
|
||||
* @return the validator XML definition.
|
||||
*/
|
||||
@Override
|
||||
public String asSimpleXml() {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new PrintWriter(sw);
|
||||
|
||||
if ( shortCircuit) {
|
||||
writer.println("\t<validator type=\"double\">");
|
||||
} else {
|
||||
writer.println("\t<validator type=\"double\" short-circuit=\"true\">");
|
||||
}
|
||||
|
||||
writer.println("\t\t<param name=\"fieldName\">" + fieldName+ "</param>");
|
||||
|
||||
|
||||
if ( min != null && min.length() > 0) {
|
||||
writer.println("\t\t<param name=\"min\">" + min + "</param>");
|
||||
}
|
||||
if ( max != null && max.length() > 0) {
|
||||
writer.println("\t\t<param name=\"max\">" + max + "</param>");
|
||||
}
|
||||
|
||||
if ( !"".equals(key)) {
|
||||
writer.println("\t\t<message key=\"" + key + "\">" + message + "</message>");
|
||||
} else {
|
||||
writer.println("\t\t<message>" + message + "</message>");
|
||||
}
|
||||
|
||||
writer.println("\t</validator>");
|
||||
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
}
|
||||
-119
@@ -1,119 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2006,2009 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.opensymphony.xwork2.validator.metadata;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**
|
||||
* <code>EmailValidatorDescription</code>
|
||||
*
|
||||
* @author Rainer Hermanns
|
||||
* @version $Id$
|
||||
*/
|
||||
public class EmailValidatorDescription extends AbstractFieldValidatorDescription {
|
||||
|
||||
|
||||
public EmailValidatorDescription() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an AbstractFieldValidatorDescription with the specified field name.
|
||||
*
|
||||
* @param fieldName
|
||||
*/
|
||||
public EmailValidatorDescription(String fieldName) {
|
||||
super(fieldName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the field validator XML definition.
|
||||
*
|
||||
* @return the field validator XML definition.
|
||||
*/
|
||||
@Override
|
||||
public String asFieldXml() {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new PrintWriter(sw);
|
||||
|
||||
if ( shortCircuit) {
|
||||
writer.println("\t\t<field-validator type=\"email\">");
|
||||
} else {
|
||||
writer.println("\t\t<field-validator type=\"email\" short-circuit=\"true\">");
|
||||
}
|
||||
|
||||
if ( !"".equals(key)) {
|
||||
writer.println("\t\t\t<message key=\"" + key + "\">" + message + "</message>");
|
||||
} else {
|
||||
writer.println("\t\t\t<message>" + message + "</message>");
|
||||
}
|
||||
|
||||
writer.println("\t\t</field-validator>");
|
||||
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the validator XML definition.
|
||||
*
|
||||
* @return the validator XML definition.
|
||||
*/
|
||||
@Override
|
||||
public String asSimpleXml() {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new PrintWriter(sw);
|
||||
|
||||
if ( shortCircuit) {
|
||||
writer.println("\t<validator type=\"email\">");
|
||||
} else {
|
||||
writer.println("\t<validator type=\"email\" short-circuit=\"true\">");
|
||||
}
|
||||
|
||||
writer.println("\t\t<param name=\"fieldName\">" + fieldName+ "</param>");
|
||||
|
||||
if ( !"".equals(key)) {
|
||||
writer.println("\t\t<message key=\"" + key + "\">" + message + "</message>");
|
||||
} else {
|
||||
writer.println("\t\t<message>" + message + "</message>");
|
||||
}
|
||||
|
||||
writer.println("\t</validator>");
|
||||
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
-94
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2006,2009 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.opensymphony.xwork2.validator.metadata;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**
|
||||
* <code>ExpressionValidatorDescription</code>
|
||||
*
|
||||
* @author Rainer Hermanns
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ExpressionValidatorDescription implements ValidatorDescription {
|
||||
|
||||
public String expression;
|
||||
public String key;
|
||||
public String message;
|
||||
public boolean shortCircuit;
|
||||
|
||||
public void setExpression(String expression) {
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public void setShortCircuit(boolean shortCircuit) {
|
||||
this.shortCircuit = shortCircuit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the field name to create the validation rule for.
|
||||
*
|
||||
* @return The field name to create the validation rule for
|
||||
*/
|
||||
public String getFieldName() {
|
||||
throw new UnsupportedOperationException("ExpressionValidator annotations cannot be applied to fields...");
|
||||
}
|
||||
|
||||
public String asXml() {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new PrintWriter(sw);
|
||||
|
||||
if ( shortCircuit) {
|
||||
writer.println("\t<validator type=\"expression\">");
|
||||
} else {
|
||||
writer.println("\t<validator type=\"expression\" short-circuit=\"true\">");
|
||||
}
|
||||
|
||||
writer.println("\t\t<param name=\"expression\">" + expression+ "</param>");
|
||||
|
||||
if ( !"".equals(key)) {
|
||||
writer.println("\t\t<message key=\"" + key + "\">" + message + "</message>");
|
||||
} else {
|
||||
writer.println("\t\t<message>" + message + "</message>");
|
||||
}
|
||||
|
||||
writer.println("\t</validator>");
|
||||
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
public boolean isSimpleValidator() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-114
@@ -1,114 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2006,2009 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.opensymphony.xwork2.validator.metadata;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**
|
||||
* <code>FieldExpressionValidatorDescription</code>
|
||||
*
|
||||
* @author Rainer Hermanns
|
||||
* @version $Id$
|
||||
*/
|
||||
public class FieldExpressionValidatorDescription extends AbstractFieldValidatorDescription {
|
||||
|
||||
public String expression;
|
||||
public String key;
|
||||
public String message;
|
||||
public boolean shortCircuit;
|
||||
|
||||
public FieldExpressionValidatorDescription() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an AbstractFieldValidatorDescription with the specified field name.
|
||||
*
|
||||
* @param fieldName
|
||||
*/
|
||||
public FieldExpressionValidatorDescription(String fieldName) {
|
||||
super(fieldName);
|
||||
}
|
||||
|
||||
public void setExpression(String expression) {
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShortCircuit(boolean shortCircuit) {
|
||||
this.shortCircuit = shortCircuit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the validator XML definition.
|
||||
*
|
||||
* @return the validator XML definition.
|
||||
*/
|
||||
@Override
|
||||
public String asFieldXml() {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new PrintWriter(sw);
|
||||
|
||||
if ( shortCircuit) {
|
||||
writer.println("\t\t<field-validator type=\"fieldexpression\">");
|
||||
} else {
|
||||
writer.println("\t\t<field-validator type=\"fieldexpression\" short-circuit=\"true\">");
|
||||
}
|
||||
|
||||
writer.println("\t\t\t<param name=\"expression\">" + expression+ "</param>");
|
||||
|
||||
if ( !"".equals(key)) {
|
||||
writer.println("\t\t\t<message key=\"" + key + "\">" + message + "</message>");
|
||||
} else {
|
||||
writer.println("\t\t\t<message>" + message + "</message>");
|
||||
}
|
||||
|
||||
writer.println("\t\t</field-validator>");
|
||||
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the validator XML definition.
|
||||
*
|
||||
* @return the validator XML definition.
|
||||
*/
|
||||
@Override
|
||||
public String asSimpleXml() {
|
||||
throw new UnsupportedOperationException(getClass().getName() + " cannot be used for simple validators...");
|
||||
}
|
||||
|
||||
}
|
||||
-145
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2006,2009 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.opensymphony.xwork2.validator.metadata;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**
|
||||
* <code>IntRangeFieldValidatorDescription</code>
|
||||
*
|
||||
* @author Rainer Hermanns
|
||||
* @version $Id$
|
||||
*/
|
||||
public class IntRangeFieldValidatorDescription extends AbstractFieldValidatorDescription {
|
||||
|
||||
public String min;
|
||||
public String max;
|
||||
|
||||
public IntRangeFieldValidatorDescription() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an AbstractFieldValidatorDescription with the specified field name.
|
||||
*
|
||||
* @param fieldName
|
||||
*/
|
||||
public IntRangeFieldValidatorDescription(String fieldName) {
|
||||
super(fieldName);
|
||||
}
|
||||
|
||||
public void setMin(String min) {
|
||||
this.min = min;
|
||||
}
|
||||
|
||||
public void setMax(String max) {
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the field validator XML definition.
|
||||
*
|
||||
* @return the field validator XML definition.
|
||||
*/
|
||||
@Override
|
||||
public String asFieldXml() {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new PrintWriter(sw);
|
||||
|
||||
if ( shortCircuit) {
|
||||
writer.println("\t\t<field-validator type=\"int\">");
|
||||
} else {
|
||||
writer.println("\t\t<field-validator type=\"int\" short-circuit=\"true\">");
|
||||
}
|
||||
if ( min != null && min.length() > 0) {
|
||||
writer.println("\t\t\t<param name=\"min\">" + min + "</param>");
|
||||
}
|
||||
if ( max != null && max.length() > 0) {
|
||||
writer.println("\t\t\t<param name=\"max\">" + max + "</param>");
|
||||
}
|
||||
|
||||
if ( !"".equals(key)) {
|
||||
writer.println("\t\t\t<message key=\"" + key + "\">" + message + "</message>");
|
||||
} else {
|
||||
writer.println("\t\t\t<message>" + message + "</message>");
|
||||
}
|
||||
|
||||
writer.println("\t\t</field-validator>");
|
||||
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the validator XML definition.
|
||||
*
|
||||
* @return the validator XML definition.
|
||||
*/
|
||||
@Override
|
||||
public String asSimpleXml() {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new PrintWriter(sw);
|
||||
|
||||
if ( shortCircuit) {
|
||||
writer.println("\t<validator type=\"int\">");
|
||||
} else {
|
||||
writer.println("\t<validator type=\"int\" short-circuit=\"true\">");
|
||||
}
|
||||
|
||||
writer.println("\t\t<param name=\"fieldName\">" + fieldName+ "</param>");
|
||||
|
||||
|
||||
if ( min != null && min.length() > 0) {
|
||||
writer.println("\t\t<param name=\"min\">" + min + "</param>");
|
||||
}
|
||||
if ( max != null && max.length() > 0) {
|
||||
writer.println("\t\t<param name=\"max\">" + max + "</param>");
|
||||
}
|
||||
|
||||
if ( !"".equals(key)) {
|
||||
writer.println("\t\t<message key=\"" + key + "\">" + message + "</message>");
|
||||
} else {
|
||||
writer.println("\t\t<message>" + message + "</message>");
|
||||
}
|
||||
|
||||
writer.println("\t</validator>");
|
||||
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
-116
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2006,2009 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.opensymphony.xwork2.validator.metadata;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**
|
||||
* <code>RequiredFieldValidatorDescription</code>
|
||||
*
|
||||
* @author Rainer Hermanns
|
||||
* @version $Id$
|
||||
*/
|
||||
public class RequiredFieldValidatorDescription extends AbstractFieldValidatorDescription {
|
||||
|
||||
public RequiredFieldValidatorDescription() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an AbstractFieldValidatorDescription with the specified field name.
|
||||
*
|
||||
* @param fieldName
|
||||
*/
|
||||
public RequiredFieldValidatorDescription(String fieldName) {
|
||||
super(fieldName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the field validator XML definition.
|
||||
*
|
||||
* @return the field validator XML definition.
|
||||
*/
|
||||
@Override
|
||||
public String asFieldXml() {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new PrintWriter(sw);
|
||||
|
||||
if ( shortCircuit) {
|
||||
writer.println("\t\t<field-validator type=\"required\">");
|
||||
} else {
|
||||
writer.println("\t\t<field-validator type=\"required\" short-circuit=\"true\">");
|
||||
}
|
||||
|
||||
if ( !"".equals(key)) {
|
||||
writer.println("\t\t\t<message key=\"" + key + "\">" + message + "</message>");
|
||||
} else {
|
||||
writer.println("\t\t\t<message>" + message + "</message>");
|
||||
}
|
||||
|
||||
writer.println("\t\t</field-validator>");
|
||||
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the validator XML definition.
|
||||
*
|
||||
* @return the validator XML definition.
|
||||
*/
|
||||
@Override
|
||||
public String asSimpleXml() {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new PrintWriter(sw);
|
||||
|
||||
if ( shortCircuit) {
|
||||
writer.println("\t<validator type=\"required\">");
|
||||
} else {
|
||||
writer.println("\t<validator type=\"required\" short-circuit=\"true\">");
|
||||
}
|
||||
|
||||
writer.println("\t\t<param name=\"fieldName\">" + fieldName+ "</param>");
|
||||
|
||||
if ( !"".equals(key)) {
|
||||
writer.println("\t\t<message key=\"" + key + "\">" + message + "</message>");
|
||||
} else {
|
||||
writer.println("\t\t<message>" + message + "</message>");
|
||||
}
|
||||
|
||||
writer.println("\t</validator>");
|
||||
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
}
|
||||
-129
@@ -1,129 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2006,2009 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.opensymphony.xwork2.validator.metadata;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**
|
||||
* <code>RequiredStringValidatorDescription</code>
|
||||
*
|
||||
* @author Rainer Hermanns
|
||||
* @version $Id$
|
||||
*/
|
||||
public class RequiredStringValidatorDescription extends AbstractFieldValidatorDescription {
|
||||
|
||||
public boolean trim = true;
|
||||
|
||||
public RequiredStringValidatorDescription() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an AbstractFieldValidatorDescription with the specified field name.
|
||||
*
|
||||
* @param fieldName
|
||||
*/
|
||||
public RequiredStringValidatorDescription(String fieldName) {
|
||||
super(fieldName);
|
||||
}
|
||||
|
||||
public void setTrim(boolean trim) {
|
||||
this.trim = trim;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the field validator XML definition.
|
||||
*
|
||||
* @return the field validator XML definition.
|
||||
*/
|
||||
@Override
|
||||
public String asFieldXml() {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new PrintWriter(sw);
|
||||
|
||||
if ( shortCircuit) {
|
||||
writer.println("\t\t<field-validator type=\"requiredstring\">");
|
||||
} else {
|
||||
writer.println("\t\t<field-validator type=\"requiredstring\" short-circuit=\"true\">");
|
||||
}
|
||||
if ( !trim) {
|
||||
writer.println("\t\t\t<param name=\"trim\">" + trim + "</param>");
|
||||
}
|
||||
|
||||
if ( !"".equals(key)) {
|
||||
writer.println("\t\t\t<message key=\"" + key + "\">" + message + "</message>");
|
||||
} else {
|
||||
writer.println("\t\t\t<message>" + message + "</message>");
|
||||
}
|
||||
|
||||
writer.println("\t\t</field-validator>");
|
||||
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the validator XML definition.
|
||||
*
|
||||
* @return the validator XML definition.
|
||||
*/
|
||||
@Override
|
||||
public String asSimpleXml() {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new PrintWriter(sw);
|
||||
|
||||
if ( shortCircuit) {
|
||||
writer.println("\t<validator type=\"requiredstring\">");
|
||||
} else {
|
||||
writer.println("\t<validator type=\"requiredstring\" short-circuit=\"true\">");
|
||||
}
|
||||
|
||||
writer.println("\t\t<param name=\"fieldName\">" + fieldName+ "</param>");
|
||||
|
||||
if ( !trim) {
|
||||
writer.println("\t\t<param name=\"trim\">" + trim + "</param>");
|
||||
}
|
||||
|
||||
if ( !"".equals(key)) {
|
||||
writer.println("\t\t<message key=\"" + key + "\">" + message + "</message>");
|
||||
} else {
|
||||
writer.println("\t\t<message>" + message + "</message>");
|
||||
}
|
||||
|
||||
writer.println("\t</validator>");
|
||||
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
}
|
||||
-153
@@ -1,153 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2006,2009 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.opensymphony.xwork2.validator.metadata;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**
|
||||
* <code>StringLengthFieldValidatorDescription</code>
|
||||
*
|
||||
* @author Rainer Hermanns
|
||||
* @version $Id$
|
||||
*/
|
||||
public class StringLengthFieldValidatorDescription extends AbstractFieldValidatorDescription {
|
||||
|
||||
public boolean trim = true;
|
||||
public String minLength;
|
||||
public String maxLength;
|
||||
|
||||
public StringLengthFieldValidatorDescription() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an AbstractFieldValidatorDescription with the specified field name.
|
||||
*
|
||||
* @param fieldName
|
||||
*/
|
||||
public StringLengthFieldValidatorDescription(String fieldName) {
|
||||
super(fieldName);
|
||||
}
|
||||
|
||||
public void setTrim(boolean trim) {
|
||||
this.trim = trim;
|
||||
}
|
||||
|
||||
public void setMinLength(String minLength) {
|
||||
this.minLength = minLength;
|
||||
}
|
||||
|
||||
public void setMaxLength(String maxLength) {
|
||||
this.maxLength = maxLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the field validator XML definition.
|
||||
*
|
||||
* @return the field validator XML definition.
|
||||
*/
|
||||
@Override
|
||||
public String asFieldXml() {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new PrintWriter(sw);
|
||||
|
||||
if ( shortCircuit) {
|
||||
writer.println("\t\t<field-validator type=\"stringlength\">");
|
||||
} else {
|
||||
writer.println("\t\t<field-validator type=\"stringlength\" short-circuit=\"true\">");
|
||||
}
|
||||
if ( !trim) {
|
||||
writer.println("\t\t\t<param name=\"trim\">" + trim + "</param>");
|
||||
}
|
||||
if ( minLength != null && minLength.length() > 0) {
|
||||
writer.println("\t\t\t<param name=\"minLength\">" + minLength + "</param>");
|
||||
}
|
||||
if ( maxLength != null && maxLength.length() > 0) {
|
||||
writer.println("\t\t\t<param name=\"maxLength\">" + maxLength + "</param>");
|
||||
}
|
||||
|
||||
if ( !"".equals(key)) {
|
||||
writer.println("\t\t\t<message key=\"" + key + "\">" + message + "</message>");
|
||||
} else {
|
||||
writer.println("\t\t\t<message>" + message + "</message>");
|
||||
}
|
||||
|
||||
writer.println("\t</field-validator>");
|
||||
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the validator XML definition.
|
||||
*
|
||||
* @return the validator XML definition.
|
||||
*/
|
||||
@Override
|
||||
public String asSimpleXml() {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new PrintWriter(sw);
|
||||
|
||||
if ( shortCircuit) {
|
||||
writer.println("\t<validator type=\"stringlength\">");
|
||||
} else {
|
||||
writer.println("\t<validator type=\"stringlength\" short-circuit=\"true\">");
|
||||
}
|
||||
|
||||
writer.println("\t\t<param name=\"fieldName\">" + fieldName+ "</param>");
|
||||
|
||||
if ( !trim) {
|
||||
writer.println("\t\t<param name=\"trim\">" + trim + "</param>");
|
||||
}
|
||||
|
||||
if ( minLength != null && minLength.length() > 0) {
|
||||
writer.println("\t\t<param name=\"minLength\">" + minLength + "</param>");
|
||||
}
|
||||
if ( maxLength != null && maxLength.length() > 0) {
|
||||
writer.println("\t\t<param name=\"maxLength\">" + maxLength + "</param>");
|
||||
}
|
||||
|
||||
if ( !"".equals(key)) {
|
||||
writer.println("\t\t<message key=\"" + key + "\">" + message + "</message>");
|
||||
} else {
|
||||
writer.println("\t\t<message>" + message + "</message>");
|
||||
}
|
||||
|
||||
writer.println("\t</validator>");
|
||||
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
-117
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2006,2009 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.opensymphony.xwork2.validator.metadata;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**
|
||||
* <code>URLValidatorDescription</code>
|
||||
*
|
||||
* @author Rainer Hermanns
|
||||
* @version $Id$
|
||||
*/
|
||||
public class URLValidatorDescription extends AbstractFieldValidatorDescription {
|
||||
|
||||
|
||||
public URLValidatorDescription() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an AbstractFieldValidatorDescription with the specified aliasNames.
|
||||
*
|
||||
* @param fieldName
|
||||
*/
|
||||
public URLValidatorDescription(String fieldName) {
|
||||
super(fieldName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the field validator XML definition.
|
||||
*
|
||||
* @return the field validator XML definition.
|
||||
*/
|
||||
@Override
|
||||
public String asFieldXml() {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new PrintWriter(sw);
|
||||
|
||||
if ( shortCircuit) {
|
||||
writer.println("\t\t<field-validator type=\"url\">");
|
||||
} else {
|
||||
writer.println("\t\t<field-validator type=\"url\" short-circuit=\"true\">");
|
||||
}
|
||||
|
||||
if ( !"".equals(key)) {
|
||||
writer.println("\t\t\t<message key=\"" + key + "\">" + message + "</message>");
|
||||
} else {
|
||||
writer.println("\t\t\t<message>" + message + "</message>");
|
||||
}
|
||||
|
||||
writer.println("\t\t</field-validator>");
|
||||
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the validator XML definition.
|
||||
*
|
||||
* @return the validator XML definition.
|
||||
*/
|
||||
@Override
|
||||
public String asSimpleXml() {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new PrintWriter(sw);
|
||||
|
||||
if ( shortCircuit) {
|
||||
writer.println("\t<validator type=\"url\">");
|
||||
} else {
|
||||
writer.println("\t<validator type=\"url\" short-circuit=\"true\">");
|
||||
}
|
||||
|
||||
writer.println("\t\t<param name=\"fieldName\">" + fieldName+ "</param>");
|
||||
|
||||
if ( !"".equals(key)) {
|
||||
writer.println("\t\t<message key=\"" + key + "\">" + message + "</message>");
|
||||
} else {
|
||||
writer.println("\t\t<message>" + message + "</message>");
|
||||
}
|
||||
|
||||
writer.println("\t</validator>");
|
||||
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
}
|
||||
}
|
||||
-62
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2006,2009 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.opensymphony.xwork2.validator.metadata;
|
||||
|
||||
/**
|
||||
* <code>ValidatorDescription</code>
|
||||
*
|
||||
* @author Rainer Hermanns
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface ValidatorDescription {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the validator XML definition.
|
||||
*
|
||||
* @return the validator XML definition.
|
||||
*/
|
||||
String asXml();
|
||||
|
||||
/**
|
||||
* Returns the field name to create the validation rule for.
|
||||
*
|
||||
* @return The field name to create the validation rule for
|
||||
*/
|
||||
String getFieldName();
|
||||
|
||||
/**
|
||||
* Sets the I18N message key.
|
||||
* @param key the I18N message key
|
||||
*/
|
||||
void setKey(String key);
|
||||
|
||||
/**
|
||||
* Sets the default validator failure message.
|
||||
*
|
||||
* @param message the default validator failure message
|
||||
*/
|
||||
void setMessage(String message);
|
||||
|
||||
/**
|
||||
* Set the shortCircuit flag.
|
||||
*
|
||||
* @param shortCircuit the shortCircuit flag.
|
||||
*/
|
||||
void setShortCircuit(boolean shortCircuit);
|
||||
|
||||
boolean isSimpleValidator();
|
||||
}
|
||||
-105
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2006,2009 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.opensymphony.xwork2.validator.metadata;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**
|
||||
* <code>VisitorFieldValidatorDescription</code>
|
||||
*
|
||||
* @author Rainer Hermanns
|
||||
* @version $Id$
|
||||
*/
|
||||
public class VisitorFieldValidatorDescription extends AbstractFieldValidatorDescription {
|
||||
|
||||
public String context;
|
||||
public boolean appendPrefix = true;
|
||||
|
||||
public VisitorFieldValidatorDescription() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an AbstractFieldValidatorDescription with the specified field name.
|
||||
*
|
||||
* @param fieldName
|
||||
*/
|
||||
public VisitorFieldValidatorDescription(String fieldName) {
|
||||
super(fieldName);
|
||||
}
|
||||
|
||||
public void setContext(String context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public void setAppendPrefix(boolean appendPrefix) {
|
||||
this.appendPrefix = appendPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the validator XML definition.
|
||||
*
|
||||
* @return the validator XML definition.
|
||||
*/
|
||||
@Override
|
||||
public String asFieldXml() {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new PrintWriter(sw);
|
||||
|
||||
if ( shortCircuit) {
|
||||
writer.println("\t\t<field-validator type=\"visitor\">");
|
||||
} else {
|
||||
writer.println("\t\t<field-validator type=\"visitor\" short-circuit=\"true\">");
|
||||
}
|
||||
|
||||
if ( context != null && context.length() > 0) {
|
||||
writer.println("\t\t\t<param name=\"context\">" + context + "</param>");
|
||||
}
|
||||
|
||||
if ( !appendPrefix) {
|
||||
writer.println("\t\t\t<param name=\"appendPrefix\">" + appendPrefix + "</param>");
|
||||
}
|
||||
|
||||
if ( !"".equals(key)) {
|
||||
writer.println("\t\t\t<message key=\"" + key + "\">" + message + "</message>");
|
||||
} else {
|
||||
writer.println("\t\t\t<message>" + message + "</message>");
|
||||
}
|
||||
|
||||
writer.println("\t\t</field-validator>");
|
||||
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the validator XML definition.
|
||||
*
|
||||
* @return the validator XML definition.
|
||||
*/
|
||||
@Override
|
||||
public String asSimpleXml() {
|
||||
throw new UnsupportedOperationException(getClass().getName() + " cannot be used for simple validators...");
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<body>Validator meta data classes.</body>
|
||||
Reference in New Issue
Block a user