|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.compare.BufferedContent
Abstract implementation for a buffered IStreamContentAccessor
.
Subclasses must implement the createStream
method
to connect the buffered content with a streamable source (e.g., a file).
As long as the contents of BufferedContent
is only retrieved as an input stream
(by means of getContents
) and the BufferedContent
is not modified (with
setContent
) no buffering takes place.
Buffering starts when either method getContent
or setContent
is called.
IContentChangeNotifier
,
IStreamContentAccessor
Constructor Summary | |
protected |
BufferedContent()
Creates a buffered stream content accessor. |
Method Summary | |
void |
addContentChangeListener(IContentChangeListener listener)
Adds a content change listener to this notifier. |
protected abstract InputStream |
createStream()
Creates and returns a stream for reading the contents. |
void |
discardBuffer()
Discards the buffered content. |
protected void |
fireContentChanged()
Notifies all registered IContentChangeListener s of a content change. |
byte[] |
getContent()
Returns the contents as an array of bytes. |
InputStream |
getContents()
Returns an open InputStream for this object which can be used to retrieve the object's content. |
void |
removeContentChangeListener(IContentChangeListener listener)
Removes the given content changed listener from this notifier. |
void |
setContent(byte[] contents)
Sets the contents. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected BufferedContent()
Method Detail |
public InputStream getContents() throws CoreException
IStreamContentAccessor
InputStream
for this object which can be used to retrieve the object's content.
The client is responsible for closing the stream when finished.
Returns null
if this object has no streamable contents.
getContents
in interface IStreamContentAccessor
CoreException
- if the contents of this object could not be accessedprotected abstract InputStream createStream() throws CoreException
Subclasses must implement this method.
CoreException
- if the contents could not be accessedpublic void setContent(byte[] contents)
contents
- the new contentspublic byte[] getContent()
null
if
the contents could not be accessedpublic void discardBuffer()
public void addContentChangeListener(IContentChangeListener listener)
IContentChangeNotifier
addContentChangeListener
in interface IContentChangeNotifier
listener
- a content changed listenerpublic void removeContentChangeListener(IContentChangeListener listener)
IContentChangeNotifier
removeContentChangeListener
in interface IContentChangeNotifier
listener
- a content changed listenerprotected void fireContentChanged()
IContentChangeListener
s of a content change.
|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |