Package org.eclipse.handly.buffer
Class ChildBuffer
- java.lang.Object
-
- org.eclipse.handly.buffer.Buffer
-
- org.eclipse.handly.buffer.ChildBuffer
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,IBuffer
,ISnapshotProvider
,IReferenceCountable
public final class ChildBuffer extends Buffer
A child buffer is created on top of a parentIBuffer
and inherits the parent's contents initially, but is modified independently. Saving the child buffer propagates its contents to the parent buffer and also to the parent buffer's underlying resource.An instance of this class is safe for use by multiple threads.
-
-
Constructor Summary
Constructors Constructor Description ChildBuffer(IBuffer parent)
Creates a new child buffer instance on top of the given parent buffer and initializes it with the parent's contents.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addRef()
Spawns a new independent ownership of this object.protected void
doSave(IContext context, org.eclipse.core.runtime.IProgressMonitor monitor)
void
release()
Relinquishes an independent ownership of this object.-
Methods inherited from class org.eclipse.handly.buffer.Buffer
addListener, applyChange, createEmptyDocument, getDocument, getListeners, getSnapshot, getSupportedListenerMethods, isDirty, removeListener, save
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.handly.buffer.IBuffer
getAnnotationModel
-
Methods inherited from interface org.eclipse.handly.util.IReferenceCountable
close
-
-
-
-
Constructor Detail
-
ChildBuffer
public ChildBuffer(IBuffer parent)
Creates a new child buffer instance on top of the given parent buffer and initializes it with the parent's contents.The child buffer takes an independent ownership of the parent buffer to ensure that it is kept open as long as the child buffer is in use. The client still owns the parent buffer, but may release it immediately.
It is the client responsibility to
release
the created buffer after it is no longer needed.- Parameters:
parent
- the parent buffer (notnull
)- Throws:
java.lang.IllegalStateException
- if the child buffer could not be created because of an inappropriate state of the parent buffer
-
-
Method Detail
-
addRef
public void addRef()
Description copied from interface:IReferenceCountable
Spawns a new independent ownership of this object. Each successful call toaddRef()
must ultimately be followed by exactly one call toIReferenceCountable.release()
.- Specified by:
addRef
in interfaceIBuffer
- Specified by:
addRef
in interfaceIReferenceCountable
- Specified by:
addRef
in interfaceISnapshotProvider
- Overrides:
addRef
in classBuffer
-
release
public void release()
Description copied from interface:IReferenceCountable
Relinquishes an independent ownership of this object. Each independent ownership of the object must ultimately end with exactly one call to this method.- Specified by:
release
in interfaceIBuffer
- Specified by:
release
in interfaceIReferenceCountable
- Specified by:
release
in interfaceISnapshotProvider
- Overrides:
release
in classBuffer
- See Also:
IReferenceCountable.close()
-
-