Java Doc for TextEdit.java in  » IDE-Eclipse » text » org » eclipse » text » edits » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » text » org.eclipse.text.edits 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.eclipse.text.edits.TextEdit

All known Subclasses:   org.eclipse.text.edits.CopyTargetEdit,  org.eclipse.text.edits.ReplaceEdit,  org.eclipse.text.edits.UndoEdit,  org.eclipse.text.edits.DeleteEdit,  org.eclipse.text.edits.CopyingRangeMarker,  org.eclipse.text.edits.RangeMarker,  org.eclipse.text.edits.MoveSourceEdit,  org.eclipse.text.edits.CopySourceEdit,  org.eclipse.text.edits.MoveTargetEdit,  org.eclipse.text.edits.InsertEdit,  org.eclipse.text.edits.MultiTextEdit,
TextEdit
abstract public class TextEdit (Code)
A text edit describes an elementary text manipulation operation. Edits are executed by applying them to a document (e.g. an instance of IDocument ).

Text edits form a tree. Clients can navigate the tree upwards, from child to parent, as well as downwards. Newly created edits are un-parented. New edits are added to the tree by calling one of the add methods on a parent edit.

An edit tree is well formed in the following sense:

  • a parent edit covers all its children
  • children don't overlap
  • an edit with length 0 can't have any children
Any manipulation of the tree that violates one of the above requirements results in a MalformedTreeException.

Insert edits are represented by an edit of length 0. If more than one insert edit exists at the same offset then the edits are executed in the order in which they have been added to a parent. The following code example:

 IDocument document= new Document("org");
 MultiTextEdit edit= new MultiTextEdit();
 edit.addChild(new InsertEdit(0, "www."));
 edit.addChild(new InsertEdit(0, "eclipse."));
 edit.apply(document);
 
therefore results in string: "www.eclipse.org".

Text edits can be executed in a mode where the edit's region is updated to reflect the edit's position in the changed document. Region updating is enabled by default or can be requested by passing UPDATE_REGIONS to the TextEdit.apply(IDocument,int) apply(IDocument, int) method. In the above example the region of the InsertEdit(0, "eclipse.") edit after executing the root edit is [3, 8]. If the region of an edit got deleted during change execution the region is set to [-1, -1] and the method TextEdit.isDeleted() isDeleted returns true.

This class isn't intended to be subclassed outside of the edit framework. Clients are only allowed to subclass MultiTextEdit.
since:
   3.0


Field Summary
final public static  intCREATE_UNDO
     Flags indicating that applying an edit tree to a document is supposed to create a corresponding undo edit.
final public static  intNONE
     Flags indicating that neither CREATE_UNDO nor UPDATE_REGIONS is set.
final public static  intUPDATE_REGIONS
     Flag indicating that the edit's region will be updated to reflect its position in the changed document.
 intfDelta
    

Constructor Summary
protected  TextEdit(int offset, int length)
     Create a new text edit.
protected  TextEdit(TextEdit source)
    

Method Summary
 voidaboutToBeAdded(TextEdit parent)
    
final public  voidaccept(TextEditVisitor visitor)
     Accepts the given visitor on a visit of the current edit.
abstract protected  voidaccept0(TextEditVisitor visitor)
     Accepts the given visitor on a type-specific visit of the current edit.
final protected  voidacceptChildren(TextEditVisitor visitor)
     Accepts the given visitor on the edits children.
final public  voidaddChild(TextEdit child)
     Adds the given edit child to this edit.
Parameters:
  child - the child edit to add
exception:
  MalformedTreeException - is thrown if the childedit can't be added to this edit.
final public  voidaddChildren(TextEdit[] edits)
     Adds all edits in edits to this edit.
 voidadjustLength(int delta)
     Adjusts the edits length according to the given delta.
 voidadjustOffset(int delta)
     Adjusts the edits offset according to the given delta.
final public  UndoEditapply(IDocument document, int style)
     Applies the edit tree rooted by this edit to the given document.
final public  UndoEditapply(IDocument document)
     Applies the edit tree rooted by this edit to the given document.
protected  booleancanZeroLengthCover()
     Returns true if an edit with length zero can cover another edit.
protected  voidchildDocumentUpdated()
     Hook method called when the document updating of a child edit has been completed.
protected  voidchildRegionUpdated()
     Hook method called when the region updating of a child edit has been completed.
final public  TextEditcopy()
     Creates a deep copy of the edit tree rooted at this edit.
public  booleancovers(TextEdit other)
     Returns true if the edit covers the given edit other.
abstract  booleandeleteChildren()
    
 voiddeleteTree()
    
 voiddispatchCheckIntegrity(TextEditProcessor processor)
    
 UndoEditdispatchPerformEdits(TextEditProcessor processor)
    
abstract protected  TextEditdoCopy()
     Creates and returns a copy of this edit.
final public  booleanequals(Object obj)
     The Edit implementation of this Object method uses object identity (==).
final public  TextEdit[]getChildren()
     Returns the edit's children.
final public  intgetChildrenSize()
     Returns the size of the managed children.
public static  IRegiongetCoverage(TextEdit[] edits)
     Returns the text range spawned by the given array of text edits. The method requires that the given array contains at least one edit.
final public  intgetExclusiveEnd()
     Returns the exclusive end position of this edit.
final public  intgetInclusiveEnd()
     Returns the inclusive end position of this edit.
public  intgetLength()
     Returns the length of the edit.
public  intgetOffset()
     Returns the offset of the edit.
final public  TextEditgetParent()
     Returns the edit's parent.
final public  IRegiongetRegion()
     Returns the range that this edit is manipulating.
final public  TextEditgetRoot()
     Returns the root edit of the edit tree.
final public  booleanhasChildren()
     Returns true if this edit has children.
final public  inthashCode()
     The Edit implementation of this Object method calls uses Object#hashCode() to compute its hash code.
 voidinternalAdd(TextEdit child)
    
 ListinternalGetChildren()
    
 voidinternalMoveTree(int delta)
    
 voidinternalSetChildren(List children)
    
 voidinternalSetLength(int length)
    
 voidinternalSetOffset(int offset)
    
 voidinternalSetParent(TextEdit parent)
    
 voidinternalToString(StringBuffer buffer, int indent)
     Adds the string representation of this text edit without children information to the given string buffer.
 booleanisDefined()
     Returns whether the region of this edit is defined or not.
final public  booleanisDeleted()
     Returns whether this edit has been deleted or not.
 voidmarkAsDeleted()
     Marks the edit as deleted.
final public  voidmoveTree(int delta)
     Move all offsets in the tree by the given delta.
 voidperformConsistencyCheck(TextEditProcessor processor, IDocument document)
    
abstract  intperformDocumentUpdating(IDocument document)
    
 voidperformRegionUpdating(int accumulatedDelta, boolean delete)
    
 voidperformSourceComputation(TextEditProcessor processor, IDocument document)
    
protected  voidpostProcessCopy(TextEditCopier copier)
     This method is called on every edit of the copied tree to do some post-processing like connected an edit to a different edit in the tree.
final public  TextEditremoveChild(int index)
     Removes the edit specified by the given index from the list of children.
final public  booleanremoveChild(TextEdit child)
     Removes the first occurrence of the given child from the list of children.
final public  TextEdit[]removeChildren()
     Removes all child edits from and returns them.
public  StringtoString()
    
 inttraverseConsistencyCheck(TextEditProcessor processor, IDocument document, List sourceEdits)
     Traverses the edit tree to perform the consistency check.
 inttraverseDocumentUpdating(TextEditProcessor processor, IDocument document)
    
 inttraverseRegionUpdating(TextEditProcessor processor, IDocument document, int accumulatedDelta, boolean delete)
    
 voidtraverseSourceComputation(TextEditProcessor processor, IDocument document)
    

Field Detail
CREATE_UNDO
final public static int CREATE_UNDO(Code)
Flags indicating that applying an edit tree to a document is supposed to create a corresponding undo edit. If not specified null is returned from method apply.



NONE
final public static int NONE(Code)
Flags indicating that neither CREATE_UNDO nor UPDATE_REGIONS is set.



UPDATE_REGIONS
final public static int UPDATE_REGIONS(Code)
Flag indicating that the edit's region will be updated to reflect its position in the changed document. If not specified when applying an edit tree to a document the edit's region will be arbitrary. It is even not guaranteed that the tree is still well formed.



fDelta
int fDelta(Code)




Constructor Detail
TextEdit
protected TextEdit(int offset, int length)(Code)
Create a new text edit. Parent is initialized to null and the edit doesn't have any children.
Parameters:
  offset - the edit's offset
Parameters:
  length - the edit's length



TextEdit
protected TextEdit(TextEdit source)(Code)
Copy constructor
Parameters:
  source - the source to copy form




Method Detail
aboutToBeAdded
void aboutToBeAdded(TextEdit parent)(Code)



accept
final public void accept(TextEditVisitor visitor)(Code)
Accepts the given visitor on a visit of the current edit.
Parameters:
  visitor - the visitor object
exception:
  IllegalArgumentException - if the visitor is null



accept0
abstract protected void accept0(TextEditVisitor visitor)(Code)
Accepts the given visitor on a type-specific visit of the current edit. This method must be implemented in all concrete text edits.

General template for implementation on each concrete TextEdit class:

 
 boolean visitChildren= visitor.visit(this);
 if (visitChildren) {
 acceptChildren(visitor);
 }
 
 
Note that the caller (accept) takes care of invoking visitor.preVisit(this) and visitor.postVisit(this).


Parameters:
  visitor - the visitor object



acceptChildren
final protected void acceptChildren(TextEditVisitor visitor)(Code)
Accepts the given visitor on the edits children.

This method must be used by the concrete implementations of accept to traverse list-values properties; it encapsulates the proper handling of on-the-fly changes to the list.


Parameters:
  visitor - the visitor object



addChild
final public void addChild(TextEdit child) throws MalformedTreeException(Code)
Adds the given edit child to this edit.
Parameters:
  child - the child edit to add
exception:
  MalformedTreeException - is thrown if the childedit can't be added to this edit. This is the case if the childoverlaps with one of its siblings or if the child edit's regionisn't fully covered by this edit.



addChildren
final public void addChildren(TextEdit[] edits) throws MalformedTreeException(Code)
Adds all edits in edits to this edit.
Parameters:
  edits - the text edits to add
exception:
  MalformedTreeException - is thrown if one ofthe given edits can't be added to this edit.
See Also:   TextEdit.addChild(TextEdit)



adjustLength
void adjustLength(int delta)(Code)
Adjusts the edits length according to the given delta. This method doesn't update any children.
Parameters:
  delta - the delta of the text replace operation



adjustOffset
void adjustOffset(int delta)(Code)
Adjusts the edits offset according to the given delta. This method doesn't update any children.
Parameters:
  delta - the delta of the text replace operation



apply
final public UndoEdit apply(IDocument document, int style) throws MalformedTreeException, BadLocationException(Code)
Applies the edit tree rooted by this edit to the given document. To check if the edit tree can be applied to the document either catch MalformedTreeException or use TextEditProcessor to execute an edit tree.
Parameters:
  document - the document to be manipulated
Parameters:
  style - flags controlling the execution of the edit tree. Validflags are: CREATE_UNDO and UPDATE_REGIONS. a undo edit, if CREATE_UNDO is specified. Otherwisenull is returned.
exception:
  MalformedTreeException - is thrown if the tree isn'tin a valid state. This exception is thrown before any editis executed. So the document is still in its original state.
exception:
  BadLocationException - is thrown if one of the editsin the tree can't be executed. The state of the document isundefined if this exception is thrown.
See Also:   TextEditProcessor.performEdits



apply
final public UndoEdit apply(IDocument document) throws MalformedTreeException, BadLocationException(Code)
Applies the edit tree rooted by this edit to the given document. This method is a convenience method for apply(document, CREATE_UNDO | UPDATE_REGIONS)
Parameters:
  document - the document to which to apply this edit a undo edit, if CREATE_UNDO is specified. Otherwisenull is returned.
exception:
  MalformedTreeException - is thrown if the tree isn'tin a valid state. This exception is thrown before any editis executed. So the document is still in its original state.
exception:
  BadLocationException - is thrown if one of the editsin the tree can't be executed. The state of the document isundefined if this exception is thrown.
See Also:   TextEdit.apply(IDocument,int)



canZeroLengthCover
protected boolean canZeroLengthCover()(Code)
Returns true if an edit with length zero can cover another edit. Returns false otherwise. whether an edit of length zero can cover another edit



childDocumentUpdated
protected void childDocumentUpdated()(Code)
Hook method called when the document updating of a child edit has been completed. When a client calls TextEdit.apply(IDocument) or TextEdit.apply(IDocument,int) this method is called TextEdit.getChildrenSize() times.

May be overridden by subclasses of MultiTextEdit .
since:
   3.1




childRegionUpdated
protected void childRegionUpdated()(Code)
Hook method called when the region updating of a child edit has been completed. When a client calls TextEdit.apply(IDocument) this method is called TextEdit.getChildrenSize() times. When calling TextEdit.apply(IDocument,int) this method is called TextEdit.getChildrenSize() times, when the style parameter contains the TextEdit.UPDATE_REGIONS flag.

May be overridden by subclasses of MultiTextEdit .
since:
   3.1




copy
final public TextEdit copy()(Code)
Creates a deep copy of the edit tree rooted at this edit. a deep copy of the edit tree
See Also:   TextEdit.doCopy()



covers
public boolean covers(TextEdit other)(Code)
Returns true if the edit covers the given edit other. It is up to the concrete text edit to decide if a edit of length zero can cover another edit.
Parameters:
  other - the other edit true if the edit covers the other edit;otherwise false is returned.



deleteChildren
abstract boolean deleteChildren()(Code)



deleteTree
void deleteTree()(Code)



dispatchCheckIntegrity
void dispatchCheckIntegrity(TextEditProcessor processor) throws MalformedTreeException(Code)



dispatchPerformEdits
UndoEdit dispatchPerformEdits(TextEditProcessor processor) throws BadLocationException(Code)



doCopy
abstract protected TextEdit doCopy()(Code)
Creates and returns a copy of this edit. The copy method should be implemented in a way so that the copy can executed without causing any harm to the original edit. Implementors of this method are responsible for creating deep or shallow copies of referenced object to fulfill this requirement.

Implementers of this method should use the copy constructor Edit#Edit(Edit source) to initialize the edit part of the copy. Implementors aren't responsible to actually copy the children or to set the right parent.

This method should not be called from outside the framework. Please use copy to create a copy of a edit tree. a copy of this edit.
See Also:   TextEdit.copy()
See Also:   TextEdit.postProcessCopy(TextEditCopier)
See Also:   TextEditCopier




equals
final public boolean equals(Object obj)(Code)
The Edit implementation of this Object method uses object identity (==).
Parameters:
  obj - the other object true iff this == obj; otherwisefalse is returned
See Also:   Object.equals(java.lang.Object)



getChildren
final public TextEdit[] getChildren()(Code)
Returns the edit's children. If the edit doesn't have any children an empty array is returned. the edit's children



getChildrenSize
final public int getChildrenSize()(Code)
Returns the size of the managed children. the size of the children



getCoverage
public static IRegion getCoverage(TextEdit[] edits)(Code)
Returns the text range spawned by the given array of text edits. The method requires that the given array contains at least one edit. If all edits passed are deleted the method returns null.
Parameters:
  edits - an array of edits the text range spawned by the given array of edits ornull if all edits are marked as deleted



getExclusiveEnd
final public int getExclusiveEnd()(Code)
Returns the exclusive end position of this edit. The exclusive end position denotes the next character of the region manipulated by this edit. The returned value is the result of the following calculation:
 getOffset() + getLength();
 
the exclusive end position



getInclusiveEnd
final public int getInclusiveEnd()(Code)
Returns the inclusive end position of this edit. The inclusive end position denotes the last character of the region manipulated by this edit. The returned value is the result of the following calculation:
 getOffset() + getLength() - 1;
 
 the inclusive end position



getLength
public int getLength()(Code)
Returns the length of the edit. Returns -1 if the edit is marked as deleted. the length of the edit



getOffset
public int getOffset()(Code)
Returns the offset of the edit. An offset is a 0-based character index. Returns -1 if the edit is marked as deleted. the offset of the edit



getParent
final public TextEdit getParent()(Code)
Returns the edit's parent. The method returns null if this edit hasn't been add to another edit. the edit's parent



getRegion
final public IRegion getRegion()(Code)
Returns the range that this edit is manipulating. The returned IRegion contains the edit's offset and length at the point in time when this call is made. Any subsequent changes to the edit's offset and length aren't reflected in the returned region object.

Creating a region for a deleted edit will result in an assertion failure. the manipulated region




getRoot
final public TextEdit getRoot()(Code)
Returns the root edit of the edit tree. the root edit of the edit tree
since:
   3.1



hasChildren
final public boolean hasChildren()(Code)
Returns true if this edit has children. Otherwise false is returned. true if this edit has children; otherwisefalse is returned



hashCode
final public int hashCode()(Code)
The Edit implementation of this Object method calls uses Object#hashCode() to compute its hash code. the object's hash code value
See Also:   Object.hashCode



internalAdd
void internalAdd(TextEdit child) throws MalformedTreeException(Code)



internalGetChildren
List internalGetChildren()(Code)



internalMoveTree
void internalMoveTree(int delta)(Code)



internalSetChildren
void internalSetChildren(List children)(Code)



internalSetLength
void internalSetLength(int length)(Code)



internalSetOffset
void internalSetOffset(int offset)(Code)



internalSetParent
void internalSetParent(TextEdit parent)(Code)



internalToString
void internalToString(StringBuffer buffer, int indent)(Code)
Adds the string representation of this text edit without children information to the given string buffer.
Parameters:
  buffer - the string buffer
Parameters:
  indent - the indent level in number of spaces
since:
   3.3



isDefined
boolean isDefined()(Code)
Returns whether the region of this edit is defined or not. whether the region of this edit is defined or not
since:
   3.1



isDeleted
final public boolean isDeleted()(Code)
Returns whether this edit has been deleted or not. true if the edit has beendeleted; otherwise false is returned.



markAsDeleted
void markAsDeleted()(Code)
Marks the edit as deleted. This method doesn't update any children.



moveTree
final public void moveTree(int delta)(Code)
Move all offsets in the tree by the given delta. This node must be a root node. The resulting offsets must be greater or equal to zero.
Parameters:
  delta - the delta
since:
   3.1



performConsistencyCheck
void performConsistencyCheck(TextEditProcessor processor, IDocument document)(Code)



performDocumentUpdating
abstract int performDocumentUpdating(IDocument document) throws BadLocationException(Code)



performRegionUpdating
void performRegionUpdating(int accumulatedDelta, boolean delete)(Code)



performSourceComputation
void performSourceComputation(TextEditProcessor processor, IDocument document)(Code)



postProcessCopy
protected void postProcessCopy(TextEditCopier copier)(Code)
This method is called on every edit of the copied tree to do some post-processing like connected an edit to a different edit in the tree.

This default implementation does nothing
Parameters:
  copier - the copier that manages a map between original andcopied edit.
See Also:   TextEditCopier




removeChild
final public TextEdit removeChild(int index)(Code)
Removes the edit specified by the given index from the list of children. Returns the child edit that was removed from the list of children. The parent of the returned edit is set to null.
Parameters:
  index - the index of the edit to remove the removed edit
exception:
  IndexOutOfBoundsException - if the indexis out of range



removeChild
final public boolean removeChild(TextEdit child)(Code)
Removes the first occurrence of the given child from the list of children.
Parameters:
  child - the child to be removed true if the edit contained the givenchild; otherwise false is returned



removeChildren
final public TextEdit[] removeChildren()(Code)
Removes all child edits from and returns them. The parent of the removed edits is set to null. an array of the removed edits



toString
public String toString()(Code)



traverseConsistencyCheck
int traverseConsistencyCheck(TextEditProcessor processor, IDocument document, List sourceEdits)(Code)
Traverses the edit tree to perform the consistency check.
Parameters:
  processor - the text edit processor
Parameters:
  document - the document to be manipulated
Parameters:
  sourceEdits - the list of source edits to be performed beforethe actual tree is applied to the document the number of indirect move or copy target edit children



traverseDocumentUpdating
int traverseDocumentUpdating(TextEditProcessor processor, IDocument document) throws BadLocationException(Code)



traverseRegionUpdating
int traverseRegionUpdating(TextEditProcessor processor, IDocument document, int accumulatedDelta, boolean delete)(Code)



traverseSourceComputation
void traverseSourceComputation(TextEditProcessor processor, IDocument document)(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.