Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

javax.ide.model
Class Document  view Document download Document.java

java.lang.Object
  extended byjavax.ide.model.Element
      extended byjavax.ide.model.Document
Direct Known Subclasses:
Project

public class Document
extends Element

The Document interface is implemented by objects that can be saved and restored. These objects are generally persisted on some file system and are address using an unique java.net.URI.

Documents are generally created using the DocumentFactory. This ensures that there is always one instance of a document pointed to by the same java.net.URI.

The specification defines following types of documents:

Extension writers that need to introduce custom document classes, should extend this class.

When a new document class is introduced, the DocumentFactory must be told how to recognize the new document. Extension writers tell the document factory how to recognize newly introduced document classes in the extension deployment descriptor.


Field Summary
private  ElementDisplayInfo _displayInfo
           
private  java.net.URI _uri
           
 
Constructor Summary
Document()
           
 
Method Summary
 void addDocumentListener(DocumentListener listener)
          Add a DocumentListener to the listener list.
 void close()
          Closes the Document and unloads any associated data.
 boolean equals(java.lang.Object other)
          Determine whether this Object is semantically equal to another Object.
 ElementDisplayInfo getDisplayInfo()
           
private  javax.ide.model.spi.DocumentImpl getDocumentImpl()
           
protected  javax.ide.model.spi.ElementImpl getElementImpl()
           
 java.io.Reader getReader()
          Gets an java.io.Reader that can be used to read the contents of this object.
 long getTimestamp()
          Returns the timestamp associated with the Document, which indicates the time at which the document was last modified.
 java.net.URI getURI()
          Returns the java.net.URI that identifies this Document.
 int hashCode()
          Get a value that represents this Object, as uniquely as possible within the confines of an int.
 boolean isDirty()
          True if the data in the object has been modified.
 boolean isNew()
          Returns true if the document's data has never been saved.
 boolean isOpen()
          Returns true if the object's data has already been loaded.
 boolean isReadOnly()
          Returns true if the document's data has never been saved.
 void markDirty(boolean dirty)
          Marks the data with the specified dirty state.
 void open()
          Opens the Document and loads any associated data into the appropriate data structures.
 void removeDocumentListener(DocumentListener listener)
          Removes a DocumentListener from the listener list.
 void save()
          Saves the contents of the document.
protected  void setDisplayInfo(ElementDisplayInfo displayInfo)
          Set the display info for this element.
 void setURI(java.net.URI uri)
          Sets the java.net.URI associated with this Document.
 
Methods inherited from class javax.ide.model.Element
getIcon, getLabel, getLongLabel, getToolTip
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_uri

private java.net.URI _uri

_displayInfo

private ElementDisplayInfo _displayInfo
Constructor Detail

Document

public Document()
Method Detail

getElementImpl

protected final javax.ide.model.spi.ElementImpl getElementImpl()
Specified by:
getElementImpl in class Element

getDocumentImpl

private javax.ide.model.spi.DocumentImpl getDocumentImpl()

setDisplayInfo

protected final void setDisplayInfo(ElementDisplayInfo displayInfo)
Set the display info for this element. This can be used by custom documents to customize their display in the IDE.


getDisplayInfo

public ElementDisplayInfo getDisplayInfo()

getURI

public final java.net.URI getURI()
Returns the java.net.URI that identifies this Document. Parts of the IDE will use the value of this java.net.URI as a hash key for caching UI components for this Document. Therefore, java.net.URI uniqueness is important.


setURI

public final void setURI(java.net.URI uri)
Sets the java.net.URI associated with this Document. It is important that the java.net.URI only be changed when the Document has just been created or when all caches keyed on the previous java.net.URI can also be updated.


isOpen

public final boolean isOpen()
Returns true if the object's data has already been loaded.


isNew

public final boolean isNew()
Returns true if the document's data has never been saved.


open

public final void open()
                throws java.io.IOException
Opens the Document and loads any associated data into the appropriate data structures. This method notifies listeners if the document is successfully opened.


close

public final void close()
                 throws java.io.IOException
Closes the Document and unloads any associated data. When this method returns, the state of the Document object should be equivalent to when the Document object has just been instantiated but not yet opened.


save

public final void save()
                throws java.io.IOException
Saves the contents of the document.


isReadOnly

public final boolean isReadOnly()
Returns true if the document's data has never been saved.


isDirty

public final boolean isDirty()
True if the data in the object has been modified.


markDirty

public final void markDirty(boolean dirty)
Marks the data with the specified dirty state.


getTimestamp

public final long getTimestamp()
Returns the timestamp associated with the Document, which indicates the time at which the document was last modified. The returned long is expressed in milliseconds since 00:00:00 GMT Jan 1, 1970.


getReader

public final java.io.Reader getReader()
                               throws java.io.IOException
Gets an java.io.Reader that can be used to read the contents of this object.


addDocumentListener

public final void addDocumentListener(DocumentListener listener)
Add a DocumentListener to the listener list. A DocumentEvent will be fired in response modifying the contents of this document.


removeDocumentListener

public final void removeDocumentListener(DocumentListener listener)
Removes a DocumentListener from the listener list.


hashCode

public final int hashCode()
Description copied from class: java.lang.Object
Get a value that represents this Object, as uniquely as possible within the confines of an int.

There are some requirements on this method which subclasses must follow:

  • Semantic equality implies identical hashcodes. In other words, if a.equals(b) is true, then a.hashCode() == b.hashCode() must be as well. However, the reverse is not necessarily true, and two objects may have the same hashcode without being equal.
  • It must be consistent. Whichever value o.hashCode() returns on the first invocation must be the value returned on all later invocations as long as the object exists. Notice, however, that the result of hashCode may change between separate executions of a Virtual Machine, because it is not invoked on the same object.

Notice that since hashCode is used in java.util.Hashtable and other hashing classes, a poor implementation will degrade the performance of hashing (so don't blindly implement it as returning a constant!). Also, if calculating the hash is time-consuming, a class may consider caching the results.

The default implementation returns System.identityHashCode(this)


equals

public final boolean equals(java.lang.Object other)
Description copied from class: java.lang.Object
Determine whether this Object is semantically equal to another Object.

There are some fairly strict requirements on this method which subclasses must follow:

  • It must be transitive. If a.equals(b) and b.equals(c), then a.equals(c) must be true as well.
  • It must be symmetric. a.equals(b) and b.equals(a) must have the same value.
  • It must be reflexive. a.equals(a) must always be true.
  • It must be consistent. Whichever value a.equals(b) returns on the first invocation must be the value returned on all later invocations.
  • a.equals(null) must be false.
  • It must be consistent with hashCode(). That is, a.equals(b) must imply a.hashCode() == b.hashCode(). The reverse is not true; two objects that are not equal may have the same hashcode, but that has the potential to harm hashing performance.

This is typically overridden to throw a java.lang.ClassCastException if the argument is not comparable to the class performing the comparison, but that is not a requirement. It is legal for a.equals(b) to be true even though a.getClass() != b.getClass(). Also, it is typical to never cause a java.lang.NullPointerException.

In general, the Collections API (java.util) use the equals method rather than the == operator to compare objects. However, java.util.IdentityHashMap is an exception to this rule, for its own good reasons.

The default implementation returns this == o.