X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=unused%2Fcom%2Fstevesoft%2Fpat%2FBracket.java;h=7d61b41d01c87d0fb3e8358b286e42158b284c01;hb=6319110ce33faa76ee6cf9832e78faa224510fed;hp=cec8af450da12d89a352b5fb0c8fb741fe1cece2;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44;p=jalviewjs.git diff --git a/unused/com/stevesoft/pat/Bracket.java b/unused/com/stevesoft/pat/Bracket.java index cec8af4..7d61b41 100644 --- a/unused/com/stevesoft/pat/Bracket.java +++ b/unused/com/stevesoft/pat/Bracket.java @@ -1,88 +1,88 @@ -// -// 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; - -import java.util.*; - -/** - * The Bracket is a form of the Or class, implements the pattern element [ ]. - */ -class Bracket extends Or -{ - boolean neg; - - Bracket(boolean n) - { - neg = n; - } - - String leftForm() - { - if (neg) - { - return "[^"; - } - else - { - return "["; - } - } - - String rightForm() - { - return "]"; - } - - String sepForm() - { - return ""; - } - - public int matchInternal(int pos, Pthings pt) - { - if (pos >= pt.src.length()) - { - return -1; - } - int r = super.matchInternal(pos, pt); - if ((neg && r < 0) || (!neg && r >= 0)) - { - return nextMatch(pos + 1, pt); - } - return -1; - } - - public patInt minChars() - { - return new patInt(1); - } - - public patInt maxChars() - { - return new patInt(1); - } - - public Or addOr(Pattern p) - { - pv = null; - v.addElement(p); - p.setParent(null); - return this; - } - - public Pattern clone1(Hashtable h) - { - Bracket b = new Bracket(neg); - b.v = new Vector(); - for (int i = 0; i < v.size(); i++) - { - b.v.addElement(((Pattern) v.elementAt(i)).clone1(h)); - } - return b; - } -}; +// +// 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; + +import java.util.*; + +/** + * The Bracket is a form of the Or class, implements the pattern element [ ]. + */ +class Bracket extends Or +{ + boolean neg; + + Bracket(boolean n) + { + neg = n; + } + + String leftForm() + { + if (neg) + { + return "[^"; + } + else + { + return "["; + } + } + + String rightForm() + { + return "]"; + } + + String sepForm() + { + return ""; + } + + public int matchInternal(int pos, Pthings pt) + { + if (pos >= pt.src.length()) + { + return -1; + } + int r = super.matchInternal(pos, pt); + if ((neg && r < 0) || (!neg && r >= 0)) + { + return nextMatch(pos + 1, pt); + } + return -1; + } + + public patInt minChars() + { + return new patInt(1); + } + + public patInt maxChars() + { + return new patInt(1); + } + + public Or addOr(Pattern p) + { + pv = null; + v.addElement(p); + p.setParent(null); + return this; + } + + public Pattern clone1(Hashtable h) + { + Bracket b = new Bracket(neg); + b.v = new Vector(); + for (int i = 0; i < v.size(); i++) + { + b.v.addElement(((Pattern) v.elementAt(i)).clone1(h)); + } + return b; + } +};