This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
/** This document's version. It's accessed by DocumentUtilities.getDocumentVersion(). */
private static final String VERSION_PROP = "version"; //NOI18N
/** Timestamp when this document was last modified. It's accessed by DocumentUtilities.getDocumentVersion(). */
private static final String LAST_MODIFICATION_TIMESTAMP_PROP = "last-modification-timestamp"; //NOI18N
/** Line separator property for reading files in */
public static final String READ_LINE_SEPARATOR_PROP = DefaultEditorKit.EndOfLineStringProperty;
/* package */ void incrementDocVersion() {
((AtomicLong) getProperty(VERSION_PROP)).incrementAndGet();
((AtomicLong) getProperty(LAST_MODIFICATION_TIMESTAMP_PROP)).set(System.currentTimeMillis());
}
/** Compound edit that write-locks the document for the whole processing
<changes>
<change id="DocumentUtilities.getDocumentTimestamp-added">
<summary>Added DocumentUtilities.getDocumentTimestamp(Document)</summary>
<version major="1" minor="34"/>
<date day="14" month="1" year="2010"/>
<author login="vstejskal"/>
<compatibility addition="yes" deletion="no" modification="no" binary="compatible" semantic="compatible" />
<description>
<p>
Adding DocumentUtilities.getDocumentTimestamp(Document) to provide access
to documents' timestamp property.
</p>
</description>
</change>
<change id="DocumentUtilities.getDocumentVersion-added">
<summary>Added DocumentUtilities.getDocumentVersion(Document)</summary>
<version major="1" minor="28"/>
OpenIDE-Module: org.netbeans.modules.editor.util/1
OpenIDE-Module-Localizing-Bundle: org/netbeans/lib/editor/util/Bundle.properties
AutoUpdate-Show-In-Client: false
OpenIDE-Module-Specification-Version: 1.33
OpenIDE-Module-Specification-Version: 1.34
/** BaseDocument's version. */
private static final Object TYPING_MODIFICATION_DOCUMENT_PROPERTY = new Object();
Object version = doc.getProperty(VERSION_PROP);
return version instanceof AtomicLong ? ((AtomicLong) version).get() : 0;
/**
* Attempts to get the timestamp of a <code>Document</code>. Netbeans editor
* documents are versioned and timestamped whenever they are modified.
* This method can be used to read the timestamp of the most recent modification.
* The timestamp is a number of milliseconds returned from <code>System.currentTimeMillis()</code>
* at the document modification.
*
* @param doc The document to get the timestamp for.
* @return The document's timestamp or <code>0</code> if the document does not
* support timestamps (ie. is not a netbeans editor document).
* @since 1.34
*/
public static long getDocumentTimestamp(Document doc) {
Object version = doc.getProperty(LAST_MODIFICATION_TIMESTAMP_PROP);