org.netbeans.modules.editor.indent/2 1.15.0

org.netbeans.modules.editor.indent.api
Class Reformat

java.lang.Object
  extended by org.netbeans.modules.editor.indent.api.Reformat

public final class Reformat
extends Object

Reformatting of a block of code in a document.
The following pattern should be used:

 reformat.lock();
 try {
     doc.atomicLock();
     try {
         reformat.reformat(...);
     } finally {
         doc.atomicUnlock();
     }
 } finally {
     reformat.unlock();
 }
 


Method Summary
static Reformat get(Document doc)
          Get the reformatting for the given document.
 void lock()
          Clients should call this method before acquiring of document's write lock.
 void reformat(int startOffset, int endOffset)
          Reformat a given range of code in the given document.
 void unlock()
          Clients should call this method after releasing of document's write lock.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

get

public static Reformat get(Document doc)
Get the reformatting for the given document.

Parameters:
doc - non-null document.
Returns:
non-null reformat object.

lock

public void lock()
Clients should call this method before acquiring of document's write lock.
The following pattern should be used:
 reformat.lock();
 try {
     doc.atomicLock();
     try {
         reformat.reformat(...);
     } finally {
         doc.atomicUnlock();
     }
 } finally {
     reformat.unlock();
 }
 


unlock

public void unlock()
Clients should call this method after releasing of document's write lock.
The following pattern should be used:
 reformat.lock();
 try {
     doc.atomicLock();
     try {
         reformat.reformat(...);
     } finally {
         doc.atomicUnlock();
     }
 } finally {
     reformat.unlock();
 }
 


reformat

public void reformat(int startOffset,
                     int endOffset)
              throws BadLocationException
Reformat a given range of code in the given document.
It includes possible fixing of indentation and possible code beautification dependent on the implementation of the reformatter.

If the reformatter implementation is not available the reindentation will be performed (i.e. just the line indentation will be fixed) as a closest match.

Parameters:
startOffset - start offset of the area to be reformatted.
endOffset - end offset of the area to be reformatted.
Throws:
BadLocationException

org.netbeans.modules.editor.indent/2 1.15.0

Built on November 22 2009.  |  Portions Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.