< lib/text/SLTextWriter.sleela > < SLeeLa Standard Library Definition. > < Definition: SLTextWriter -- a comprehensive buffered text-output contract for > < the text library family. > < > < SLTextWriter accumulates decoded text and flushes it to a sink. The byte/ > < stream I/O is a runtime concern, so sink writes are bridged; the in-language > < layer owns a real accumulation buffer the caller fills with (+), plus line > < and byte bookkeeping. > < * In-language: sink naming, charset selection, a real write buffer the > < caller appends to (write/writeLine/newline/indent), buffered-length and > < line counters, and pending-content inspection. > < * Bridged: open / flush / drain / close -- the real sink access; each > < returns an inspectable "text.bridge:writer::..." descriptor the > < runtime fulfils; never a faked write. > < > < only; #sleela 2.1. > > < Comments are #sleela 2.5 material; < Family: text. Native VM/OS work crosses an explicit bridge. > class SLTextWriter { < the sink name/path > String value = ""; < encoding charset > String charset = "UTF-8"; < accumulated, not-yet-flushed text (in-language) > String pending = ""; < lines written into the buffer > int lines = 0; < number of write operations > int edits = 0; < ---- configuration / lifecycle (in-language) ---------------------- > void set(String v) { value = v; } String get() { return value; } void clear() { value = ""; pending = ""; lines = 0; edits = 0; } void setCharset(String c) { charset = c; } String getCharset() { return charset; } < ---- in-language buffered writes (real; fluent) ------------------- > SLTextWriter write(String s) { pending = pending + s; edits = edits + 1; return this; } SLTextWriter writeInt(int n) { pending = pending + n; edits = edits + 1; return this; } SLTextWriter writeLine(String s) { pending = pending + s + "\n"; lines = lines + 1; edits = edits + 1; return this; } SLTextWriter newline() { pending = pending + "\n"; lines = lines + 1; edits = edits + 1; return this; } SLTextWriter space() { pending = pending + " "; edits = edits + 1; return this; } < indent(depth): write depth units of two-space indentation (real). > SLTextWriter indent(int depth) { int i = 0; while (i < depth) { pending = pending + " "; i = i + 1; } edits = edits + 1; return this; } < writeAll(parts): write every element of a String[] (real). > SLTextWriter writeAll(String[] parts) { int i = 0; int n = arrayLength(parts); while (i < n) { pending = pending + parts[i]; i = i + 1; } edits = edits + 1; return this; } < pending-content inspection (in-language). > String buffered() { return pending; } boolean hasPending() { return pending != ""; } int lineCount() { return lines; } int writeCount() { return edits; } < ---- bridged sink access (the real I/O) --------------------------- > String bridge(String op) { return "text.bridge:writer:" + op + ":" + value; } String bridgeArg(String op, String a) { return "text.bridge:writer:" + op + ":" + value + ":" + a; } String open() { return bridge("open"); } < flush(): hand the pending buffer to the runtime sink and clear it locally. > String flush() { String out = bridgeArg("flush", pending); pending = ""; return out; } String drain() { return bridgeArg("drain", pending); } < not named close(): close is reserved > String closeStream() { return bridge("close"); } < ---- introspection ------------------------------------------------- > String typeName() { return "SLeeLa.text.SLTextWriter"; } boolean available() { return true; } < SLCloneable / SLDisposable intent. > SLTextWriter copy() { SLTextWriter c = new SLTextWriter(); c.set(value); c.setCharset(charset); return c; } void dispose() { value = ""; pending = ""; lines = 0; edits = 0; } < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- > < Eleven catalogued attributes with getter/setter pairs, so a GUI, loader, > < or catalog can read and (where appropriate) override each record. > < Values are faithful to the subject's real origin where publicly known. > String metaVersion = "1.0.0"; int metaId = 7; String metaAuthor = "SLeeLa standard library"; String metaDate = "2026-10-23"; String metaCopyright = "MEARVK LLC"; String metaTrademark = "none"; String metaCorporation = "MEARVK LLC"; String metaOrigin = "International"; String metaBirthDate = "2026"; int metaScienceRating = 8; String metaNationalSchedule = "The Java Language Specification (java.io.Writer)"; String getMetaVersion() { return metaVersion; } void setMetaVersion(String v) { metaVersion = v; } int getMetaId() { return metaId; } void setMetaId(int v) { metaId = v; } String getAuthor() { return metaAuthor; } void setAuthor(String v) { metaAuthor = v; } String getDate() { return metaDate; } void setDate(String v) { metaDate = v; } String getCopyright() { return metaCopyright; } void setCopyright(String v) { metaCopyright = v; } String getTrademark() { return metaTrademark; } void setTrademark(String v) { metaTrademark = v; } String getCorporation() { return metaCorporation; } void setCorporation(String v) { metaCorporation = v; } String getOrigin() { return metaOrigin; } void setOrigin(String v) { metaOrigin = v; } String getBirthDate() { return metaBirthDate; } void setBirthDate(String v) { metaBirthDate = v; } int getScienceRating() { return metaScienceRating; } void setScienceRating(int v) { metaScienceRating = v; } String getNationalSchedule() { return metaNationalSchedule; } void setNationalSchedule(String v) { metaNationalSchedule = v; } }