edu.wpi.cs.cs509.clipboard
Interface IClipboard

All Known Subinterfaces:
IClipboardGUI
All Known Implementing Classes:
Clipboard

public interface IClipboard

Interface to a Clipboard component.

  1. Retrieve the most recent Item on the clipboard
  2. Retrieve the most recent Item on the clipboard that is a sub-type of B
  3. Retrieve the nth item on the clipboard
  4. Retrieve the nth item on the clipboard that is a sub-type of B
  5. Return an Enumeration of Data Types on the Clipboard.
  6. Clear the Clipboard.

To properly encapsulate information within the component, we use factory methods to generate the parameters that external components need to pass into our component.

This interface is to be used by those components that require an API-interface to the clipboard component. If an Microsoft-Office-like Clipboard GUI is required, then the IClipboardGUI interface should be the means by which the clipboard is interacted.

Author:
George T. Heineman (heineman@cs.wpi.edu)

Method Summary
 void clear()
          Clear the contents of the clipboard
 boolean insert(IItem i)
          Inserts the given object conforming to the IItem interface into the clipboard.
 IDataType newDataTypeInstance(java.lang.String s)
          Constructs an object conforming to the IDataType interface given a String object.
 IItem newItemInstance(IDataType type, java.lang.Object o)
          Constructs an object conforming to the IItem interface given an IDataType and object
 IItem retrieve()
          Retrieves the last IItem inserted into the clipboard.
 IItem retrieve(IDataType type)
          Retrieves most recent IItem inserted into clipboard of given type.
 IItem retrieveNth(int n)
          Returns the nth last IItem inserted into the Clipboard
 IItem retrieveNth(int n, IDataType type)
          Returns the nth IItem in the clipboard that is a sub-type of given IDataType.
 java.util.Enumeration types()
          Return Enumeration of IDataType objects representing the clipboard contents
 

Method Detail

clear

public void clear()
Clear the contents of the clipboard

PRE: none
POST: clipboard is empty

Modified V1.1 to work with GUI


insert

public boolean insert(IItem i)
Inserts the given object conforming to the IItem interface into the clipboard.

PRE: none
POST: clipboard.size() = clipboard'.size() + 1. i is the next item to be retrieved.

Parameters:
i - edu.wpi.cs.cs509.graph.clipboard.Item
Returns:
true if Item successfully added.

newDataTypeInstance

public IDataType newDataTypeInstance(java.lang.String s)
                              throws ClipboardException
Constructs an object conforming to the IDataType interface given a String object.

Returns:
edu.wpi.cs.cs509.graph.clipboard.IDataType
Throws:
ClipboardException - If String refers to non-valid Java type.

newItemInstance

public IItem newItemInstance(IDataType type,
                             java.lang.Object o)
                      throws ClipboardException
Constructs an object conforming to the IItem interface given an IDataType and object

Parameters:
type - edu.wpi.cs.cs509.graph.clipboard.IDataType
o - java.lang.Object
Returns:
edu.wpi.cs.cs509.graph.clipboard.IItem
Throws:
ClipboardException - If type was not previously constructed by clipboard.

retrieve

public IItem retrieve()
               throws ClipboardException
Retrieves the last IItem inserted into the clipboard.

PRE: clipboard.size() > 1
POST: clipboard unchanged.

Returns:
edu.wpi.cs.cs509.graph.clipboard.IItem
Throws:
ClipboardException - If clipboard is empty.

retrieve

public IItem retrieve(IDataType type)
               throws ClipboardException
Retrieves most recent IItem inserted into clipboard of given type.

PRE: clipboard.size() > 1
POST: clipboard unchanged.

Parameters:
type - edu.wpi.cs.cs509.graph.clipboard.IDataType
Returns:
edu.wpi.cs.cs509.graph.clipboard.IItem
Throws:
ClipboardException - No such type exists in the clipboard.

retrieveNth

public IItem retrieveNth(int n)
                  throws ClipboardException
Returns the nth last IItem inserted into the Clipboard

PRE: clipboard.size() > n
POST: clipboard unchanged.

Parameters:
n - int
Returns:
edu.wpi.cs.cs509.graph.clipboard.IItem
Throws:
ClipboardException - If n is invalid given state of clipboard.

retrieveNth

public IItem retrieveNth(int n,
                         IDataType type)
                  throws ClipboardException
Returns the nth IItem in the clipboard that is a sub-type of given IDataType.

PRE: clipboard.size() > n
POST: clipboard unchanged.

Parameters:
n - int
type - edu.wpi.cs.cs509.graph.clipboard.IDataType
Returns:
edu.wpi.cs.cs509.graph.clipboard.IItem
Throws:
ClipboardException - the nth object of type does not exist in clipboard.

types

public java.util.Enumeration types()
Return Enumeration of IDataType objects representing the clipboard contents

PRE: none
POST: clipboard unchanged.

Returns:
java.util.Enumeration