001 /*
002 * Copyright 1999-2001,2004 The Apache Software Foundation.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 package org.apache.commons.latka.jelly.validators;
018
019 import org.apache.commons.latka.Validator;
020 import org.apache.commons.latka.validators.RegexpValidator;
021
022 import org.apache.log4j.Category;
023
024 /**
025 * A class to match some part of the response body to a regular expression
026 *
027 * @author dion
028 * @version $Id: RegexpTag.java 155424 2005-02-26 13:09:29Z dirkv $
029 */
030 public class RegexpTag extends HttpValidatorTagSupport {
031
032 /** the regular expression pattern to match with */
033 private String _pattern = null;
034 /** whether the match is to be case sensitive */
035 private boolean _ignoreCase = false;
036 /** whether to expect success or failure */
037 private boolean _condition = true;
038
039 protected static final Category _log = Category.getInstance(RegexpTag.class);
040
041 public Validator getValidator() {
042 return new RegexpValidator(_label,_pattern,_condition,_ignoreCase);
043 }
044
045 /** Setter for property ignoreCase.
046 * @param ignoreCase New value of property ignoreCase.
047 */
048 public void setIgnoreCase(boolean ignoreCase) {
049 _ignoreCase = ignoreCase;
050 }
051
052 /** Setter for property pattern.
053 * @param pattern New value of property pattern.
054 */
055 public void setPattern(String pattern) {
056 _pattern = pattern;
057 }
058
059 public void setCond(boolean condition) {
060 _condition = condition;
061 }
062
063 }