public abstract class ModelAdapter extends java.lang.Object implements java.lang.Comparable, Located
Element (usually, an IDE Node).
 A ModelAdapter knows how to get the constructs in the model,
 and works with the Location class to identify and track constructs as
 the model evolves. Each concrete model adapter subclass is associated with
 a specific model type and a corresponding concrete
 ModelType subclass.
 A typical model adapter corresponds to a file node in the IDE and identifies a workspace, a project, a package, and a node. If two projects are audited which contain the same node, two model adapters will be created and each will be traversed once. Model adapters have a natural order defined by comparing, in order, the names of workspace, project, package, and node.
 Typically, Audit works with text nodes. The TextFileModelAdapter
 subclass is an abstract class that provides specific support for writing
 model adapters for models tied to text nodes.
 
 The IDE allows nodes and their object models to be accessed from multiple
 threads, and requires various sorts of locking protocols to ensure
 correctness. ModelAdapter exposes this to the Audit
 framework as two kinds of transactions: read and write. The Audit framework
 always accesses constructs inside a read transaction, and applies transforms
 inside a write transaction. The default implementations of the locking
 methods are empty.
 
 The default implementations supplied in this class assume that workspace,
 project, and URL are not null. To reduce special case code in the Audit
 framework, however, root, workspace, project, and package ModelAdapter
 subclasses are provided in the framework which may have null workspace,
 project, package, or node. These subclasses override the default
 implementations.
| Modifier | Constructor and Description | 
|---|---|
protected  | 
ModelAdapter(ModelFactory factory,
            ModelType type,
            ContainerModelAdapter workspace,
            ContainerModelAdapter project,
            ContainerModelAdapter directory,
            ContentDirectory element,
            java.net.URL url)
Creates a model adapter that adapts a  
ContentDirectory element. | 
protected  | 
ModelAdapter(ModelFactory factory,
            ModelType type,
            ContainerModelAdapter workspace,
            ContainerModelAdapter project,
            ContainerModelAdapter directory,
            Node node,
            java.net.URL url)
Creates a model adapter that adapts a file  
Node. | 
protected  | 
ModelAdapter(ModelFactory factory,
            ModelType type,
            ContainerModelAdapter workspace,
            ContainerModelAdapter project,
            ContainerModelAdapter directory,
            Node node,
            java.net.URL url,
            java.lang.String primaryCollationString)
Creates a model adapter that adapts a file  
Node. | 
protected  | 
ModelAdapter(ModelFactory factory,
            ModelType type,
            ContainerModelAdapter workspace,
            Project project)
Creates a model adapter that adapts a  
Project node. | 
protected  | 
ModelAdapter(ModelFactory factory,
            ModelType type,
            Workspace workspace)
Creates a model adapter that adapts a  
Workspace node. | 
protected  | 
ModelAdapter(ModelFactory factory,
            ModelType type,
            Workspaces workspaces)
Creates a model adapter that adapts a root  
Workspaces element. | 
| Modifier and Type | Method and Description | 
|---|---|
protected void | 
acquireReadLock(WriteLockRequestListener listener)
Acquires a read lock for this model. 
 | 
protected void | 
acquireReadLock(WriteLockRequestListener listener,
               boolean interruptOnWait)
Acquires a read lock for this model. 
 | 
void | 
beginRead()
Begins a read transaction on this model for the current thread. 
 | 
void | 
beginRead(WriteLockRequestListener listener,
         boolean interruptOnWait)
Begins a preemptable read transaction on this model for the current thread. 
 | 
protected void | 
beginReadHook()
A subclass hook invoked by  
beginRead() after it invokes
 acquireReadLock(oracle.javatools.buffer.WriteLockRequestListener). | 
void | 
cancelRead()
Cancels any read transaction for any thread on this model. 
 | 
protected static int | 
compareSiblings(ModelAdapter d1,
               ModelAdapter d2)  | 
abstract int | 
compareTo(java.lang.Object object)
Gets whether this model is less than, equal to, or greater than another
 using the natural order defined by this class. 
 | 
protected static boolean | 
contains(int offset1,
        int length1,
        Location location2)
Gets whether a range contains a location, specifically for use by
 subclasses of  
contains(Object, Location). | 
boolean | 
contains(Location location)
Gets whether this model contains a location. 
 | 
abstract boolean | 
contains(ModelAdapter that)
Gets whether this model contains a model. 
 | 
boolean | 
contains(java.lang.Object construct,
        Location location)
Gets whether a construct in this model contains a location. 
 | 
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. 
 | 
void | 
endRead()
Ends the read transaction on this model for the current 
 thread. 
 | 
void | 
endRead(WriteLockRequestListener listener)
Ends the preemptable read transaction on this model for the current 
 thread. 
 | 
protected void | 
endReadHook()
A subclass hook invoked by  
endRead() before it invokes
 releaseReadLock(oracle.javatools.buffer.WriteLockRequestListener). | 
void | 
enter(AuditContext context)
Invoked as an auditor traversal enters this model. 
 | 
boolean | 
equals(java.lang.Object object)
Gets whether this model is equal to an object. 
 | 
void | 
exit(AuditContext context)
Invoked as an auditor traversal exits this model. 
 | 
java.lang.Object | 
getAttribute(java.lang.Object key)
Gets the value of an attribute in this model, or null if
 none. 
 | 
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. 
 | 
java.lang.Object | 
getConstruct(Location location)
Gets the innermost construct containing a location in this model. 
 | 
java.lang.Object | 
getConstruct(Location location,
            java.lang.Object parentConstruct)
Gets the outermost construct containing a location within a specified
 construct in this model. 
 | 
abstract java.util.Iterator | 
getContainedConstructs(java.lang.Object construct)
Gets the constructs contained by a construct in this model. 
 | 
abstract ContainerModelAdapter | 
getContainingAdapter()
Gets the model adapter containing this model adapter, or null if this is 
 the root node. 
 | 
Dependency | 
getDependency()
Gets a  
Dependency which tracks changes to this model. | 
ContentDirectory | 
getDirectory()
Gets the package directory containing this model, or null if none. 
 | 
ContainerModelAdapter | 
getDirectoryAdapter()
Gets the model adapter for the directory containing this model, or null if 
 this is a root, workspace, or project model. 
 | 
Element | 
getElement()
Gets the IDE  
Element corresponding to this model, or null if none. | 
abstract Location[] | 
getElementLocations(Element element)
Gets the locations of the constructs in this model corresponding to an
 IDE element. 
 | 
Location | 
getEndLocation()
Gets a location greater than any location in this model. 
 | 
ModelFactory | 
getFactory()
Gets the factory for this model. 
 | 
FileModelAdapter | 
getFileAdapter()
Gets the model adapter for the file containing this model, or null if this 
 is a root, workspace, project, or package model. 
 | 
Location | 
getFocusLocation(Location location)
Gets the focus location for a location in this model. 
 | 
Location | 
getFocusLocation(java.lang.Object construct,
                Location location)
Gets the focus location for a construct in this model. 
 | 
Context | 
getIdeContext()
Creates an  
IDE context for 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()
Gets a location less than or equal to any location in this model. 
 | 
Location | 
getLocation(int offset,
           int length)
Gets a location in this model. 
 | 
abstract Location | 
getLocation(java.lang.Object construct)
Gets the location for a construct in this model, or null if the object
 is not a construct in this model. 
 | 
protected ReadWriteLock | 
getLock()  | 
oracle.ide.navigation.NavigationPoint | 
getNavigationPoint(Location location)
Gets a  
NavigationPoint to navigate to a location, or null if the
 location is not navigable. | 
Node | 
getNode()
Gets the IDE  
Node corresponding to this model, or null if none
 (in particular, if this is the root or a directory model). | 
protected java.text.CollationKey | 
getPrimaryCollationKey()  | 
Project | 
getProject()
Gets the project containing this model. 
 | 
ContainerModelAdapter | 
getProjectAdapter()
Gets the model adapter for the project containing this model, or null if 
 this is root or workspace model. 
 | 
abstract java.lang.Object | 
getRoot()
Gets the root construct of this model. 
 | 
protected java.text.CollationKey | 
getSecondaryCollationKey()  | 
protected java.lang.String | 
getSecondaryCollationString()
Gets the long string used to sort two model adapters when their short 
 strings are equal. 
 | 
java.lang.String | 
getShortLabel()
Gets a short label for this model. 
 | 
java.lang.String | 
getText(int offset,
       int length)
Gets text from this model, or null if no text is available. 
 | 
ModelType | 
getType()
Gets the model type for this node. 
 | 
abstract java.net.URL | 
getUrl()
Gets the non-null URL corresponding to this model. 
 | 
java.net.URL | 
getURL()
Deprecated. 
 
use  
getUrl() | 
Workspace | 
getWorkspace()
Gets the workspace containing this model. 
 | 
ContainerModelAdapter | 
getWorkspaceAdapter()
Gets the model adapter for the workspace of this node, or null if this is
 a root model. 
 | 
int | 
hashCode()  | 
javax.swing.Icon | 
icon(Location location)
Gets the icon for a location of this model. 
 | 
abstract javax.swing.Icon | 
icon(java.lang.Object construct)
Gets the icon for a construct of this model. 
 | 
boolean | 
isEditable(Location location)
Gets whether a location in this model is editable. 
 | 
abstract boolean | 
isFile()
Gets whether this model represents a "file". 
 | 
boolean | 
isModifiable()
Gets whether this model is modifiable. 
 | 
boolean | 
isModified()
Gets whether the model has been modified since this representation of it
 was created. 
 | 
boolean | 
isModified(Location location)
Gets whether a region of this model has been modified since this 
 model adapter was created. 
 | 
protected boolean | 
isReadLockHeld()  | 
protected boolean | 
isWriteLockHeld()  | 
java.lang.Object | 
label(Location location)
Gets the label for a location of this model. 
 | 
abstract java.lang.Object | 
label(java.lang.Object construct)
Gets the label for a construct of this model. 
 | 
void | 
release()
Releases resources used by this model. 
 | 
protected void | 
releaseReadLock(WriteLockRequestListener listener)
Releases a read lock for this model. 
 | 
void | 
setAttribute(java.lang.Object key,
            java.lang.Object value)
Sets the value of an attribute in this model. 
 | 
java.lang.Object | 
summary(Location location)
Gets the summary for a location of this model. 
 | 
abstract java.lang.Object | 
summary(java.lang.Object construct)
Gets the summary for a construct of this model. 
 | 
java.lang.String | 
toString()  | 
void | 
verifyReadTransaction()
Verifies that a read transaction is in progress for this model. 
 | 
protected ModelAdapter(ModelFactory factory, ModelType type, Workspaces workspaces)
Workspaces element.protected ModelAdapter(ModelFactory factory, ModelType type, Workspace workspace)
Workspace node.protected ModelAdapter(ModelFactory factory, ModelType type, ContainerModelAdapter workspace, Project project)
Project node.protected ModelAdapter(ModelFactory factory, ModelType type, ContainerModelAdapter workspace, ContainerModelAdapter project, ContainerModelAdapter directory, ContentDirectory element, java.net.URL url)
ContentDirectory element.protected ModelAdapter(ModelFactory factory, ModelType type, ContainerModelAdapter workspace, ContainerModelAdapter project, ContainerModelAdapter directory, Node node, java.net.URL url)
Node.protected ModelAdapter(ModelFactory factory, ModelType type, ContainerModelAdapter workspace, ContainerModelAdapter project, ContainerModelAdapter directory, Node node, java.net.URL url, java.lang.String primaryCollationString)
Node.public ContentDirectory getDirectory()
public Element getElement()
Element corresponding to this model, or null if none.public Location getEndLocation()
public final ModelFactory getFactory()
public Context getIdeContext()
IDE context for this model.public int getInitialLength()
Integer.MAX_VALUE
 if this node has not been opened. The default ModelAdapter 
 implementation returns Integer.MAX_VALUE.public final Location getLocation()
getLocation in interface Locatedpublic Location getLocation(int offset, int length)
public Node getNode()
Node corresponding to this model, or null if none
 (in particular, if this is the root or a directory model).public Project getProject()
public java.lang.String getShortLabel()
public final ModelType getType()
public abstract java.net.URL getUrl()
public final java.net.URL getURL()
getUrl()public Workspace getWorkspace()
public abstract boolean isFile()
public boolean isModifiable()
ModelAdapter
 implementation returns false.public boolean isModified()
ModelAdapter implementation returns false.public boolean isModified(Location location)
public final void beginRead()
                     throws java.lang.InterruptedException
 The ModelAdapter implementation delegates to acquireReadLock(oracle.javatools.buffer.WriteLockRequestListener)
 to acquire locks, and delegates to beginReadHook() to allow 
 subclasses to initialize transaction state.
java.lang.InterruptedException - if the current thread is in or gets put in 
                              the interrupted state. The interrupted state
                              is cleared when this exception is thrown.public final void beginRead(WriteLockRequestListener listener, boolean interruptOnWait) throws java.lang.InterruptedException
 The ModelAdapter implementation delegates to acquireReadLock(oracle.javatools.buffer.WriteLockRequestListener) 
 to acquire locks and to add the listener, and delegates to beginReadHook() to allow subclasses to initialize transaction state.
listener - The listener to notify if a thread waits to acquire the write lock, or 
 null if read transaction is not preemptable.interruptOnWait - Whether to interrupt on entry if the model is stale and this thread is 
 required to wait for another thread to update it.java.lang.InterruptedException - if the current thread is in or gets put in the interrupted state, if the 
 listener is not null and other threads are already waiting for a write 
 lock, or if interruptOnWait is true and the this thread is required to 
 wait for another thread. The interrupted state is cleared when this 
 exception is thrown.public final void endRead()
 endRead() delegates to endReadHook() to allow subclasses to
 finalize transaction state, and delegates to releaseReadLock(oracle.javatools.buffer.WriteLockRequestListener) to 
 release locks.
public final void endRead(WriteLockRequestListener listener)
 endRead() delegates to endReadHook() to allow subclasses to
 finalize transaction state, and delegates to releaseReadLock(oracle.javatools.buffer.WriteLockRequestListener) to 
 release locks and remove the listener.
listener - The listener to be notified if a thread waits to acquire
                  a write lock, or null. Must be the same as given to the 
                  corresponding beginRead().public void cancelRead()
ModelAdapter implementation does nothing.
 
 The Audit framework invokes this method when asynchronously cancelling
 an audit which has begun a read transaction on this model. This allows
 model adapters to cancel model-specific long-running operations invoked
 by the model adapter (e.g., a compilation). Asynchronous cancellation is 
 inherently racy, so an implementation must be careful not too fail if
 called  after the transaction has actually ended.protected void acquireReadLock(WriteLockRequestListener listener) throws java.lang.InterruptedException
beginRead() with
 no read transaction for this model active on the current thread. The
 client is assumed to be preemptable if it supplies the listener argument;
 non-preemptable if not. The default ModelAdapter implementation 
 does nothing.listener - The listener to notify if a thread waits to acquire the write lock, or null.java.lang.InterruptedException - if the current thread is in or gets put in 
 the interrupted state. The interrupted state is cleared when this 
 exception is thrown.protected void acquireReadLock(WriteLockRequestListener listener, boolean interruptOnWait) throws java.lang.InterruptedException
beginRead() with
 no read transaction for this model active on the current thread. The
 client is assumed to be preemptable if it supplies the listener argument;
 non-preemptable if not. The default ModelAdapter implementation 
 delegates to acquireReadLock(WriteLockRequestListener).listener - The listener to notify if a thread waits to acquire the write lock, or null.interruptOnWait - Whether to interrupt on entry if the model is stale and this thread is 
 required to wait for another thread to update it.java.lang.InterruptedException - if the current thread is in or gets put in the interrupted state, if the 
 listener is not null and other threads are already waiting for a write 
 lock, or if interruptOnWait is true and the this thread is required to 
 wait for another thread. The interrupted state is cleared when this 
 exception is thrown.protected void releaseReadLock(WriteLockRequestListener listener)
endRead() with
 no write transaction for this model active on the current thread, and a 
 read transaction for this model active on the current thread. The
 default ModelAdapter implementation does nothing.listener - The listener to notify if a thread waits to acquire
                  a write lock, or null. Must be the same as given to the 
                  corresponding beginRead().protected void beginReadHook()
                      throws java.lang.InterruptedException
beginRead() after it invokes
 acquireReadLock(oracle.javatools.buffer.WriteLockRequestListener). The default ModelAdapter implementation
 does nothing.java.lang.InterruptedExceptionprotected void endReadHook()
endRead() before it invokes
 releaseReadLock(oracle.javatools.buffer.WriteLockRequestListener). The default ModelAdapter implementation
 does nothing.protected ReadWriteLock getLock()
protected boolean isReadLockHeld()
protected boolean isWriteLockHeld()
public void verifyReadTransaction()
ModelAdapter implementation does nothing.public boolean isEditable(Location location)
public boolean edit(Location location)
ModelAdapter implementation invokes
 getNavigationPoint(Location) and, if the location is navigable,
 invokes NavigationManager.navigateTo(NavigationPoint).public oracle.ide.navigation.NavigationPoint getNavigationPoint(Location location)
NavigationPoint to navigate to a location, or null if the
 location is not navigable. The default ModelAdapter implementation
 returns null.public char getCharacter(int offset)
0 if no text is
 available. A read transaction must be active on this node. The
 ModelAdapter implementation returns 0.offset - The index of the character to return.public int getColumnOffset(int offset)
ModelAdapter 
 implementation returns the character offset.public java.lang.Object getConstruct(Location location)
ModelAdapter implementation traverses from the root using
 getContainedConstructs(java.lang.Object) and the Location.contains(oracle.jdeveloper.audit.model.Location) method.location - A location in this model.public java.lang.Object getConstruct(Location location, java.lang.Object parentConstruct)
 The ModelAdapter implementation traverses from the containing 
 construct using getContainedConstructs(java.lang.Object) and the 
 Location.contains(oracle.jdeveloper.audit.model.Location) method.
location - A location contained within parentConstruct.parentConstruct - A construct of this model, created by either
                        getRoot() or getContainedConstructs(java.lang.Object)public abstract java.util.Iterator getContainedConstructs(java.lang.Object construct)
Implementations must return an iterator which iterates the constructs in document order.
construct - A construct of this model, created by either
                  getRoot() or getContainedConstructs(java.lang.Object)public Dependency getDependency()
Dependency which tracks changes to this model. A read 
 transaction must be active on this model. 
 
 The default ModelAdapter implementation returns a null dependency.
public abstract Location[] getElementLocations(Element element)
 Implementations need only deal with IDE element types that are returned 
 by the getRootElementTypes and
 getContainedElementTypes methods
 of the model type for this model.
element - an IDE Element of a type supported by this model.public Location getFocusLocation(java.lang.Object construct, Location location)
ModelAdapter implementation returns the construct location. A
 read transaction must be active on this node.construct - a construct in this model, created by either
                  getRoot() or getContainedConstructs(java.lang.Object).location - the location of the construct.public Location getFocusLocation(Location location)
getFocusLocation(java.lang.Object, oracle.jdeveloper.audit.model.Location) implementation gets the whole location. A read
 transaction must be active on this node.location - a location in this model.public java.lang.String getLine(int offset)
ModelAdapter
 implementation returns null.offset - The index of a character in the line to return.public int getLineOffset(int offset)
0 if this model does not have lines and columns. A read
 transaction must be active on this node. The ModelAdapter
 implementation returns 0.public abstract Location getLocation(java.lang.Object construct)
 If the construct is the root construct, implementations must return getLocation(); otherwise implementations must extract offset and length
 from the construct to create a Location (typically with getLocation(int, int)).
construct - a construct in this model, created by either
 getRoot() or getContainedConstructs(java.lang.Object).public abstract java.lang.Object getRoot()
public java.lang.String getText(int offset,
                       int length)
ModelAdapter 
 implementation returns null.offset - The index of the first character to return.length - The number of characters to return.public boolean equals(java.lang.Object object)
ModelFactory instances cannot be compared.equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic abstract int compareTo(java.lang.Object object)
ModelFactory instances cannot be compared.compareTo in interface java.lang.Comparableobject - The model to which to compare this model.java.lang.ClassCastException - if the object is not a ModelAdapter.protected static int compareSiblings(ModelAdapter d1, ModelAdapter d2)
public boolean contains(Location location)
location - The Location to test.public abstract boolean contains(ModelAdapter that)
that - The ModelAdapter to test.public boolean contains(java.lang.Object construct,
               Location location)
ModelAdapter location returns true if the construct is
 this or the location returned for the construct by getLocation(Object) contains the construct
 (getLocation(construct).contains(location).
 
 Subclasses that can determine containment trivially for some constructs,
 or can extract offset and length directly from some constructs and so
 avoid the expense of creating a  object should override this
 method, delegating to super for any constructs they can't optimize. To
 determine containment of the location by an offset and length, use
 contains(int, int, Location) to ensure correct results
 containment of an empty location.construct - The construct in this node to test.location - The Location to test.protected static final boolean contains(int offset1,
               int length1,
               Location location2)
contains(Object, Location). A location at either
 range boundary that was created empty (as opposed to became empty through
 deletion) is only contained if the containing range is itself empty.protected java.lang.String getSecondaryCollationString()
ModelAdapter implementation returns
 URLFileSystem.getPlatformPathName(getURL()).public java.lang.String toString()
toString in class java.lang.Objectprotected final java.text.CollationKey getPrimaryCollationKey()
protected java.text.CollationKey getSecondaryCollationKey()
public ContainerModelAdapter getWorkspaceAdapter()
public ContainerModelAdapter getProjectAdapter()
public ContainerModelAdapter getDirectoryAdapter()
public FileModelAdapter getFileAdapter()
public abstract ContainerModelAdapter getContainingAdapter()
public abstract java.lang.Object label(java.lang.Object construct)
Object, and Audit uses 
 String.valueOf(Object) to get a string. Typically, 
 implementations of this method will return a string, but the return type 
 allows an implementation to return an object which defers expensive 
 formatting to its toString() method. If necessary, the label 
 should be localized.public abstract java.lang.Object summary(java.lang.Object construct)
Object, 
 and Audit uses String.valueOf(Object) to get a string. Typically, 
 implementations of this method will return a string, but the return type 
 allows an implementation to return an object which defers expensive 
 formatting to its toString() method. The summary should be 
 localized.public abstract javax.swing.Icon icon(java.lang.Object construct)
public java.lang.Object label(Location location)
Object, and Audit uses 
 String.valueOf(Object) to get a string. Typically, 
 implementations of this method will return a string, but the return type 
 allows an implementation to return an object which defers expensive 
 formatting to its toString() method. If necessary, the label 
 should be localized.public java.lang.Object summary(Location location)
Object, 
 and Audit uses String.valueOf(Object) to get a string. Typically, 
 implementations of this method will return a string, but the return type 
 allows an implementation to return an object which defers expensive 
 formatting to its toString() method. The summary should be 
 localized.public javax.swing.Icon icon(Location location)
public void setAttribute(java.lang.Object key,
                java.lang.Object value)
key - An object identifying the attribute to set.value - The possibly null new value of the attribute.getAttribute(java.lang.Object)public java.lang.Object getAttribute(java.lang.Object key)
key - An object identifying the attribute to get.public void release()
public java.lang.String contextDescription(Location location)
 The ModelAdapter implementation includes the file name and offsets 
 of the location.
public void enter(AuditContext context)
ModelAdapter implementation does nothing.context - The audit context for the root construct of this model.public void exit(AuditContext context)
OutOfMemoryError. Implementations should be written accordingly.
 
 Tbe default ModelAdapter implementation does nothing.context - The audit context for the root construct of this model.