2 // This software is now distributed according to
\r
3 // the Lesser Gnu Public License. Please see
\r
4 // http://www.gnu.org/copyleft/lesser.txt for
\r
6 // -- Happy Computing!
\r
8 package com.stevesoft.pat;
\r
9 import java.util.Vector;
\r
10 import java.util.Hashtable;
\r
12 /** The Bracket is a form of the Or class,
\r
13 implements the pattern element [ ]. */
\r
14 class Bracket extends Or {
\r
16 Bracket(boolean n) { neg = n; }
\r
23 String rightForm() { return "]"; }
\r
24 String sepForm() { return ""; }
\r
25 public int matchInternal(int pos,Pthings pt) {
\r
26 if(pos >= pt.src.length()) return -1;
\r
27 int r = super.matchInternal(pos,pt);
\r
28 if((neg && r<0)||(!neg && r>=0))
\r
29 return nextMatch(pos+1,pt);
\r
32 public patInt minChars() { return new patInt(1); }
\r
33 public patInt maxChars() { return new patInt(1); }
\r
35 public Or addOr(Pattern p) {
\r
41 public Pattern clone1(Hashtable h) {
\r
42 Bracket b = new Bracket(neg);
\r
44 for(int i=0;i<v.size();i++)
\r
45 b.v.addElement( ((Pattern)v.elementAt(i)).clone1(h) );
\r