org.eclipse.cdt.internal.ui.editor
Class DocumentAdapter

java.lang.Object
  extended by org.eclipse.cdt.internal.ui.editor.DocumentAdapter
All Implemented Interfaces:
org.eclipse.cdt.core.model.IBuffer, org.eclipse.jface.text.IDocumentListener

public class DocumentAdapter
extends java.lang.Object
implements org.eclipse.cdt.core.model.IBuffer, org.eclipse.jface.text.IDocumentListener

Adapts IDocument to IBuffer. Uses the same algorithm as the text widget to determine the buffer's line delimiter. All text inserted into the buffer is converted to this line delimiter. This class is public for test purposes only. This class is similar to the JDT DocumentAdapter class.


Field Summary
static org.eclipse.cdt.core.model.IBuffer NULL
          NULL implementing IBuffer
 
Constructor Summary
DocumentAdapter(org.eclipse.cdt.core.model.IOpenable owner, org.eclipse.core.resources.IFile file)
           
DocumentAdapter(org.eclipse.cdt.core.model.IOpenable owner, org.eclipse.core.runtime.IPath location)
           
 
Method Summary
 void addBufferChangedListener(org.eclipse.cdt.core.model.IBufferChangedListener listener)
           
 void append(char[] text)
           
 void append(java.lang.String text)
           
 void close()
           
 void documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent event)
           
 void documentChanged(org.eclipse.jface.text.DocumentEvent event)
           
 char getChar(int position)
           
 char[] getCharacters()
           
 java.lang.String getContents()
           
 org.eclipse.jface.text.IDocument getDocument()
          Returns the adapted document.
 int getLength()
           
 org.eclipse.cdt.core.model.IOpenable getOwner()
           
 org.eclipse.core.runtime.IStatus getStatus()
          Returns the status of this document adapter.
 java.lang.String getText(int offset, int length)
           
 org.eclipse.core.resources.IResource getUnderlyingResource()
           
 boolean hasUnsavedChanges()
           
 boolean isClosed()
           
 boolean isReadOnly()
           
 void removeBufferChangedListener(org.eclipse.cdt.core.model.IBufferChangedListener listener)
           
 void replace(int position, int length, char[] text)
           
 void replace(int position, int length, java.lang.String text)
           
 void save(org.eclipse.core.runtime.IProgressMonitor progress, boolean force)
           
 void setContents(char[] contents)
           
 void setContents(java.lang.String contents)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL

public static final org.eclipse.cdt.core.model.IBuffer NULL
NULL implementing IBuffer

Constructor Detail

DocumentAdapter

public DocumentAdapter(org.eclipse.cdt.core.model.IOpenable owner,
                       org.eclipse.core.resources.IFile file)

DocumentAdapter

public DocumentAdapter(org.eclipse.cdt.core.model.IOpenable owner,
                       org.eclipse.core.runtime.IPath location)
Method Detail

getStatus

public org.eclipse.core.runtime.IStatus getStatus()
Returns the status of this document adapter.


getDocument

public org.eclipse.jface.text.IDocument getDocument()
Returns the adapted document.

Returns:
the adapted document

addBufferChangedListener

public void addBufferChangedListener(org.eclipse.cdt.core.model.IBufferChangedListener listener)
Specified by:
addBufferChangedListener in interface org.eclipse.cdt.core.model.IBuffer

removeBufferChangedListener

public void removeBufferChangedListener(org.eclipse.cdt.core.model.IBufferChangedListener listener)
Specified by:
removeBufferChangedListener in interface org.eclipse.cdt.core.model.IBuffer

append

public void append(char[] text)
Specified by:
append in interface org.eclipse.cdt.core.model.IBuffer
See Also:
IBuffer.append(char[])

append

public void append(java.lang.String text)
Specified by:
append in interface org.eclipse.cdt.core.model.IBuffer
See Also:
IBuffer.append(java.lang.String)

close

public void close()
Specified by:
close in interface org.eclipse.cdt.core.model.IBuffer
See Also:
IBuffer.close()

getChar

public char getChar(int position)
Specified by:
getChar in interface org.eclipse.cdt.core.model.IBuffer
See Also:
IBuffer.getChar(int)

getCharacters

public char[] getCharacters()
Specified by:
getCharacters in interface org.eclipse.cdt.core.model.IBuffer
See Also:
IBuffer.getCharacters()

getContents

public java.lang.String getContents()
Specified by:
getContents in interface org.eclipse.cdt.core.model.IBuffer
See Also:
IBuffer.getContents()

getLength

public int getLength()
Specified by:
getLength in interface org.eclipse.cdt.core.model.IBuffer
See Also:
IBuffer.getLength()

getOwner

public org.eclipse.cdt.core.model.IOpenable getOwner()
Specified by:
getOwner in interface org.eclipse.cdt.core.model.IBuffer
See Also:
IBuffer.getOwner()

getText

public java.lang.String getText(int offset,
                                int length)
Specified by:
getText in interface org.eclipse.cdt.core.model.IBuffer
See Also:
IBuffer.getText(int, int)

getUnderlyingResource

public org.eclipse.core.resources.IResource getUnderlyingResource()
Specified by:
getUnderlyingResource in interface org.eclipse.cdt.core.model.IBuffer
See Also:
IBuffer.getUnderlyingResource()

hasUnsavedChanges

public boolean hasUnsavedChanges()
Specified by:
hasUnsavedChanges in interface org.eclipse.cdt.core.model.IBuffer
See Also:
IBuffer.hasUnsavedChanges()

isClosed

public boolean isClosed()
Specified by:
isClosed in interface org.eclipse.cdt.core.model.IBuffer
See Also:
IBuffer.isClosed()

isReadOnly

public boolean isReadOnly()
Specified by:
isReadOnly in interface org.eclipse.cdt.core.model.IBuffer
See Also:
IBuffer.isReadOnly()

replace

public void replace(int position,
                    int length,
                    char[] text)
Specified by:
replace in interface org.eclipse.cdt.core.model.IBuffer
See Also:
IBuffer.replace(int, int, char[])

replace

public void replace(int position,
                    int length,
                    java.lang.String text)
Specified by:
replace in interface org.eclipse.cdt.core.model.IBuffer
See Also:
IBuffer.replace(int, int, java.lang.String)

save

public void save(org.eclipse.core.runtime.IProgressMonitor progress,
                 boolean force)
          throws org.eclipse.cdt.core.model.CModelException
Specified by:
save in interface org.eclipse.cdt.core.model.IBuffer
Throws:
org.eclipse.cdt.core.model.CModelException
See Also:
IBuffer.save(org.eclipse.core.runtime.IProgressMonitor, boolean)

setContents

public void setContents(char[] contents)
Specified by:
setContents in interface org.eclipse.cdt.core.model.IBuffer
See Also:
IBuffer.setContents(char[])

setContents

public void setContents(java.lang.String contents)
Specified by:
setContents in interface org.eclipse.cdt.core.model.IBuffer
See Also:
IBuffer.setContents(java.lang.String)

documentAboutToBeChanged

public void documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent event)
Specified by:
documentAboutToBeChanged in interface org.eclipse.jface.text.IDocumentListener

documentChanged

public void documentChanged(org.eclipse.jface.text.DocumentEvent event)
Specified by:
documentChanged in interface org.eclipse.jface.text.IDocumentListener