X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=bin%2Fcom%2Fstevesoft%2Fpat%2FRegexWriter.js;h=f1be88e9344267eb3bf82e443be8605769486927;hp=817515b8ce870389211903a5220a2d5d502a5562;hb=7301a2415adab88038b291fc54caeeb3a5a47a44;hpb=6154cb57a6eac3bb1344b8342495f5bb701ee921 diff --git a/bin/com/stevesoft/pat/RegexWriter.js b/bin/com/stevesoft/pat/RegexWriter.js index 817515b..f1be88e 100644 --- a/bin/com/stevesoft/pat/RegexWriter.js +++ b/bin/com/stevesoft/pat/RegexWriter.js @@ -1,134 +1,134 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["java.io.Writer", "com.stevesoft.pat.PartialBuffer", "java.lang.StringBuffer"], "com.stevesoft.pat.RegexWriter", ["com.stevesoft.pat.StringBufferLike", "com.stevesoft.pat.wrap.WriterWrap"], function () { -c$ = Clazz.decorateAsClass (function () { -this.repr = null; -this.w = null; -this.ww = null; -this.sb = null; -this.wrap = null; -this.pos = 0; -this.epos = 0; -this.interval = 128; -this.bufferSize = 2048; -this.EOLchar = '\n'; -this.max_lines = 2; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "RegexWriter", java.io.Writer); -Clazz.prepareFields (c$, function () { -this.sb = new StringBuffer (); -this.wrap = new com.stevesoft.pat.PartialBuffer (this.sb); -}); -Clazz.makeConstructor (c$, -function (t, w) { -Clazz.superConstructor (this, com.stevesoft.pat.RegexWriter, []); -this.w = w; -this.ww = new com.stevesoft.pat.wrap.WriterWrap (w); -this.repr = t.getReplacer (); -this.repr.setBuffer ( new com.stevesoft.pat.StringBufferLike (this.ww)); -this.repr.setSource (this.wrap); -}, "com.stevesoft.pat.Transformer,java.io.Writer"); -Clazz.makeConstructor (c$, -function (r, w) { -Clazz.superConstructor (this, com.stevesoft.pat.RegexWriter, []); -this.w = w; -this.ww = new com.stevesoft.pat.wrap.WriterWrap (w); -this.repr = r.getReplacer (); -this.repr.setBuffer ( new com.stevesoft.pat.StringBufferLike (this.ww)); -this.repr.setSource (this.wrap); -}, "com.stevesoft.pat.Regex,java.io.Writer"); -Clazz.defineMethod (c$, "getEOLchar", -function () { -return this.EOLchar; -}); -Clazz.defineMethod (c$, "setEOLchar", -function (c) { -this.EOLchar = c; -}, "~S"); -Clazz.defineMethod (c$, "getMaxLines", -function () { -return this.max_lines; -}); -Clazz.defineMethod (c$, "setMaxLines", -function (ml) { -this.max_lines = ml; -}, "~N"); -Clazz.defineMethod (c$, "write", -function () { -var rex = this.repr.getRegex (); -var eposOld = this.epos; -if (rex.matchAtLike (this.wrap, this.epos) && !this.wrap.overRun) { -while (this.pos < this.epos) { -this.w.write (this.sb.charCodeAt (this.pos++)); -} -var to = rex.matchedTo (); -this.repr.setPos (to); -this.repr.apply (rex, rex.getReplaceRule ()); -this.epos = this.pos = to; -if (this.epos == eposOld && this.epos < this.sb.length ()) { -this.epos++; -}} else if (!this.wrap.overRun && this.epos < this.sb.length ()) { -this.epos++; -}while (this.pos < this.epos) { -this.w.write (this.sb.charCodeAt (this.pos++)); -} -if (this.epos == this.sb.length ()) { -this.sb.setLength (1); -this.pos = this.epos = 1; -} else if (this.pos > this.bufferSize) { -for (var i = this.bufferSize; i < this.sb.length (); i++) { -this.sb.setCharAt (i - this.bufferSize, this.sb.charAt (i)); -} -this.pos -= this.bufferSize; -this.epos -= this.bufferSize; -this.sb.setLength (this.sb.length () - this.bufferSize); -}}); -Clazz.defineMethod (c$, "write", -function (ca, b, n) { -var m = b + n; -for (var i = b; i < m; i++) { -this.sb.append (ca[i]); -if (this.sb.length () % this.interval == this.interval - 1) { -this.wrap.overRun = false; -while (this.epos + this.interval < this.sb.length () && !this.wrap.overRun) { -this.write (); -} -}} -}, "~A,~N,~N"); -Clazz.overrideMethod (c$, "flush", -function () { -}); -Clazz.defineMethod (c$, "close", -function () { -this.wrap.allowOverRun = false; -this.wrap.overRun = false; -while (this.epos < this.sb.length ()) { -this.write (); -} -this.write (); -this.w.close (); -}); -Clazz.defineMethod (c$, "length", -function () { -return this.sb.length (); -}); -Clazz.defineMethod (c$, "charAt", -function (i) { -return this.sb.charAt (i); -}, "~N"); -Clazz.defineMethod (c$, "setInterval", -function (i) { -this.interval = i; -}, "~N"); -Clazz.defineMethod (c$, "getInterval", -function () { -return this.interval; -}); -Clazz.defineMethod (c$, "getBufferSize", -function () { -return this.bufferSize; -}); -Clazz.defineMethod (c$, "setBufferSize", -function (i) { -this.bufferSize = i; -}, "~N"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["java.io.Writer", "com.stevesoft.pat.PartialBuffer", "java.lang.StringBuffer"], "com.stevesoft.pat.RegexWriter", ["com.stevesoft.pat.StringBufferLike", "com.stevesoft.pat.wrap.WriterWrap"], function () { +c$ = Clazz.decorateAsClass (function () { +this.repr = null; +this.w = null; +this.ww = null; +this.sb = null; +this.wrap = null; +this.pos = 0; +this.epos = 0; +this.interval = 128; +this.bufferSize = 2048; +this.EOLchar = '\n'; +this.max_lines = 2; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "RegexWriter", java.io.Writer); +Clazz.prepareFields (c$, function () { +this.sb = new StringBuffer (); +this.wrap = new com.stevesoft.pat.PartialBuffer (this.sb); +}); +Clazz.makeConstructor (c$, +function (t, w) { +Clazz.superConstructor (this, com.stevesoft.pat.RegexWriter, []); +this.w = w; +this.ww = new com.stevesoft.pat.wrap.WriterWrap (w); +this.repr = t.getReplacer (); +this.repr.setBuffer ( new com.stevesoft.pat.StringBufferLike (this.ww)); +this.repr.setSource (this.wrap); +}, "com.stevesoft.pat.Transformer,java.io.Writer"); +Clazz.makeConstructor (c$, +function (r, w) { +Clazz.superConstructor (this, com.stevesoft.pat.RegexWriter, []); +this.w = w; +this.ww = new com.stevesoft.pat.wrap.WriterWrap (w); +this.repr = r.getReplacer (); +this.repr.setBuffer ( new com.stevesoft.pat.StringBufferLike (this.ww)); +this.repr.setSource (this.wrap); +}, "com.stevesoft.pat.Regex,java.io.Writer"); +Clazz.defineMethod (c$, "getEOLchar", +function () { +return this.EOLchar; +}); +Clazz.defineMethod (c$, "setEOLchar", +function (c) { +this.EOLchar = c; +}, "~S"); +Clazz.defineMethod (c$, "getMaxLines", +function () { +return this.max_lines; +}); +Clazz.defineMethod (c$, "setMaxLines", +function (ml) { +this.max_lines = ml; +}, "~N"); +Clazz.defineMethod (c$, "write", +function () { +var rex = this.repr.getRegex (); +var eposOld = this.epos; +if (rex.matchAtLike (this.wrap, this.epos) && !this.wrap.overRun) { +while (this.pos < this.epos) { +this.w.write (this.sb.charCodeAt (this.pos++)); +} +var to = rex.matchedTo (); +this.repr.setPos (to); +this.repr.apply (rex, rex.getReplaceRule ()); +this.epos = this.pos = to; +if (this.epos == eposOld && this.epos < this.sb.length ()) { +this.epos++; +}} else if (!this.wrap.overRun && this.epos < this.sb.length ()) { +this.epos++; +}while (this.pos < this.epos) { +this.w.write (this.sb.charCodeAt (this.pos++)); +} +if (this.epos == this.sb.length ()) { +this.sb.setLength (1); +this.pos = this.epos = 1; +} else if (this.pos > this.bufferSize) { +for (var i = this.bufferSize; i < this.sb.length (); i++) { +this.sb.setCharAt (i - this.bufferSize, this.sb.charAt (i)); +} +this.pos -= this.bufferSize; +this.epos -= this.bufferSize; +this.sb.setLength (this.sb.length () - this.bufferSize); +}}); +Clazz.defineMethod (c$, "write", +function (ca, b, n) { +var m = b + n; +for (var i = b; i < m; i++) { +this.sb.append (ca[i]); +if (this.sb.length () % this.interval == this.interval - 1) { +this.wrap.overRun = false; +while (this.epos + this.interval < this.sb.length () && !this.wrap.overRun) { +this.write (); +} +}} +}, "~A,~N,~N"); +Clazz.overrideMethod (c$, "flush", +function () { +}); +Clazz.defineMethod (c$, "close", +function () { +this.wrap.allowOverRun = false; +this.wrap.overRun = false; +while (this.epos < this.sb.length ()) { +this.write (); +} +this.write (); +this.w.close (); +}); +Clazz.defineMethod (c$, "length", +function () { +return this.sb.length (); +}); +Clazz.defineMethod (c$, "charAt", +function (i) { +return this.sb.charAt (i); +}, "~N"); +Clazz.defineMethod (c$, "setInterval", +function (i) { +this.interval = i; +}, "~N"); +Clazz.defineMethod (c$, "getInterval", +function () { +return this.interval; +}); +Clazz.defineMethod (c$, "getBufferSize", +function () { +return this.bufferSize; +}); +Clazz.defineMethod (c$, "setBufferSize", +function (i) { +this.bufferSize = i; +}, "~N"); +});