Provides a buffer for writing formatted output files.<q ref="core.gml:Object">Object</q>The CodeWriter object is typically used to create a package of formatted files according to:
<ol><li>Create a new CodeWriter for the files package </li><li>Set the desired formatting style using the various CodeWriter settings </li><li>Add new files and folders using the <q ref="core.dev:createFile">createFile</q> and <q ref="core.dev:createFolder">createFolder</q> methods </li><li>Add content to the current file using the various addXXX, beginXXX and endXXX methods </li><li>Content is usually written serially to the last created file. To write in random access order, use the <q ref="core.dev:getBookmark">getBookmark</q>, <q ref="core.dev:moveToBookmark">moveToBookmark</q> and <q ref="core.dev:moveToFile">moveToFile</q> methods </li><li>To report errors resp. warnings to the errors log while writing, use the <q ref="core.dev:error">error</q> resp. <q ref="core.dev:warning">warning</q> methods </li><li>Once all content has been written, call the <q ref="core.dev:serialize">serialize</q> method </li><li>Use the <q ref="core.dev:getRootFolder">getRootFolder</q>, <q ref="core.dev:getSubFiles">getSubFiles</q>, or <q ref="core.dev:getAllFiles">getAllFiles</q> to navigate through the serialized files </li><li>Use the <q ref="core.dev:getFileText">getFileText</q> or <q ref="core.dev:getFileXml">getFileXml</q> to retrieve the content of the serialized files </li></ol>
In addition, the CodeWriter implements also the <q ref="core.lib:TreeView!provider">TreeProvider</q> interface,
and thus can be bound directly to the <q ref="core.lib:TreeView">TreeView</q> component.(c) SAP AG 2003-2006. All rights reserved.
CodeWriter constructor.The package name.The settings object (for overriding default CodeWriter settings).
Represents a <q ref="core.dev:CodeWriter">CodeWriter</q> error.The GML_ERROR structure is made of:
<table class="BOTH"><tr><td class="H V">Name </td><td class=H>Type </td><td class=H>Description </td></tr><tr><td class=V>type </td><td>String </td><td>The error type (E=Error, W=Warning) </td></tr><tr><td class=V>msg </td><td>String </td><td>The error message </td></tr><tr><td class=V>obj </td><td><q ref="core.gml:GmlObject">GmlObject</q> </td><td>Optional. The GML element associated with the error </td></tr><tr><td class=V>unit </td><td><q ref="core.gml:GmlObject">GmlObject</q> </td><td>Optional. The GML unit that contains the error </td></tr></table>
Represents a <q ref="core.dev:CodeWriter">CodeWriter</q> file.The GML_FILE structure is made of:
<table class="BOTH"><tr><td class="H V">Name </td><td class=H>Type </td><td class=H>Description </td></tr><tr><td class=V>id </td><td>String </td><td>The file id </td></tr><tr><td class=V>name </td><td>String </td><td>The file name </td></tr><tr><td class=V>path </td><td>String </td><td>The file absolute path </td></tr><tr><td class=V>type </td><td>String </td><td>The file type (extension) </td></tr><tr><td class=V>hint </td><td>String </td><td>The file short description </td></tr><tr><td class=V>icon </td><td>String </td><td>The file icon </td></tr><tr><td class=V>text </td><td>String </td><td>The file text (available after the file has been serialized) </td></tr><tr><td class=V>xml </td><td>XmlDocument </td><td>The file xml document (applies only to xml files; available after the file has been serialized) </td></tr><tr><td class=V>isFolder </td><td>Boolean </td><td>Indicates whether the file is a folder (readonly) </td></tr><tr><td class=V>isCode </td><td>Boolean </td><td>Indicates whether the file is a code file (readonly) </td></tr><tr><td class=V>isXml </td><td>Boolean </td><td>Indicates whether the file is an xml file (readonly) </td></tr><tr><td class=V>isImage </td><td>Boolean </td><td>Indicates whether the file is an image file (readonly) </td></tr></table>
Creates a new file under the specified folder.The parent folder in which the new file should be added.The new file name.The new file type (e.g., folder, txt, js, java, htm, xml, etc.).A short description of the new file.Display icon for the new file. If omitted, the icon will be derived from the file's type.A numeric value used for controlling the display order of the new file within its parent folder.The newly created file.
Creates a new folder.The parent folder in which the new folder should be added.The new folder name.A short description of the new folder.Display icon for the new folder. If omitted, the default folder icon will be used.A numeric value used for controlling the display order of the new folder within its parent folder.The newly created folder.
Gets a bookmark object that represents the current position of the CodeWriter cursor.The bookmark object.
Moves the CodeWriter cursor to a previously saved bookmark.The file bookmark to open.
Moves the CodeWriter cursor to the end of the specified file.The absolute path name (including file name).The parent folder.The file name relative to the parent folder (including extension).The file handle.
Removes the specified file/folder.The file/folder to remove.When a folder is removed then its contained files/folders are removed as well (recursively).
Serializes all files in the CodeWriter.<ul><li>The CodeWriter must be serialized to make the files contents available in text representation. </li><li>This method is typically invoked after the last write operation on the CodeWriter. </li></ul>
Adds one or more lines to the end of the current block.The lines to add (if omitted, an empty line will be added).
Begins a new block under the current block.The block header line.The new block.<ul><li>Upon completion the current block is set to the newly created block </li><li>A call to <q ref="core.dev:CodeWriter!beginBlock">beginBlock</q> must be subsequently followed by a matching call to <q ref="core.dev:CodeWriter!endBlock">endBlock</q> </li></ul><q ref="core.dev:CodeWriter!endBlock">endBlock</q>
Ends the current block.The parent block (parent of the closed block).<ul><li>Upon completion the current block is set to the parent block </li><li>A call to <q ref="core.dev:CodeWriter!endBlock">endBlock</q> should match a previous call to <q ref="core.dev:CodeWriter!beginBlock">beginBlock</q> </li></ul><q ref="core.dev:CodeWriter!beginBlock">beginBlock</q>
Adds a <code>case</code> clause to a <code>switch</code> block.The <code>case</code> condition (if omitted, the <code>default</code> case will be added).<ul><li>The <q ref="core.dev:CodeWriter!beginCase">beginCase</q> method must be called between a matching pair of <q ref="core.dev:CodeWriter!beginSwitch">beginSwitch</q> and <q ref="core.dev:CodeWriter!endSwitch">endSwitch</q> calls. </li><li>The <code>cond</code> parameter is required in all but the last <q ref="core.dev:CodeWriter!beginCase">beginCase</q> call within the same <code>switch</code> block. </li></ul><q ref="core.dev:CodeWriter!beginSwitch">beginSwitch</q> | <q ref="core.dev:CodeWriter!endSwitch">endSwitch</q>
Adds a <code>catch</code> clause to a <code>try</code> block.The <code>catch</code> expression.<ul><li>The <q ref="core.dev:CodeWriter!beginCatch">beginCatch</q> method must be called between a matching pair of <q ref="core.dev:CodeWriter!beginTry">beginTry</q> and <q ref="core.dev:CodeWriter!endTry">endTry</q> calls. </li></ul><q ref="core.dev:CodeWriter!beginTry">beginTry</q> | <q ref="core.dev:CodeWriter!endTry">endTry</q>
Begins a <code>do</code> block under the current block.The <code>do</code> condition.The new <code>do</code> block.A call to <q ref="core.dev:CodeWriter!beginDo">beginDo</q> must be subsequently followed by a matching call to <q ref="core.dev:CodeWriter!endDo">endDo</q>
<h2>Sample</h2>
<pre>
<b>source:</b>
out.beginDo('i < 10');
out.add('print(i);');
out.endDo();
<b>output:</b>
do {
print(i);
} while (i < 10);
</pre><q ref="core.dev:CodeWriter!endDo">endDo</q>
Adds an <code>else</code> clause to an <code>if</code> block.The <code>else</code> condition.<ul><li>The <q ref="core.dev:CodeWriter!beginElse">beginElse</q> method must be called between a matching pair of <q ref="core.dev:CodeWriter!beginIf">beginIf</q> and <q ref="core.dev:CodeWriter!endIf">endIf</q> calls. </li><li>The <code>cond</code> parameter is required in all but the last <q ref="core.dev:CodeWriter!beginElse">beginElse</q> call within the same <code>if</code> block. </li></ul><q ref="core.dev:CodeWriter!beginIf">beginIf</q> | <q ref="core.dev:CodeWriter!endIf">endIf</q>
Begins a <code>for</code> block under the current block.The <code>for</code> condition.The new <code>for</code> block.<ul><li>A call to <q ref="core.dev:CodeWriter!beginFor">beginFor</q> must be subsequently followed by a matching call to <q ref="core.dev:CodeWriter!endFor">endFor</q> </li></ul>
<h2>Sample</h2>
<pre>
<b>source:</b>
out.beginFor('var i=0; i<10; i++');
out.add('print(i);');
out.endFor();
<b>output:</b>
for (var i=0; i<10; i++) {
print(i);
}
</pre><q ref="core.dev:CodeWriter!endFor">endFor</q>
Begins an <code>if</code> block under the current block.The <code>if</code> condition.The new <code>if</code> block.<ul><li>A call to <q ref="core.dev:CodeWriter!beginIf">beginIf</q> must be subsequently followed by a matching call to <q ref="core.dev:CodeWriter!endIf">endIf</q> </li><li>Between the <q ref="core.dev:CodeWriter!beginIf">beginIf</q> and matching <q ref="core.dev:CodeWriter!endIf">endIf</q> calls, the <q ref="core.dev:CodeWriter!beginElse">beginElse</q> method can be called zero or more times </li></ul>
<h2>Sample</h2>
<pre>
<b>source:</b>
out.beginIf('a < 0');
out.add('print("negative")');
out.beginElse('a > 0');
out.add('print("positive")');
out.beginElse();
out.add('print("zero")');
out.endIf();
<b>output:</b>
if (a < 0) {
print("negative");
} else if (a < 10) {
print("positive");
} else if (a < 10) {
print("zero");
}
</pre><q ref="core.dev:CodeWriter!beginElse">beginElse</q> | <q ref="core.dev:CodeWriter!endIf">endIf</q>
Begins a <code>switch</code> block under the current block.The <code>switch</code> expression.The new <code>switch</code> block.<ul><li>A call to <q ref="core.dev:CodeWriter!beginSwitch">beginSwitch</q> must be subsequently followed by a matching call to <q ref="core.dev:CodeWriter!endSwitch">endSwitch</q> </li><li>Between the <q ref="core.dev:CodeWriter!beginSwitch">beginSwitch</q> and matching <q ref="core.dev:CodeWriter!endSwitch">endSwitch</q> calls, the <q ref="core.dev:CodeWriter!beginCase">beginCase</q> method can be called one or more times </li></ul>
<h2>Sample</h2>
<pre>
<b>source:</b>
out.beginSwitch('type');
out.beginCase('A');
out.add('break;');
out.add();
out.beginCase('B');
out.add('break;');
out.add();
out.beginCase();
out.add('break;');
out.endSwitch();
<b>output:</b>
switch (type) {
case 'A':
break;
case 'B':
break;
default:
break;
}
</pre><q ref="core.dev:CodeWriter!beginCase">beginCase</q> | <q ref="core.dev:CodeWriter!endSwitch">endSwitch</q>
Begins a <code>try</code> block under the current block.The new <code>try</code> block.<ul><li>A call to <q ref="core.dev:CodeWriter!beginTry">beginTry</q> must be subsequently followed by a matching call to <q ref="core.dev:CodeWriter!endTry">endTry</q> </li><li>Between the <q ref="core.dev:CodeWriter!beginTry">beginTry</q> and matching <q ref="core.dev:CodeWriter!endTry">endTry</q> calls, the <q ref="core.dev:CodeWriter!beginCatch">beginCatch</q> method can be called one or more times </li></ul>
<h2>Sample</h2>
<pre>
<b>source:</b>
out.beginTry();
out.add('...');
out.beginCatch('e');
out.add('...');
out.endTry();
<b>output:</b>
try {
...
} catch (e) {
...
}
</pre><q ref="core.dev:CodeWriter!beginCatch">beginCatch</q> | <q ref="core.dev:CodeWriter!endTry">endTry</q>
Begins a <code>while</code> block under the current block.The <code>while</code> condition.The new <code>while</code> block.A call to <q ref="core.dev:CodeWriter!beginWhile">beginWhile</q> must be subsequently followed by a matching call to <q ref="core.dev:CodeWriter!endWhile">endWhile</q>
<h2>Sample</h2>
<pre>
<b>source:</b>
out.beginWhile('i < 10');
out.add('print(i);');
out.endWhile();
<b>output:</b>
while (i < 10) {
print(i);
}
</pre><q ref="core.dev:CodeWriter!endWhile">endWhile</q>
Ends the current <code>do</code> block.The parent block (parent of the closed <code>do</code> block).A call to <q ref="core.dev:CodeWriter!endDo">endDo</q> should match a previous call to <q ref="core.dev:CodeWriter!beginDo">beginDo</q><q ref="core.dev:CodeWriter!beginDo">beginDo</q>
Ends the current <code>for</code> block.The parent block (parent of the closed <code>for</code> block).A call to <q ref="core.dev:CodeWriter!endFor">endFor</q> should match a previous call to <q ref="core.dev:CodeWriter!beginFor">beginFor</q><q ref="core.dev:CodeWriter!beginFor">beginFor</q>
Ends the current <code>if</code> block.The parent block (parent of the closed <code>if</code> block).A call to <q ref="core.dev:CodeWriter!endIf">endIf</q> should match a previous call to <q ref="core.dev:CodeWriter!beginIf">beginIf</q><q ref="core.dev:CodeWriter!beginIf">beginIf</q> | <q ref="core.dev:CodeWriter!beginElse">beginElse</q>
Ends the current <code>switch</code> block.The parent block (parent of the closed <code>switch</code> block).A call to <q ref="core.dev:CodeWriter!endSwitch">endSwitch</q> should match a previous call to <q ref="core.dev:CodeWriter!beginSwitch">beginSwitch</q><q ref="core.dev:CodeWriter!beginSwitch">beginSwitch</q> | <q ref="core.dev:CodeWriter!beginCase">beginCase</q>
Ends the current <code>try</code> block.The parent block (parent of the closed <code>try</code> block).A call to <q ref="core.dev:CodeWriter!endTry">endTry</q> should match a previous call to <q ref="core.dev:CodeWriter!beginTry">beginTry</q><q ref="core.dev:CodeWriter!beginTry">beginTry</q> | <q ref="core.dev:CodeWriter!beginCatch">beginCatch</q>
Ends the current <code>while</code> block.The parent block (parent of the closed <code>while</code> block).A call to <q ref="core.dev:CodeWriter!endWhile">endWhile</q> should match a previous call to <q ref="core.dev:CodeWriter!beginWhile">beginWhile</q><q ref="core.dev:CodeWriter!beginWhile">beginWhile</q>
Adds a single-line <code>tag</code> (xml) at the end of the current block.The tag name.The tag attributes.The tag text.<h2>Sample</h2>
<pre>
<b>source:</b>
out.addTag('input', {id:"F1", value:100});
<b>output:</b>
<input id="F1" value="100"/>
</pre><q ref="core.dev:CodeWriter!addTag">addTag</q>
Begins a <code>cdata</code> (xml) block under the current block.The cdata tag name.The cdata tag attributes.The new <code>cdata</code> block.<ul><li>A call to <q ref="core.dev:CodeWriter!beginCData">beginCData</q> must be subsequently followed by a matching call to <q ref="core.dev:CodeWriter!endCData">endCData</q> </li></ul>
<h2>Sample</h2>
<pre>
<b>source:</b>
out.beginCData('script', {language:"JavaScript"});
out.add('var a=0;');
out.add('a += 1;');
out.endCData();
<b>output:</b>
<script language="JavaScript"><![CDATA[
var a=0;
a = a+1;
]]></script>
</pre><q ref="core.dev:CodeWriter!endCData">endCData</q>
Begins a <code>tag</code> (xml) block under the current block.The tag name.The tag attributes.The new <code>tag</code> block.<ul><li>A call to <q ref="core.dev:CodeWriter!beginTag">beginTag</q> must be subsequently followed by a matching call to <q ref="core.dev:CodeWriter!endTag">endTag</q> </li></ul>
<h2>Sample</h2>
<pre>
<b>source:</b>
out.beginTag('table', {id:"TBL1", width:100, height:100});
...
out.endTag();
<b>output:</b>
<table id="TBL1" width="100" height="100">
...
</table>
</pre><q ref="core.dev:CodeWriter!endTag">endTag</q>
Ends the current <code>cdata</code> (xml) block.The parent block (parent of the closed <code>cdata</code> block).A call to <q ref="core.dev:CodeWriter!endCData">endCData</q> should match a previous call to <q ref="core.dev:CodeWriter!beginCData">beginCData</q><q ref="core.dev:CodeWriter!beginCData">beginCData</q>
Ends the current <code>tag</code> (xml) block.The parent block (parent of the closed <code>tag</code> block).A call to <q ref="core.dev:CodeWriter!endTag">endTag</q> should match a previous call to <q ref="core.dev:CodeWriter!beginTag">beginTag</q><q ref="core.dev:CodeWriter!beginTag">beginTag</q>
Gets the total number of folders/files.
Gets the list of all files/folders in the CodeWriter.The files list.
Gets a specified file/folder.The absolute path name (including file name).The parent folder.The file name relative to the parent folder (including extension).The file handle.The requested file.
Gets statistics about the specified file/folder.The file/folder to query.The requested statistics.The statistics are returned in an object with the following fields: {bytesCount:Number, filesCount:Number, foldersCount:Number}.
Gets the text contents of a specified file.The file to fetch.The requested file's text contents.The CodeWriter must be serialized prior to using this method.
Gets the xml contents of a specified file.The file to fetch.The requested file's xml contents.The CodeWriter must be serialized prior to using this method.
Gets the root folder.The root folder.
Gets the list of files/folders under a given folder.The folder to fetch.The files list.
Gets the number of accumulated errors.
Gets the number of accumulated warnings.
Erases any error/warning indicators in the current diagram.
Reports an error.The error message.The GML object associated with the error.Optional hint about the error.
Gets the collection of all accumulated errors/warnings.The errors collection.
Gets the collection of all accumulated errors, grouped by unit/warnings.The errors collection.
Paints error/warning indicators next to all associated elements in the current diagram.
Reports a warning.The warning message.The GML object associated with the warning.Optional hint about the warning.
Gets the number of links.
Gets the collection of all links.The links collection.
Reports a link.The link message.The link address.Optional hint about the link.
Indicates whether opening brace of a block is placed inline or on the next line.<h2>Sample</h2>
<i class="INSET">compactBlockBraces = true</i>
<pre style="margin-top:5">
if (a < 0) {
print("negative");
}
</pre>
<i class="INSET">compactBlockBraces = false</i>
<pre style="margin-top:5">
if (a < 0)
{
print("negative");
}
</pre>
Indicates whether a block clause (e.g., Else, Catch, etc.) is placed inline or on the next line.<h2>Sample</h2>
<i class="INSET">compactBlockClauses = true</i> and <i>compactBlockBraces = true</i>
<pre style="margin-top:5">
if (a < 0) {
print("negative");
} else {
print("positive");
}
</pre>
<i class="INSET">compactBlockClauses = false</i> and <i>compactBlockBraces = true</i>
<pre style="margin-top:5">
if (a < 0) {
print("negative");
}
else {
print("positive");
}
</pre>
<i class="INSET">compactBlockClauses = false</i> and <i>compactBlockBraces = false</i>
<pre style="margin-top:5">
if (a < 0)
{
print("negative");
}
else
{
print("positive");
}
</pre>
Indicates whether one-line blocks are placed inline or enclosed in braces on separate lines.<h2>Sample</h2>
<i class="INSET">compactOneLineBlocks = true</i>
<pre style="margin-top:5">
if (a < 0) print("negative"); else print("positive");
</pre>
<i class="INSET">compactOneLineBlocks = false</i>
<pre style="margin-top:5">
if (a < 0) {
print("negative");
} else {
print("positive");
}
</pre>
Indicates whether statement terminators should be automatically added to the end of lines in code blocks.<h2>Sample</h2>
<i class="INSET">completeStatements = true</i>
<pre style="margin-top:5">
function (a,b) {
var c;
c = a + b;
print(c);
}
</pre>
<i class="INSET">completeStatements = false</i>
<pre style="margin-top:5">
function (a,b) {
var c
c = a + b
print(c)
}
</pre>
Indicates whether block contents are indented one level to the right of the block statement.<h2>Sample</h2>
<i class="INSET">indentBlockContents = true</i>
<pre style="margin-top:5">
function (a, b) {
if (a < b) {
print("a < b");
} else {
print("a > b");
}
}
</pre>
<i class="INSET">indentBlockContents = false</i>
<pre style="margin-top:5">
function (a, b) {
if (a < b) {
print("a < b");
} else {
print("a > b");
}
}
</pre>
Indicates whether case contents are indented one level to the right of the case labels.<h2>Sample</h2>
<i class="INSET">indentCaseContents = true</i>
<pre style="margin-top:5">
switch (type) {
case 'A':
print("A");
break;
case 'B':
print("B");
break;
default:
print("X");
break;
}
</pre>
<i class="INSET">indentCaseContents = false</i>
<pre style="margin-top:5">
switch (type) {
case 'A':
print("A");
break;
case 'B':
print("B");
break;
default:
print("X");
break;
}
</pre>
Indicates whether to insert spacing between adjacent case clauses.<h2>Sample</h2>
<i class="INSET">insertCaseSpacing = true</i>
<pre style="margin-top:5">
switch (type) {
case 'A':
print("A");
break;
case 'B':
print("B");
break;
default:
print("X");
break;
}
</pre>
<i class="INSET">insertCaseSpacing = false</i>
<pre style="margin-top:5">
switch (type) {
case 'A':
print("A");
break;
case 'B':
print("B");
break;
default:
print("X");
break;
}
</pre>
Gets or sets the newline characters sequence.
Gets or sets the path separator character.
Gets or sets the tab size (number of spaces).