java.lang.Object
org.aspectj.org.eclipse.jdt.internal.core.Buffer
Alle implementierten Schnittstellen:
IBuffer
Bekannte direkte Unterklassen:
NullBuffer

public class Buffer extends Object implements IBuffer
Siehe auch:
  • Verschachtelte Klassen - Übersicht

    Von Schnittstelle geerbte verschachtelte Klassen/Schnittstellen org.aspectj.org.eclipse.jdt.core.IBuffer

    IBuffer.ITextEditCapability
  • Feldübersicht

    Felder
    Modifizierer und Typ
    Feld
    Beschreibung
    protected org.eclipse.core.runtime.ListenerList<IBufferChangedListener>
     
    protected char[]
     
    protected static final int
     
    protected static final int
     
    protected static final int
     
    protected org.eclipse.core.resources.IFile
     
    protected int
     
    protected int
     
    protected int
     
    protected Object
     
    protected IOpenable
     
  • Konstruktorübersicht

    Konstruktoren
    Modifizierer
    Konstruktor
    Beschreibung
    protected
    Buffer(org.eclipse.core.resources.IFile file, IOpenable owner, boolean readOnly)
    Creates a new buffer on an underlying resource.
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    void
    Adds the given listener for changes to this buffer.
    void
    append(char[] text)
    Append the text to the actual content, the gap is moved to the end of the text.
    void
    append(String text)
    Append the text to the actual content, the gap is moved to the end of the text.
    void
    Closes the buffer.
    char
    getChar(int position)
    Returns the character at the given position in this buffer.
    char[]
    Returns the contents of this buffer as a character array, or null if the buffer has not been initialized.
    Returns the contents of this buffer as a String.
    int
    Returns number of characters stored in this buffer.
    Returns the Java openable element owning of this buffer.
    getText(int offset, int length)
    Returns the given range of text in this buffer.
    org.eclipse.core.resources.IResource
    Returns the underlying resource for which this buffer was opened, or null if this buffer was not opened on a resource.
    boolean
    Returns whether this buffer has been modified since it was opened or since it was last saved.
    boolean
    Returns whether this buffer has been closed.
    boolean
    Returns whether this buffer is read-only.
    protected void
    moveAndResizeGap(int position, int size)
    Moves the gap to location and adjust its size to the anticipated change size.
    protected void
    Notify the listeners that this buffer has changed.
    void
    Removes the given listener from this buffer.
    void
    replace(int position, int length, char[] text)
    Replaces length characters starting from position with text.
    void
    replace(int position, int length, String text)
    Replaces length characters starting from position with text.
    void
    save(org.eclipse.core.runtime.IProgressMonitor progress, boolean force)
    Saves the contents of this buffer to its underlying resource.
    void
    setContents(char[] newContents)
    Sets the contents of this buffer to the given character array.
    void
    setContents(String newContents)
    Sets the contents of this buffer to the given String.
    protected void
    setReadOnly(boolean readOnly)
    Sets this Buffer to be read only.
     

    Von Klasse geerbte Methoden java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Felddetails

    • file

      protected org.eclipse.core.resources.IFile file
    • flags

      protected int flags
    • contents

      protected char[] contents
    • changeListeners

      protected org.eclipse.core.runtime.ListenerList<IBufferChangedListener> changeListeners
    • owner

      protected IOpenable owner
    • gapStart

      protected int gapStart
    • gapEnd

      protected int gapEnd
    • lock

      protected Object lock
    • F_HAS_UNSAVED_CHANGES

      protected static final int F_HAS_UNSAVED_CHANGES
      Siehe auch:
    • F_IS_READ_ONLY

      protected static final int F_IS_READ_ONLY
      Siehe auch:
    • F_IS_CLOSED

      protected static final int F_IS_CLOSED
      Siehe auch:
  • Konstruktordetails

    • Buffer

      protected Buffer(org.eclipse.core.resources.IFile file, IOpenable owner, boolean readOnly)
      Creates a new buffer on an underlying resource.
  • Methodendetails

    • addBufferChangedListener

      public void addBufferChangedListener(IBufferChangedListener listener)
      Beschreibung aus Schnittstelle kopiert: IBuffer
      Adds the given listener for changes to this buffer. Has no effect if an identical listener is already registered or if the buffer is closed.
      Angegeben von:
      addBufferChangedListener in Schnittstelle IBuffer
      Parameter:
      listener - the listener of buffer changes
      Siehe auch:
    • append

      public void append(char[] text)
      Append the text to the actual content, the gap is moved to the end of the text.
      Angegeben von:
      append in Schnittstelle IBuffer
      Parameter:
      text - the given character array to append to contents of the buffer
    • append

      public void append(String text)
      Append the text to the actual content, the gap is moved to the end of the text.
      Angegeben von:
      append in Schnittstelle IBuffer
      Parameter:
      text - the String to append to the contents of the buffer
    • close

      public void close()
      Beschreibung aus Schnittstelle kopiert: IBuffer
      Closes the buffer. Any unsaved changes are lost. Reports a buffer changed event with a 0 offset and a 0 length. When this event is fired, the buffer should already be closed.

      Further operations on the buffer are not allowed, except for close. If an attempt is made to close an already closed buffer, the second attempt has no effect.

      Angegeben von:
      close in Schnittstelle IBuffer
      Siehe auch:
    • getChar

      public char getChar(int position)
      Beschreibung aus Schnittstelle kopiert: IBuffer
      Returns the character at the given position in this buffer.

      The returned value is undefined if the buffer is closed.

      Angegeben von:
      getChar in Schnittstelle IBuffer
      Parameter:
      position - a zero-based source offset in this buffer
      Gibt zurück:
      the character at the given position in this buffer
      Siehe auch:
    • getCharacters

      public char[] getCharacters()
      Beschreibung aus Schnittstelle kopiert: IBuffer
      Returns the contents of this buffer as a character array, or null if the buffer has not been initialized.

      Callers should make no assumption about whether the returned character array is or is not the genuine article or a copy. In other words, if the client wishes to change this array, they should make a copy. Likewise, if the client wishes to hang on to the array in its current state, they should make a copy.

      The returned value is undefined if the buffer is closed.

      Angegeben von:
      getCharacters in Schnittstelle IBuffer
      Gibt zurück:
      the characters contained in this buffer
      Siehe auch:
    • getContents

      public String getContents()
      Beschreibung aus Schnittstelle kopiert: IBuffer
      Returns the contents of this buffer as a String. Like all strings, the result is an immutable value object., It can also answer null if the buffer has not been initialized.

      The returned value is undefined if the buffer is closed.

      Angegeben von:
      getContents in Schnittstelle IBuffer
      Gibt zurück:
      the contents of this buffer as a String
      Siehe auch:
    • getLength

      public int getLength()
      Beschreibung aus Schnittstelle kopiert: IBuffer
      Returns number of characters stored in this buffer.

      The returned value is undefined if the buffer is closed.

      Angegeben von:
      getLength in Schnittstelle IBuffer
      Gibt zurück:
      the number of characters in this buffer
      Siehe auch:
    • getOwner

      public IOpenable getOwner()
      Beschreibung aus Schnittstelle kopiert: IBuffer
      Returns the Java openable element owning of this buffer.
      Angegeben von:
      getOwner in Schnittstelle IBuffer
      Gibt zurück:
      the openable element owning this buffer
      Siehe auch:
    • getText

      public String getText(int offset, int length)
      Beschreibung aus Schnittstelle kopiert: IBuffer
      Returns the given range of text in this buffer.

      The returned value is undefined if the buffer is closed.

      Angegeben von:
      getText in Schnittstelle IBuffer
      Parameter:
      offset - the zero-based starting offset
      length - the number of characters to retrieve
      Gibt zurück:
      the given range of text in this buffer
      Siehe auch:
    • getUnderlyingResource

      public org.eclipse.core.resources.IResource getUnderlyingResource()
      Beschreibung aus Schnittstelle kopiert: IBuffer
      Returns the underlying resource for which this buffer was opened, or null if this buffer was not opened on a resource.
      Angegeben von:
      getUnderlyingResource in Schnittstelle IBuffer
      Gibt zurück:
      the underlying resource for this buffer, or null if none.
      Siehe auch:
    • hasUnsavedChanges

      public boolean hasUnsavedChanges()
      Beschreibung aus Schnittstelle kopiert: IBuffer
      Returns whether this buffer has been modified since it was opened or since it was last saved. If a buffer does not have an underlying resource, this method always returns true.

      NOTE: when a buffer does not have unsaved changes, the model may decide to close it to claim some memory back. If the associated element needs to be reopened later on, its buffer factory will be requested to create a new buffer.

      Angegeben von:
      hasUnsavedChanges in Schnittstelle IBuffer
      Gibt zurück:
      a boolean indicating presence of unsaved changes (in the absence of any underlying resource, it will always return true).
      Siehe auch:
    • isClosed

      public boolean isClosed()
      Beschreibung aus Schnittstelle kopiert: IBuffer
      Returns whether this buffer has been closed.
      Angegeben von:
      isClosed in Schnittstelle IBuffer
      Gibt zurück:
      a boolean indicating whether this buffer is closed.
      Siehe auch:
    • isReadOnly

      public boolean isReadOnly()
      Beschreibung aus Schnittstelle kopiert: IBuffer
      Returns whether this buffer is read-only.
      Angegeben von:
      isReadOnly in Schnittstelle IBuffer
      Gibt zurück:
      a boolean indicating whether this buffer is read-only
      Siehe auch:
    • moveAndResizeGap

      protected void moveAndResizeGap(int position, int size)
      Moves the gap to location and adjust its size to the anticipated change size. The size represents the expected range of the gap that will be filled after the gap has been moved. Thus the gap is resized to actual size + the specified size and moved to the given position.
    • notifyChanged

      protected void notifyChanged(BufferChangedEvent event)
      Notify the listeners that this buffer has changed. To avoid deadlock, this should not be called in a synchronized block.
    • removeBufferChangedListener

      public void removeBufferChangedListener(IBufferChangedListener listener)
      Beschreibung aus Schnittstelle kopiert: IBuffer
      Removes the given listener from this buffer. Has no effect if an identical listener is not registered or if the buffer is closed.
      Angegeben von:
      removeBufferChangedListener in Schnittstelle IBuffer
      Parameter:
      listener - the listener
      Siehe auch:
    • replace

      public void replace(int position, int length, char[] text)
      Replaces length characters starting from position with text. After that operation, the gap is placed at the end of the inserted text.
      Angegeben von:
      replace in Schnittstelle IBuffer
      Parameter:
      position - the zero-based starting position of the affected text range in this buffer
      length - the length of the affected text range in this buffer
      text - the replacing text as a character array
    • replace

      public void replace(int position, int length, String text)
      Replaces length characters starting from position with text. After that operation, the gap is placed at the end of the inserted text.
      Angegeben von:
      replace in Schnittstelle IBuffer
      Parameter:
      position - the zero-based starting position of the affected text range in this buffer
      length - the length of the affected text range in this buffer
      text - the replacing text as a String
    • save

      public void save(org.eclipse.core.runtime.IProgressMonitor progress, boolean force) throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: IBuffer
      Saves the contents of this buffer to its underlying resource. If successful, this buffer will have no unsaved changes. The buffer is left open. Saving a buffer with no unsaved changes has no effect - the underlying resource is not changed. If the buffer does not have an underlying resource or is read-only, this has no effect.

      The force parameter controls how this method deals with cases where the workbench is not completely in sync with the local file system. If false is specified, this method will only attempt to overwrite a corresponding file in the local file system provided it is in sync with the workbench. This option ensures there is no unintended data loss; it is the recommended setting. However, if true is specified, an attempt will be made to write a corresponding file in the local file system, overwriting any existing one if need be. In either case, if this method succeeds, the resource will be marked as being local (even if it wasn't before).

      Has no effect if this buffer is read-only or if the buffer is closed.

      Angegeben von:
      save in Schnittstelle IBuffer
      Parameter:
      progress - the progress monitor to notify
      force - a boolean flag indicating how to deal with resource inconsistencies.
      Löst aus:
      JavaModelException - if an error occurs writing the buffer to the underlying resource
      Siehe auch:
    • setContents

      public void setContents(char[] newContents)
      Beschreibung aus Schnittstelle kopiert: IBuffer
      Sets the contents of this buffer to the given character array. This buffer will now have unsaved changes. Any client can set the contents of the buffer, not just the owner of the buffer. Reports a buffer changed event.

      Equivalent to replace(0,getLength(),contents).

      Has no effect if this buffer is read-only or if the buffer is closed.

      Angegeben von:
      setContents in Schnittstelle IBuffer
      Parameter:
      newContents - the new contents of this buffer as a character array
      Siehe auch:
    • setContents

      public void setContents(String newContents)
      Beschreibung aus Schnittstelle kopiert: IBuffer
      Sets the contents of this buffer to the given String. This buffer will now have unsaved changes. Any client can set the contents of the buffer, not just the owner of the buffer. Reports a buffer changed event.

      Equivalent to replace(0,getLength(),contents).

      Has no effect if this buffer is read-only or if the buffer is closed.

      Angegeben von:
      setContents in Schnittstelle IBuffer
      Parameter:
      newContents - the new contents of this buffer as a String
      Siehe auch:
    • setReadOnly

      protected void setReadOnly(boolean readOnly)
      Sets this Buffer to be read only.
    • toString

      public String toString()
      Setzt außer Kraft:
      toString in Klasse Object