// // 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.*; /** This class implements the (?: ... ) extended Pattern. It provides a base class from which we derive the [ ... ], ( ... ), (?! ... ), and (?= ... ) patterns. */ class Or extends Pattern { Vector v; Pattern[] pv = null; Or() { v = new Vector(); } String leftForm() { return "(?:"; } String rightForm() { return ")"; } String sepForm() { return "|"; } public Or addOr(Pattern p) { pv = null; v.addElement(p); p.setParent(this); return this; } public String toString() { int i; StringBuffer sb = new StringBuffer(); sb.append(leftForm()); if(v.size()>0) sb.append( ((Pattern)v.elementAt(0)).toString() ); for(i=1;i= 0) return r; } return -1; } public patInt minChars() { if(v.size()==0) return new patInt(0); patInt m = ((Pattern)v.elementAt(0)).countMinChars(); for(int i=1;i