Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-04

oracle.jdeveloper.audit.model
Class TextFileModelAdapter

java.lang.Object
  extended by oracle.jdeveloper.audit.model.ModelAdapter
      extended by oracle.jdeveloper.audit.model.FileModelAdapter
          extended by oracle.jdeveloper.audit.model.TextFileModelAdapter
All Implemented Interfaces:
java.lang.Comparable, Located
Direct Known Subclasses:
JavaSourceModelAdapter

public abstract class TextFileModelAdapter
extends FileModelAdapter

An abstract ModelAdapter adapter which adapts a text file node.

When the node is open, this adapter tracks changes to the text buffer associated with the node and maps offsets across edits to the node. When the node is opened, this adapter attaches an observer to the text buffer.

See Also:
ModelAdapter

Field Summary
 
Fields inherited from class oracle.jdeveloper.audit.model.ModelAdapter
index, log
 
Constructor Summary
TextFileModelAdapter(ModelFactory factory, ModelType type, ContainerModelAdapter workspace, ContainerModelAdapter project, ContainerModelAdapter directory, Node node, java.net.URL url)
           
TextFileModelAdapter(ModelFactory factory, ModelType type, ContainerModelAdapter workspace, ContainerModelAdapter project, ContainerModelAdapter directory, Node node, java.net.URL url, java.lang.String primaryCollationString)
           
 
Method Summary
protected  boolean acquireReadLock(WriteLockRequestListener listener)
          Acquires a read lock for this model.
protected  void beginReadHook()
          A subclass hook invoked by ModelAdapter.beginRead() after it invokes ModelAdapter.acquireReadLock(oracle.javatools.buffer.WriteLockRequestListener).
 java.lang.String contextDescription(Location location)
          Gets a description of a location of this model.
 boolean edit(Location location)
          Edits a location in this model using an editor suitable for the model and location.
protected  void endReadHook()
          A subclass hook invoked by ModelAdapter.endRead() before it invokes ModelAdapter.releaseReadLock(oracle.javatools.buffer.WriteLockRequestListener).
 char getCharacter(int offset)
          Gets a character from this model, or 0 if no text is available.
 int getColumnOffset(int offset)
          Gets the zero-based column offset of a character offset in this model, or the character offset if this model does not have lines and columns.
protected  int getDeltaLength(int offset, int length, int version)
           
protected  int getDeltaOffset(int offset, int version)
           
 Location getFocusLocation(Location location)
          Gets the focus location for a location in this model.
 int getInitialLength()
          Gets the initial length of this model.
 java.lang.String getLine(int offset)
          Gets a line of text from this model, or null if no text is available.
 int getLineOffset(int offset)
          Gets the zero-based line offset of a character offset in this model, or 0 if this model does not have lines and columns.
 Location getLocation(int offset, int length)
          Gets a location in this model.
 java.lang.Object getRoot()
          Gets the root construct of this model.
abstract  java.lang.Object getRootImplementation()
           
 java.lang.String getText(int offset, int length)
          Gets text from this model, or null if no text is available.
 TextBuffer getTextBuffer()
          Gets the text buffer for this model.
 TextNode getTextNode()
          Gets the IDE {@link TextNode) containing this model.
 boolean isEditable(Location location)
          Gets whether a location in this model is editable.
 boolean isModifiable()
          Gets whether this model is modifiable.
 boolean isModified()
          Gets whether this model has been modified since this model adapter was created.
 boolean isModified(Location location)
          Gets whether a region of this model has been modified since this model adapter was created.
 void release()
          Releases resources used by this model.
protected  void releaseReadLock(WriteLockRequestListener listener)
          Releases a read lock for this model.
 
Methods inherited from class oracle.jdeveloper.audit.model.FileModelAdapter
compareTo, contains, getContainingAdapter, getDependency, getFileAdapter, getUrl, isFile
 
Methods inherited from class oracle.jdeveloper.audit.model.ModelAdapter
beginRead, beginRead, cancelRead, compareSiblings, contains, contains, endRead, endRead, enter, equals, exit, getAttribute, getConstruct, getConstruct, getContainedConstructs, getDirectory, getDirectoryAdapter, getElement, getElementLocations, getEndLocation, getFactory, getFocusLocation, getIdeContext, getLocation, getLocation, getLock, getNode, getPrimaryCollationKey, getProject, getProjectAdapter, getSecondaryCollationKey, getSecondaryCollationString, getShortLabel, getType, getURL, getWorkspace, getWorkspaceAdapter, icon, icon, label, label, setAttribute, summary, summary, toString, verifyReadTransaction
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextFileModelAdapter

public TextFileModelAdapter(ModelFactory factory,
                            ModelType type,
                            ContainerModelAdapter workspace,
                            ContainerModelAdapter project,
                            ContainerModelAdapter directory,
                            Node node,
                            java.net.URL url)

TextFileModelAdapter

public TextFileModelAdapter(ModelFactory factory,
                            ModelType type,
                            ContainerModelAdapter workspace,
                            ContainerModelAdapter project,
                            ContainerModelAdapter directory,
                            Node node,
                            java.net.URL url,
                            java.lang.String primaryCollationString)
Method Detail

getTextNode

public TextNode getTextNode()
Gets the IDE {@link TextNode) containing this model.


isModifiable

public boolean isModifiable()
Description copied from class: ModelAdapter
Gets whether this model is modifiable. The ModelAdapter implementation returns false.

Overrides:
isModifiable in class ModelAdapter

isModified

public boolean isModified()
Description copied from class: ModelAdapter
Gets whether this model has been modified since this model adapter was created. Note that this indicates nothing about whether this model is modified relative to its representation on disk.

Overrides:
isModified in class ModelAdapter

isModified

public boolean isModified(Location location)
Description copied from class: ModelAdapter
Gets whether a region of this model has been modified since this model adapter was created. Note that this indicates nothing about whether this region is modified relative to its representation on disk.

Overrides:
isModified in class ModelAdapter

getInitialLength

public int getInitialLength()
Description copied from class: ModelAdapter
Gets the initial length of this model. Gets Integer.MAX_VALUE if this node has not been opened. The default ModelAdapter implementation returns Integer.MAX_VALUE.

Overrides:
getInitialLength in class ModelAdapter

getLocation

public Location getLocation(int offset,
                            int length)
Description copied from class: ModelAdapter
Gets a location in this model.

Overrides:
getLocation in class ModelAdapter

getDeltaLength

protected int getDeltaLength(int offset,
                             int length,
                             int version)

getDeltaOffset

protected int getDeltaOffset(int offset,
                             int version)

acquireReadLock

protected boolean acquireReadLock(WriteLockRequestListener listener)
Acquires a read lock for this model. Invoked by ModelAdapter.beginRead() with no read transaction for this model active on the current thread. The client is assumed to be cancellable if it supplies the listener argument; non-cancellable if not. The default TextFileModelAdapter implementation is the following:
     ReadWriteLock lock = getLock();
     lock.readLock();
     return listener != null && lock.addWriteLockRequestListener(listener);
 
.

Overrides:
acquireReadLock in class ModelAdapter
Parameters:
listener - The listener to notify if a thread waits to acquire the write lock, or null if the client is not cancellable.
Returns:
whether other threads are already waiting for the write lock; always false if listener is null.

releaseReadLock

protected void releaseReadLock(WriteLockRequestListener listener)
Releases a read lock for this model. Invoked by ModelAdapter.endRead() with a read transaction for this model active on the current thread. The default TextFileModelAdapter implementation is the following:
     ReadWriteLock lock = getLock();
     if (listener != null) lock.removeWriteLockRequestListener(listener);
     lock.readUnlock();
 
.

Overrides:
releaseReadLock in class ModelAdapter
Parameters:
listener - The value given to the matching acquireReadLock(oracle.javatools.buffer.WriteLockRequestListener).

beginReadHook

protected void beginReadHook()
A subclass hook invoked by ModelAdapter.beginRead() after it invokes ModelAdapter.acquireReadLock(oracle.javatools.buffer.WriteLockRequestListener). The default ModelAdapter implementation does nothing.

The TextFileModelAdapter implementation pins the text buffer for use during the read transaction. Subclasses should not invoke this method from inside a synchronized block, on peril of deadlock!

Overrides:
beginReadHook in class ModelAdapter
See Also:
ModelAdapter.beginRead(), endReadHook()

endReadHook

protected void endReadHook()
A subclass hook invoked by ModelAdapter.endRead() before it invokes ModelAdapter.releaseReadLock(oracle.javatools.buffer.WriteLockRequestListener). The default ModelAdapter implementation does nothing. The TextFileModelAdapter implementation unpins the text buffer.

Overrides:
endReadHook in class ModelAdapter
See Also:
ModelAdapter.endRead(), beginReadHook()

getCharacter

public char getCharacter(int offset)
Description copied from class: ModelAdapter
Gets a character from this model, or 0 if no text is available. A read transaction must be active on this node. The ModelAdapter implementation returns 0.

Overrides:
getCharacter in class ModelAdapter
Parameters:
offset - The index of the character to return.

getColumnOffset

public int getColumnOffset(int offset)
Description copied from class: ModelAdapter
Gets the zero-based column offset of a character offset in this model, or the character offset if this model does not have lines and columns. A read transaction must be active on this model. The ModelAdapter implementation returns the character offset.

Overrides:
getColumnOffset in class ModelAdapter

getFocusLocation

public Location getFocusLocation(Location location)
Description copied from class: ModelAdapter
Gets the focus location for a location in this model. This is a region within the location which should be highlighted. The default ModelAdapter.getFocusLocation(java.lang.Object, oracle.jdeveloper.audit.model.Location) implementation gets the whole location. A read transaction must be active on this node.

Overrides:
getFocusLocation in class ModelAdapter
Parameters:
location - a location in this model.

getLine

public java.lang.String getLine(int offset)
Description copied from class: ModelAdapter
Gets a line of text from this model, or null if no text is available. A read transaction must be active on this node. The ModelAdapter implementation returns null.

Overrides:
getLine in class ModelAdapter
Parameters:
offset - The index of a character in the line to return.

getLineOffset

public int getLineOffset(int offset)
Description copied from class: ModelAdapter
Gets the zero-based line offset of a character offset in this model, or 0 if this model does not have lines and columns. A read transaction must be active on this node. The ModelAdapter implementation returns 0.

Overrides:
getLineOffset in class ModelAdapter

getRoot

public final java.lang.Object getRoot()
Description copied from class: ModelAdapter
Gets the root construct of this model. A read transaction must be active on this model.

Specified by:
getRoot in class ModelAdapter

getRootImplementation

public abstract java.lang.Object getRootImplementation()

getText

public java.lang.String getText(int offset,
                                int length)
Description copied from class: ModelAdapter
Gets text from this model, or null if no text is available. A read transaction must be active on this node. The ModelAdapter implementation returns null.

Overrides:
getText in class ModelAdapter
Parameters:
offset - The index of the first character to return.
length - The number of characters to return.

getTextBuffer

public TextBuffer getTextBuffer()
Gets the text buffer for this model.

A read transaction must be active for this model on the current thread.


isEditable

public boolean isEditable(Location location)
Gets whether a location in this model is editable. The default ModelAdapter implementation returns false.

The default FileModelAdapter implementation returns true.

Overrides:
isEditable in class ModelAdapter

edit

public boolean edit(Location location)
Edits a location in this model using an editor suitable for the model and location. The default ModelAdapter implementation does nothing and returns false.

The default TextFileModelAdapter implementation invokes Editors.editNode(oracle.ide.model.Workspace, oracle.ide.model.Project, oracle.ide.model.Node, int, int, boolean).

Overrides:
edit in class ModelAdapter

release

public void release()
Description copied from class: ModelAdapter
Releases resources used by this model.

Overrides:
release in class ModelAdapter

contextDescription

public java.lang.String contextDescription(Location location)
Gets a description of a location of this model.

The ModelAdapter implementation includes the file name and offsets of the location.

The TextFileModelAdapter implementation adds the line and column numbers and the text of the location.

Overrides:
contextDescription in class ModelAdapter

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-04

Copyright © 1997, 2010, Oracle. All rights reserved.