BufferManagerImpl (jEdit API Documentation)

Package org.gjt.sp.jedit.manager

## Class BufferManagerImpl

- java.lang.Object
- - org.gjt.sp.jedit.manager.BufferManagerImpl

- All Implemented Interfaces:
    `BufferManager`

      public class BufferManagerImpl
      extends java.lang.Object
      implements BufferManager

  This class contains buffer management code, those methods are not public and must only be used by jEdit. The public interface is `BufferManager`
  Since:
    5.6pre1

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static Buffer[]` | `EMPTY_BUFFER_ARRAY` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `BufferManagerImpl()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `java.util.Optional<Buffer>` | `_getBuffer​(java.lang.String path)` | Returns the buffer with the specified path name.
    `void` | `addBufferToList​(Buffer buffer)` |
    `void` | `checkBufferStatus​(View view, boolean currentBuffer, boolean autoReload)` | Checks buffer status on disk and shows the dialog box informing the user that buffers changed on disk, if necessary.
    `void` | `closeAllBuffers​(View view, boolean isExiting, boolean autosaveUntitled, boolean saveRecent, boolean persistentMarkers)` |
    `void` | `forEach​(java.util.function.Consumer<? super Buffer> action)` | Performs the given action for each buffer.
    `java.util.Optional<Buffer>` | `getBuffer​(java.lang.String path)` | Returns the buffer with the specified path name.
    `java.lang.Object` | `getBufferListLock()` |
    `java.util.List<Buffer>` | `getBuffers()` | Returns an array of all open buffers from any View.
    `java.util.List<Buffer>` | `getBuffers​(java.util.function.Predicate<Buffer> predicate)` |
    `java.util.List<Buffer>` | `getDirtyBuffers()` |
    `Buffer` | `getFirst()` |
    `Buffer` | `getLast()` |
    `int` | `getNextUntitledBufferId()` |
    `java.util.List<Buffer>` | `getNonUntitledDirtyBuffers()` |
    `java.util.List<Buffer>` | `getTitledBuffers()` |
    `java.util.List<Buffer>` | `getUntitledBuffers()` |
    `void` | `removeBuffer​(Buffer buffer)` |
    `void` | `removeBufferFromList​(Buffer buffer)` |
    `void` | `setSortBuffers​(boolean sortBuffers)` |
    `void` | `setSortByName​(boolean sortByName)` |
    `int` | `size()` | Returns the number of open buffers.
    `void` | `updateBufferHash​(Buffer buffer)` | To be used by jEdit class only
    `void` | `updatePosition​(java.lang.String oldPath, Buffer buffer)` | If buffer sorting is enabled, this repositions the buffer.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### EMPTY_BUFFER_ARRAY

          public static final Buffer[] EMPTY_BUFFER_ARRAY

  - ### Constructor Detail

    - #### BufferManagerImpl

          public BufferManagerImpl()

  - ### Method Detail

    - #### getBufferListLock

          public java.lang.Object getBufferListLock()

    - #### getBuffers

          public java.util.List<Buffer> getBuffers()

      Returns an array of all open buffers from any View. This method is synchronized on the bufferList, if you expect your action might be slow
      Specified by:
        `getBuffers` in interface `BufferManager`
      Returns:
        a list of all open buffers
      See Also:
        `View.getBuffers()`

    - #### getBuffers

          public java.util.List<Buffer> getBuffers​(java.util.function.Predicate<Buffer> predicate)

    - #### getTitledBuffers

          public java.util.List<Buffer> getTitledBuffers()

      Specified by:
        `getTitledBuffers` in interface `BufferManager`

    - #### getUntitledBuffers

          public java.util.List<Buffer> getUntitledBuffers()

      Specified by:
        `getUntitledBuffers` in interface `BufferManager`

    - #### getNonUntitledDirtyBuffers

          public java.util.List<Buffer> getNonUntitledDirtyBuffers()

      Specified by:
        `getNonUntitledDirtyBuffers` in interface `BufferManager`

    - #### getDirtyBuffers

          public java.util.List<Buffer> getDirtyBuffers()

      Specified by:
        `getDirtyBuffers` in interface `BufferManager`

    - #### forEach

          public void forEach​(java.util.function.Consumer<? super Buffer> action)

      Performs the given action for each buffer. This method is synchronized on the bufferList, if you expect your action might be slow, you can retrieve an array of the buffers.
      Specified by:
        `forEach` in interface `BufferManager`
      Parameters:
        `action` - The action to be performed for each element
      Throws:
        `java.lang.NullPointerException` - if the specified action is null

    - #### size

          public int size()

      Returns the number of open buffers.
      Specified by:
        `size` in interface `BufferManager`

    - #### getFirst

          public Buffer getFirst()

      Specified by:
        `getFirst` in interface `BufferManager`

    - #### getLast

          public Buffer getLast()

    - #### checkBufferStatus

          public void checkBufferStatus​(View view,
                                        boolean currentBuffer,
                                        boolean autoReload)

      Checks buffer status on disk and shows the dialog box informing the user that buffers changed on disk, if necessary.
      Parameters:
        `view` - The view
        `currentBuffer` - indicates whether to check only the current buffer
        `autoReload` - true if we autoreload
      Since:
        jEdit 4.2pre1

    - #### setSortBuffers

          public void setSortBuffers​(boolean sortBuffers)

    - #### setSortByName

          public void setSortByName​(boolean sortByName)

    - #### getBuffer

          public java.util.Optional<Buffer> getBuffer​(java.lang.String path)

      Returns the buffer with the specified path name. The path name must be an absolute path. This method automatically resolves symbolic links. If performance is critical, cache the canonical path and call `_getBuffer(String)` instead.
      Specified by:
        `getBuffer` in interface `BufferManager`
      Parameters:
        `path` - The path name
      Returns:
        the searched buffer, or null if it is not already open
      See Also:
        `MiscUtilities.constructPath(String,String)`, `MiscUtilities.resolveSymlinks(String)`

    - #### _getBuffer

          public java.util.Optional<Buffer> _getBuffer​(java.lang.String path)

      Returns the buffer with the specified path name. The path name must be an absolute, canonical, path.
      Parameters:
        `path` - The path name
      Returns:
        the searched buffer, or null if it is not already open
      See Also:
        `MiscUtilities.constructPath(String,String)`, `MiscUtilities.resolveSymlinks(String)`, `getBuffer(String)`

    - #### getNextUntitledBufferId

          public int getNextUntitledBufferId()

      Specified by:
        `getNextUntitledBufferId` in interface `BufferManager`

    - #### updateBufferHash

          public void updateBufferHash​(Buffer buffer)

      To be used by jEdit class only

    - #### removeBufferFromList

          public void removeBufferFromList​(Buffer buffer)

    - #### addBufferToList

          public void addBufferToList​(Buffer buffer)

    - #### updatePosition

          public void updatePosition​(java.lang.String oldPath,
                                     Buffer buffer)

      If buffer sorting is enabled, this repositions the buffer.

    - #### removeBuffer

          public void removeBuffer​(Buffer buffer)

    - #### closeAllBuffers

          public void closeAllBuffers​(View view,
                                      boolean isExiting,
                                      boolean autosaveUntitled,
                                      boolean saveRecent,
                                      boolean persistentMarkers)