|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.wurbelizer.SourceDocument
public class SourceDocument
A SourceDocument represents the logical structure of a source file in memory.
Source documents are divided into sections, so-called SourceElements.
Each element can be manipulated independently. Especially new elements, so-called
guarded blocks, can be inserted, replaced and removed. They are identified by
a unique name, a tag, which is stored along with the section within the document.
Elements can also be addressed by their logical index (starting at 0).
| Nested Class Summary | |
|---|---|
static class |
SourceDocument.FoldType
editor folds (currently only supported for GUARDTYPE_NETBEANS |
| Constructor Summary | |
|---|---|
SourceDocument(StringBuilder text,
String name,
Properties otherProps)
Constructs a SourceDocument from a text buffer. |
|
SourceDocument(String text,
String name,
Properties otherProps)
Constructs a SourceDocument from a String. |
|
| Method Summary | |
|---|---|
void |
deleteElement(int elemNdx)
Removes an element at given index. |
int |
deleteGuarded(String guardedName)
Removes a guarded section with a given name. |
int |
deleteGuarded(String guardedName,
int startIndex)
Removes a guarded section with a given name starting at a given logical index. |
List<SourceElement> |
getElements()
Gets the list of all elements of this document. |
int |
getLineNumber(int pos)
Gets the line number for a given character position. |
String |
getPackageName()
Gets the package name of the source document. |
Properties |
getProperties()
Gets the optional properties for this document |
StringBuilder |
getText()
Gets the contents of the whole document. |
void |
insertGuarded(SourceElement.Type guardType,
SourceDocument.FoldType foldType,
String guardedName,
String str,
int elemNdx)
Inserts a guarded section by creating a new SourceElement. |
int |
replaceGuarded(SourceElement.Type guardType,
SourceDocument.FoldType foldType,
String guardedName,
String str)
Replaces a guarded section. |
void |
replaceInline(String str,
int elemNdx)
Replaces an inline wurblet section. |
void |
setText(StringBuilder text)
Sets the text of the document. |
String |
toString()
Prints the name of the document without the package name. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public SourceDocument(StringBuilder text,
String name,
Properties otherProps)
throws SourceException
text - the contents of the documentname - the name of the document (usually the filename)otherProps - optional properties for wurblets
SourceException - if parsing the document failed
public SourceDocument(String text,
String name,
Properties otherProps)
throws SourceException
String.
text - the contents of the documentname - the name of the document (usually the filename)otherProps - optional properties for wurblets
SourceException - if parsing the document failed| Method Detail |
|---|
public void insertGuarded(SourceElement.Type guardType,
SourceDocument.FoldType foldType,
String guardedName,
String str,
int elemNdx)
throws SourceException
guardType - the element typefoldType - the editor fold type (currently only supported for Netbeans), null if noneguardedName - the name of the guarded sectionstr - the text to insert (the output of the wurblet)elemNdx - the element index where to insert the new element
SourceException - if creating the element failed
public int deleteGuarded(String guardedName,
int startIndex)
guardedName - the name of the guarded section to removestartIndex - start index in elements where to start the search
public int deleteGuarded(String guardedName)
guardedName - the name of the guarded section to remove
public int replaceGuarded(SourceElement.Type guardType,
SourceDocument.FoldType foldType,
String guardedName,
String str)
throws SourceException
guardType - the element typefoldType - the editor fold type (currently only supported for Netbeans), null if noneguardedName - the name of the guarded section to replacestr - the new text
SourceException - if operation failed
public void replaceInline(String str,
int elemNdx)
throws SourceException
str - the new textelemNdx - the index of the SourceElement
SourceException - if operaton failedpublic void deleteElement(int elemNdx)
elemNdx - the index to elementspublic int getLineNumber(int pos)
pos - the character position in the document.
public String toString()
toString in class Objectpublic StringBuilder getText()
public Properties getProperties()
public String getPackageName()
public void setText(StringBuilder text)
throws SourceException
text - the contents of the document
SourceException - if parsing the contents failedpublic List<SourceElement> getElements()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||