Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.compare
Class BufferedContent


java.lang.Object
  extended by 
org.eclipse.compare.BufferedContent
All Implemented Interfaces:
IContentChangeNotifier, IStreamContentAccessor
Direct Known Subclasses:
ResourceNode

public abstract class BufferedContent
extends Object
implements IContentChangeNotifier, IStreamContentAccessor

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.

See Also:
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 IContentChangeListeners 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

BufferedContent

protected BufferedContent()
Creates a buffered stream content accessor.

Method Detail

getContents

public 
InputStream getContents()
                        throws 
CoreException
Description copied from interface: IStreamContentAccessor
Returns an open 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.

Specified by:
getContents in interface IStreamContentAccessor
Returns:
an input stream containing the contents of this object
Throws:
CoreException - if the contents of this object could not be accessed

createStream

protected abstract 
InputStream createStream()
                                     throws 
CoreException
Creates and returns a stream for reading the contents.

Subclasses must implement this method.

Returns:
the stream from which the content is read
Throws:
CoreException - if the contents could not be accessed

setContent

public void setContent(byte[] contents)
Sets the contents. Registered content change listeners are notified.

Parameters:
contents - the new contents

getContent

public byte[] getContent()
Returns the contents as an array of bytes.

Returns:
the contents as an array of bytes, or null if the contents could not be accessed

discardBuffer

public void discardBuffer()
Discards the buffered content.


addContentChangeListener

public void addContentChangeListener(
IContentChangeListener listener)
Description copied from interface: IContentChangeNotifier
Adds a content change listener to this notifier. Has no effect if an identical listener is already registered.

Specified by:
addContentChangeListener in interface IContentChangeNotifier
Parameters:
listener - a content changed listener

removeContentChangeListener

public void removeContentChangeListener(
IContentChangeListener listener)
Description copied from interface: IContentChangeNotifier
Removes the given content changed listener from this notifier. Has no effect if the listener is not registered.

Specified by:
removeContentChangeListener in interface IContentChangeNotifier
Parameters:
listener - a content changed listener

fireContentChanged

protected void fireContentChanged()
Notifies all registered IContentChangeListeners of a content change.


Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire