|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.6.0) E13403-07 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.jdeveloper.audit.model.ModelAdapter
public abstract class ModelAdapter
An abstract adapter between the Audit framework and the object model
associated with a particular IDE 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.
ModelType
,
ContainerModelAdapter
,
FileModelAdapter
,
TextFileModelAdapter
Field Summary | |
---|---|
protected int |
index
|
protected static Log |
log
|
Constructor Summary | |
---|---|
protected |
ModelAdapter(ModelFactory factory,
ModelType type)
Creates a model adapter that adapts a root Workspaces element. |
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 package directory node. |
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 @link oracle.ide.model.Project Project} node. |
protected |
ModelAdapter(ModelFactory factory,
ModelType type,
Workspace workspace)
Creates a model adapter that adapts a @link oracle.ide.model.Workspace Workspace} node. |
Method Summary | |
---|---|
protected boolean |
acquireReadLock(WriteLockRequestListener listener)
Acquires a read lock for this model. |
void |
beginRead()
Begins a read transaction on this model for the current thread. |
boolean |
beginRead(WriteLockRequestListener listener)
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. |
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 adapter. |
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()
|
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. |
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 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. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final Log log
protected int index
Constructor Detail |
---|
protected ModelAdapter(ModelFactory factory, ModelType type)
Workspaces
element.
protected ModelAdapter(ModelFactory factory, ModelType type, Workspace workspace)
protected ModelAdapter(ModelFactory factory, ModelType type, ContainerModelAdapter workspace, Project project)
protected ModelAdapter(ModelFactory factory, ModelType type, ContainerModelAdapter workspace, ContainerModelAdapter project, ContainerModelAdapter directory, ContentDirectory element, java.net.URL url)
package directory
node. The folder
will be null if the
package was not created from a navigator selection (in particular, was
created by a Project model adapter).
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
.
Method Detail |
---|
public ContentDirectory getDirectory()
public Element getElement()
Element
corresponding to this model, or null if none.
Packages in particular often do not have an element.
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 Location getLocation()
getLocation
in interface Located
public 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()
public boolean isModified(Location location)
public final void beginRead()
The ModelAdapter
implementation delegates to acquireReadLock(oracle.javatools.buffer.WriteLockRequestListener)
to acquire locks, and delegates to beginReadHook()
to allow
subclasses to initialize transaction state.
public final boolean beginRead(WriteLockRequestListener listener)
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.
listener
is null.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.
protected boolean acquireReadLock(WriteLockRequestListener listener)
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.
listener
is null.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()
beginRead()
after it invokes
acquireReadLock(oracle.javatools.buffer.WriteLockRequestListener)
. The default ModelAdapter
implementation
does nothing.
protected void endReadHook()
endRead()
before it invokes
releaseReadLock(oracle.javatools.buffer.WriteLockRequestListener)
. The default ModelAdapter
implementation
does nothing.
protected ReadWriteLock getLock()
public final void verifyReadTransaction()
ModelAdapter
implementation normally does nothing.
public boolean isEditable(Location location)
ModelAdapter
implementation returns false.
public boolean edit(Location location)
ModelAdapter
implementation does nothing and
returns false.
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. 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)
Implementations must extract offset and length from the construct
to create a Location
.
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.Object
public abstract int compareTo(java.lang.Object object)
ModelFactory
instances cannot be compared.
compareTo
in interface java.lang.Comparable
object
- The node with which to compare this node.
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)
construct
- The construct in this node to test.location
- The Location
to test.protected java.lang.String getSecondaryCollationString()
ModelAdapter
implementation returns
URLFileSystem.getPlatformPathName(getURL())
.
public java.lang.String toString()
toString
in class java.lang.Object
protected 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)
context
- The audit context for the root construct of this model.public void exit(AuditContext context)
context
- The audit context for the root construct of this model.
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.6.0) E13403-07 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |