-//
-// 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.*;
-
-/** Thrown when one encounters things like [z-a] */
-class BadRangeArgs extends RegSyntax
-{
-};
-
-/**
- * Implments a subelement (ranges) of the [] pattern element. For example,
- * [a-z023] is implemented using a range and tree oneChar classes.
- *
- * @see Bracket
- * @see oneChar
- */
-class Range extends Pattern
-{
- char lo, hi, altlo, althi;
-
- boolean printBrackets = false;
-
- public String toString()
- {
- String s = protect("" + lo, PROTECT_THESE, ESC) + "-"
- + protect("" + hi, PROTECT_THESE, ESC);
- if (!printBrackets)
- {
- return s;
- }
- return "[" + s + "]";
- }
-
- Range(char loi, char hii) throws RegSyntax
- {
- lo = loi;
- hi = hii;
- oneChar o = null;
- if (lo >= hi)
- {
- // throw new BadRangeArgs();
- RegSyntaxError.endItAll("Badly formed []'s : " + lo + " >= " + hi);
- }
- o = new oneChar(lo);
- altlo = o.altc;
- o = new oneChar(hi);
- althi = o.altc;
- }
-
- public int matchInternal(int pos, Pthings pt)
- {
- if (pos >= pt.src.length())
- {
- return -1;
- }
- if (Masked(pos, pt))
- {
- return -1;
- }
- char c = pt.src.charAt(pos);
- if (lo <= c && c <= hi || (pt.ignoreCase && (altlo <= c && c <= althi)))
- {
- return nextMatch(pos + 1, pt);
- }
- return -1;
- }
-
- public patInt minChars()
- {
- return new patInt(1);
- }
-
- public patInt maxChars()
- {
- return new patInt(1);
- }
-
- public Pattern clone1(Hashtable h)
- {
- try
- {
- Range r = new Range(lo, hi);
- r.printBrackets = printBrackets;
- return r;
- } catch (RegSyntax rs)
- {
- return null;
- }
- }
-};
+//\r
+// This software is now distributed according to\r
+// the Lesser Gnu Public License. Please see\r
+// http://www.gnu.org/copyleft/lesser.txt for\r
+// the details.\r
+// -- Happy Computing!\r
+//\r
+package com.stevesoft.pat;\r
+\r
+import java.util.*;\r
+\r
+/** Thrown when one encounters things like [z-a] */\r
+class BadRangeArgs extends RegSyntax\r
+{\r
+};\r
+\r
+/**\r
+ * Implments a subelement (ranges) of the [] pattern element. For example,\r
+ * [a-z023] is implemented using a range and tree oneChar classes.\r
+ * \r
+ * @see Bracket\r
+ * @see oneChar\r
+ */\r
+class Range extends Pattern\r
+{\r
+ char lo, hi, altlo, althi;\r
+\r
+ boolean printBrackets = false;\r
+\r
+ public String toString()\r
+ {\r
+ String s = protect("" + lo, PROTECT_THESE, ESC) + "-"\r
+ + protect("" + hi, PROTECT_THESE, ESC);\r
+ if (!printBrackets)\r
+ {\r
+ return s;\r
+ }\r
+ return "[" + s + "]";\r
+ }\r
+\r
+ Range(char loi, char hii) throws RegSyntax\r
+ {\r
+ lo = loi;\r
+ hi = hii;\r
+ oneChar o = null;\r
+ if (lo >= hi)\r
+ {\r
+ // throw new BadRangeArgs();\r
+ RegSyntaxError.endItAll("Badly formed []'s : " + lo + " >= " + hi);\r
+ }\r
+ o = new oneChar(lo);\r
+ altlo = o.altc;\r
+ o = new oneChar(hi);\r
+ althi = o.altc;\r
+ }\r
+\r
+ public int matchInternal(int pos, Pthings pt)\r
+ {\r
+ if (pos >= pt.src.length())\r
+ {\r
+ return -1;\r
+ }\r
+ if (Masked(pos, pt))\r
+ {\r
+ return -1;\r
+ }\r
+ char c = pt.src.charAt(pos);\r
+ if (lo <= c && c <= hi || (pt.ignoreCase && (altlo <= c && c <= althi)))\r
+ {\r
+ return nextMatch(pos + 1, pt);\r
+ }\r
+ return -1;\r
+ }\r
+\r
+ public patInt minChars()\r
+ {\r
+ return new patInt(1);\r
+ }\r
+\r
+ public patInt maxChars()\r
+ {\r
+ return new patInt(1);\r
+ }\r
+\r
+ public Pattern clone1(Hashtable h)\r
+ {\r
+ try\r
+ {\r
+ Range r = new Range(lo, hi);\r
+ r.printBrackets = printBrackets;\r
+ return r;\r
+ } catch (RegSyntax rs)\r
+ {\r
+ return null;\r
+ }\r
+ }\r
+};\r