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