1 Clazz.declarePackage ("com.stevesoft.pat");
2 Clazz.load (["java.util.Enumeration", "$.Vector"], "com.stevesoft.pat.RegexTokenizer", ["com.stevesoft.pat.Regex"], function () {
3 c$ = Clazz.decorateAsClass (function () {
11 Clazz.instantialize (this, arguments);
12 }, com.stevesoft.pat, "RegexTokenizer", null, java.util.Enumeration);
13 Clazz.prepareFields (c$, function () {
14 this.v = new java.util.Vector ();
15 this.vi = new java.util.Vector ();
17 Clazz.defineMethod (c$, "getMore",
19 var s = this.r.right ();
20 if (this.r.searchFrom (this.toParse, this.pos)) {
21 this.v.addElement (this.r.left ().substring (this.pos));
22 this.vi.addElement ( new Integer (this.r.matchFrom () + this.r.charsMatched ()));
23 for (var i = 0; i < this.r.numSubs (); i++) {
24 if (this.r.substring () != null) {
25 this.v.addElement (this.r.substringI (i + this.offset));
26 this.vi.addElement ( new Integer (this.r.matchFromI (i + this.offset) + this.r.charsMatchedI (i + this.offset)));
28 this.pos = this.r.matchFrom () + this.r.charsMatched ();
29 } else if (s != null) {
30 this.v.addElement (s);
32 Clazz.makeConstructor (c$,
33 function (txt, ptrn) {
35 this.r = new com.stevesoft.pat.Regex (ptrn, "");
36 this.offset = com.stevesoft.pat.Regex.BackRefOffset;
39 Clazz.makeConstructor (c$,
43 this.offset = com.stevesoft.pat.Regex.BackRefOffset;
45 }, "~S,com.stevesoft.pat.Regex");
46 Clazz.overrideMethod (c$, "nextElement",
48 if (this.count >= this.v.size ()) {
50 }return this.v.elementAt (this.count++);
52 Clazz.defineMethod (c$, "nextToken",
54 return this.nextElement ();
56 Clazz.defineMethod (c$, "nextToken",
59 this.r.compile (newpat);
61 if (Clazz.exceptionOf (r_, com.stevesoft.pat.RegSyntax)) {
66 return this.nextToken (this.r);
68 Clazz.defineMethod (c$, "nextToken",
71 if (this.vi.size () > this.count) {
72 this.pos = (this.vi.elementAt (this.count)).intValue ();
73 this.v.setSize (this.count);
74 this.vi.setSize (this.count);
76 return this.nextToken ();
77 }, "com.stevesoft.pat.Regex");
78 Clazz.overrideMethod (c$, "hasMoreElements",
80 if (this.count >= this.v.size ()) {
82 }return this.count < this.v.size ();
84 Clazz.defineMethod (c$, "hasMoreTokens",
86 return this.hasMoreElements ();
88 Clazz.defineMethod (c$, "countTokens",
90 var _count = this.count;
91 while (this.hasMoreTokens ()) {
95 return this.v.size () - this.count;
97 Clazz.defineMethod (c$, "allTokens",
100 var ret = new Array (this.v.size ());
101 this.v.copyInto (ret);