JAL-1807 includes ?j2sdebug flag and DebugJS._(msg)
[jalviewjs.git] / bin / com / stevesoft / pat / PartialBuffer.js
1 Clazz.declarePackage ("com.stevesoft.pat");
2 Clazz.load (["com.stevesoft.pat.StringLike"], "com.stevesoft.pat.PartialBuffer", ["java.lang.StringBuffer"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.off = 0;
5 this.allowOverRun = true;
6 this.overRun = false;
7 this.sb = null;
8 Clazz.instantialize (this, arguments);
9 }, com.stevesoft.pat, "PartialBuffer", null, com.stevesoft.pat.StringLike);
10 Clazz.makeConstructor (c$, 
11 function (sb) {
12 this.sb = sb;
13 }, "StringBuffer");
14 Clazz.overrideMethod (c$, "charAt", 
15 function (n) {
16 n += this.off;
17 if (n == this.sb.length ()) {
18 this.overRun = true;
19 return String.fromCharCode (0);
20 }return this.sb.charAt (n);
21 }, "~N");
22 Clazz.overrideMethod (c$, "length", 
23 function () {
24 return this.allowOverRun ? this.sb.length () + 1 : this.sb.length ();
25 });
26 Clazz.overrideMethod (c$, "indexOf", 
27 function (c) {
28 for (var i = 0; i < this.sb.length (); i++) {
29 if (this.sb.charAt (i) == c) {
30 return i;
31 }}
32 return -1;
33 }, "~S");
34 Clazz.overrideMethod (c$, "unwrap", 
35 function () {
36 return this.sb;
37 });
38 Clazz.overrideMethod (c$, "substring", 
39 function (i1, i2) {
40 var sb =  new StringBuffer (i2 - i1);
41 for (var i = i1; i < i2; i++) {
42 sb.append (this.charAt (i));
43 }
44 return sb.toString ();
45 }, "~N,~N");
46 Clazz.overrideMethod (c$, "newStringBufferLike", 
47 function () {
48 return null;
49 });
50 });