X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fcom%2Fstevesoft%2Fpat%2FValidator.java;h=2803f58c82f423369d79afbcde580ea107e037d0;hb=3459a8a691cb22508d7067f240b7254e588e77d3;hp=facd3f789bd537d3e0ec7f8347504d5162a18e49;hpb=c40cf903f740a72ab63dd1abc10fa33450ce660d;p=jalview.git diff --git a/src/com/stevesoft/pat/Validator.java b/src/com/stevesoft/pat/Validator.java index facd3f7..2803f58 100755 --- a/src/com/stevesoft/pat/Validator.java +++ b/src/com/stevesoft/pat/Validator.java @@ -1,58 +1,75 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** This class makes it easy to create your own patterns -and integrate them into Regex. For more detail, see the -example file deriv2.java or -deriv3.java. */ - -public class Validator { - String argsave = null; - String pattern = "."; - /** - This method does extra checking on a matched section of - a String beginning at position start and ending at end. - The idea is that you can do extra checking with this - that you don't know how to do with a standard Regex. - - If this method is successful, it returns the location - of the end of this pattern element -- that may be the - value end provided or some other value. A negative - value signifies that a match failure. - - By default, this method just returns end and thus - does nothing. - @see com.stevesoft.pat.Regex#define(java.lang.String,java.lang.String,com.stevesoft.pat.Validator) - */ - public int validate(StringLike src,int start,int end) { - return end; - } - /* This method allows you to modify the behavior of this - validator by making a new Validator object. If a Validator - named "foo" is defined, then the pattern "{??foo:bar}" will - cause Regex to first get the Validator given to Regex.define - and then to call its arg method with the string "bar". - If this method returns a null (the default) you get the same - behavior as the pattern "{??foo}" would supply. */ - public Validator arg(String s) { return null; } - - /** For optimization it is helpful, but not necessary, that - you define the minimum number of characters this validator - will allow to match. To do this - return new patInt(number) where number is the smallest - number of characters that can match. */ - public patInt minChars() { return new patInt(0); } - - /** For optimization it is helpful, but not necessary, that - you define the maximum number of characters this validator - will allow to match. To do this either - return new patInt(number), or new patInf() if an infinite - number of characters may match. */ - public patInt maxChars() { return new patInf(); } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * This class makes it easy to create your own patterns and integrate them into + * Regex. For more detail, see the example file + * deriv2.java or + * deriv3.java. + */ + +public class Validator +{ + String argsave = null; + + String pattern = "."; + + /** + * This method does extra checking on a matched section of a String beginning + * at position start and ending at end. The idea is that you can do extra + * checking with this that you don't know how to do with a standard Regex. + * + * If this method is successful, it returns the location of the end of this + * pattern element -- that may be the value end provided or some other value. + * A negative value signifies that a match failure. + * + * By default, this method just returns end and thus does nothing. + * + * @see com.stevesoft.pat.Regex#define(java.lang.String,java.lang.String,com.stevesoft.pat.Validator) + */ + public int validate(StringLike src, int start, int end) + { + return end; + } + + /* + * This method allows you to modify the behavior of this validator by making a + * new Validator object. If a Validator named "foo" is defined, then the + * pattern "{??foo:bar}" will cause Regex to first get the Validator given to + * Regex.define and then to call its arg method with the string "bar". If this + * method returns a null (the default) you get the same behavior as the + * pattern "{??foo}" would supply. + */ + public Validator arg(String s) + { + return null; + } + + /** + * For optimization it is helpful, but not necessary, that you define the + * minimum number of characters this validator will allow to match. To do this + * return new patInt(number) where number is the smallest number of characters + * that can match. + */ + public patInt minChars() + { + return new patInt(0); + } + + /** + * For optimization it is helpful, but not necessary, that you define the + * maximum number of characters this validator will allow to match. To do this + * either return new patInt(number), or new patInf() if an infinite number of + * characters may match. + */ + public patInt maxChars() + { + return new patInf(); + } +}