-//
-// 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 allows you to match on a partial string. If the allowOverRun flag
- * is true, then the length() method returns a number 1 larger than is actually
- * contained by the class.
- * <p>
- * If one attempts to access the last character as follows:
- *
- * <pre>
- * javajs.util.SB sb = ...;
- * ...
- * PartialBuffer pb = new PartialBuffer(sb);
- * char c = pb.charAt(pb.length()-1);
- * </pre>
- *
- * then two things happen. First, a zero is returned into the variable c.
- * Second, the overRun flag is set to "true." Accessing data beyond the end of
- * the buffer is considered an "overRun" of the data.
- * <p>
- * This can be helpful in determining whether more characters are required for a
- * match to occur, as the pseudo-code below illustrates.
- *
- * <pre>
- * int i = ...;
- * Regex r = new Regex("some pattern");
- * pb.allowOverRun = true;
- * pb.overRun = true;
- * boolean result = r.matchAt(pb,i);
- * if(pb.overRun) {
- * // The result of the match is not relevant, regardless
- * // of whether result is true or false. We need to
- * // append more data to the buffer and try again.
- * ....
- * sb.append(more data);
- * }
- * </pre>
- */
-class PartialBuffer implements StringLike
-{
- int off;
-
- public boolean allowOverRun = true;
-
- public boolean overRun = false;
-
- javajs.util.SB sb;
-
- PartialBuffer(javajs.util.SB sb)
- {
- this.sb = sb;
- }
-
- public char charAt(int n)
- {
- n += off;
- if (n == sb.length())
- {
- overRun = true;
- return 0;
- }
- return sb.charAt(n);
- }
-
- public int length()
- {
- return allowOverRun ? sb.length() + 1 : sb.length();
- }
-
- public int indexOf(char c)
- {
- for (int i = 0; i < sb.length(); i++)
- {
- if (sb.charAt(i) == c)
- {
- return i;
- }
- }
- return -1;
- }
-
- public Object unwrap()
- {
- return sb;
- }
-
- public String substring(int i1, int i2)
- {
- javajs.util.SB sb = new javajs.util.SB();//(i2 - i1);
- for (int i = i1; i < i2; i++)
- {
- sb.appendC(charAt(i));
- }
- return sb.toString();
- }
-
- /** Just returns null. */
- public BasicStringBufferLike newStringBufferLike()
- {
- 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
+/**\r
+ * This class allows you to match on a partial string. If the allowOverRun flag\r
+ * is true, then the length() method returns a number 1 larger than is actually\r
+ * contained by the class.\r
+ * <p>\r
+ * If one attempts to access the last character as follows:\r
+ * \r
+ * <pre>\r
+ * javajs.util.SB sb = ...;\r
+ * ...\r
+ * PartialBuffer pb = new PartialBuffer(sb);\r
+ * char c = pb.charAt(pb.length()-1);\r
+ * </pre>\r
+ * \r
+ * then two things happen. First, a zero is returned into the variable c.\r
+ * Second, the overRun flag is set to "true." Accessing data beyond the end of\r
+ * the buffer is considered an "overRun" of the data.\r
+ * <p>\r
+ * This can be helpful in determining whether more characters are required for a\r
+ * match to occur, as the pseudo-code below illustrates.\r
+ * \r
+ * <pre>\r
+ * int i = ...;\r
+ * Regex r = new Regex("some pattern");\r
+ * pb.allowOverRun = true;\r
+ * pb.overRun = true;\r
+ * boolean result = r.matchAt(pb,i);\r
+ * if(pb.overRun) {\r
+ * // The result of the match is not relevant, regardless\r
+ * // of whether result is true or false. We need to\r
+ * // append more data to the buffer and try again.\r
+ * ....\r
+ * sb.append(more data);\r
+ * }\r
+ * </pre>\r
+ */\r
+class PartialBuffer implements StringLike\r
+{\r
+ int off;\r
+\r
+ public boolean allowOverRun = true;\r
+\r
+ public boolean overRun = false;\r
+\r
+ javajs.util.SB sb;\r
+\r
+ PartialBuffer(javajs.util.SB sb)\r
+ {\r
+ this.sb = sb;\r
+ }\r
+\r
+ public char charAt(int n)\r
+ {\r
+ n += off;\r
+ if (n == sb.length())\r
+ {\r
+ overRun = true;\r
+ return 0;\r
+ }\r
+ return sb.charAt(n);\r
+ }\r
+\r
+ public int length()\r
+ {\r
+ return allowOverRun ? sb.length() + 1 : sb.length();\r
+ }\r
+\r
+ public int indexOf(char c)\r
+ {\r
+ for (int i = 0; i < sb.length(); i++)\r
+ {\r
+ if (sb.charAt(i) == c)\r
+ {\r
+ return i;\r
+ }\r
+ }\r
+ return -1;\r
+ }\r
+\r
+ public Object unwrap()\r
+ {\r
+ return sb;\r
+ }\r
+\r
+ public String substring(int i1, int i2)\r
+ {\r
+ javajs.util.SB sb = new javajs.util.SB();//(i2 - i1);\r
+ for (int i = i1; i < i2; i++)\r
+ {\r
+ sb.appendC(charAt(i));\r
+ }\r
+ return sb.toString();\r
+ }\r
+\r
+ /** Just returns null. */\r
+ public BasicStringBufferLike newStringBufferLike()\r
+ {\r
+ return null;\r
+ }\r
+}\r