Extension SDK 10.1.2

oracle.jdeveloper.audit.model
Class Location

java.lang.Object
  extended byoracle.jdeveloper.audit.model.Location
All Implemented Interfaces:
java.lang.Comparable, Located

public class Location
extends java.lang.Object
implements java.lang.Comparable, Located

A location in a document in a project. This class encapsulates a document and a range of characters within the text buffer for the document; and using the document, allows clients to go back and forth between Locations and constructs in the source model for the document. A location adjusts the offset and length it exposes to clients to account for edits in the containing document that happen after its creation.

The document is defined by a DocumentAdapter, which encapsulates a workspace, project, and node and serves as a factory and service provider for locations.

Analyzer implementations typically work directly with constructs rather than with Locations. However, the Audit framework relies on locations to avoid holding references to constructs and thereby locking entire source models into memory; and to allow it to use source models which are completely recreated whenever the underlying document changes.

Location implements Comparable in such a way that a location which includes another always sorts first.

Notes

When a whole document location is created, the length should be the length of the document. To avoid opening files that don't otherwise need to be opened, the length is set internally to Integer.MAX_VALUE. When used, lengths of Integer.MAX_VALUE are always replaced by document.getInitialLength(), which will also be Integer.MAX_VALUE until the document is actually opened. Because getEnd propagates the length to the offset, the same replacement is also done for the internal offset value.

See Also:
DocumentAdapter

Constructor Summary
Location(DocumentAdapter document)
          Creates a location spanning the entire document.
Location(DocumentAdapter document, int offset, int length)
          Creates a location within a document.
 
Method Summary
 int compareTo(java.lang.Object object)
           A Location which encloses another will always sort first.
 boolean contains(Location location)
          Gets whether this location contains a location.
 boolean equals(java.lang.Object object)
           
 Location getBeginning()
          Gets a zero length location at the beginning of this location.
 DocumentAdapter getDocument()
          Gets the document containing this location.
 Location getEnd()
          Gets a zero length location at the end of this location.
 int getEndOffset()
          Gets the number of characters in the document text buffer before the first character following this location, adjusted for edits to the containing document.
 int getLength()
          Gets the number of characters in the document text buffer contained by this location, adjusted for edits to the containing document.
 Location getLocation()
          Gets this location in fulfillment of the Located interface.
 int getOffset()
          Gets the number of characters in the document text buffer before this location, adjusted for edits to the containing document.
 Project getProject()
          Gets the project containing this location.
 Workspace getWorkspace()
          Gets the workspace containing this location.
 int hashCode()
           
 boolean isRoot()
          Gets whether this location corresponds to the root construct in the object model for its document.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Location

public Location(DocumentAdapter document)
Creates a location spanning the entire document. This location corresponds to the root construct in the object model for the document.

Parameters:
document - The DocumentAdapter containing this location.

Location

public Location(DocumentAdapter document,
                int offset,
                int length)
Creates a location within a document.

Parameters:
document - The DocumentAdapter containing this location.
offset - The number of characters in the text buffer for the document before the first character contained by this location.
length - The number of characters within this location.
Method Detail

getLocation

public final Location getLocation()
Gets this location in fulfillment of the Located interface.

Specified by:
getLocation in interface Located
Returns:
this location.

isRoot

public boolean isRoot()
Gets whether this location corresponds to the root construct in the object model for its document.


getWorkspace

public Workspace getWorkspace()
Gets the workspace containing this location.


getProject

public Project getProject()
Gets the project containing this location.


getDocument

public DocumentAdapter getDocument()
Gets the document containing this location.


getOffset

public int getOffset()
Gets the number of characters in the document text buffer before this location, adjusted for edits to the containing document.


getLength

public int getLength()
Gets the number of characters in the document text buffer contained by this location, adjusted for edits to the containing document.


getEndOffset

public int getEndOffset()
Gets the number of characters in the document text buffer before the first character following this location, adjusted for edits to the containing document.


getBeginning

public Location getBeginning()
Gets a zero length location at the beginning of this location.


getEnd

public Location getEnd()
Gets a zero length location at the end of this location.

Returns:

contains

public boolean contains(Location location)
Gets whether this location contains a location.

Parameters:
location - The location to test.

compareTo

public int compareTo(java.lang.Object object)
A Location which encloses another will always sort first. The implementation deals with nested documents correctly.

Specified by:
compareTo in interface java.lang.Comparable

equals

public boolean equals(java.lang.Object object)

hashCode

public int hashCode()

toString

public java.lang.String toString()

Extension SDK

 

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