com.rapidminer.operator.ports.impl
Class AbstractPort

java.lang.Object
  extended by com.rapidminer.tools.AbstractObservable<Port>
      extended by com.rapidminer.operator.ports.impl.AbstractPort
All Implemented Interfaces:
Port, Observable<Port>
Direct Known Subclasses:
InputPortImpl, OutputPortImpl

public abstract class AbstractPort
extends AbstractObservable<Port>
implements Port

Implemented by keeping a weak reference to the data that can be cleared at any time by the garbage collector. In addition to the week reference, this class also keeps a hard reference to the data, freeing it when calling freeMemory().

Author:
Simon Fischer

Field Summary
 
Fields inherited from interface com.rapidminer.operator.ports.Port
CLEAR_ALL, CLEAR_ALL_ERRORS, CLEAR_ALL_METADATA, CLEAR_DATA, CLEAR_META_DATA_ERRORS, CLEAR_METADATA, CLEAR_REAL_METADATA, CLEAR_SIMPLE_ERRORS
 
Constructor Summary
protected AbstractPort(Ports<? extends Port> owner, java.lang.String name, boolean simulatesStack)
           
 
Method Summary
 void addError(MetaDataError metaDataError)
          Report an error in the current process setup.
 void clear(int clearFlags)
          Clears data, meta data and errors at this port.
 java.util.List<QuickFix> collectQuickFixes()
          Returns a sorted list of all quick fixes applicable for this port.
 void freeMemory()
          Releases of the hard reference.
 IOObject getAnyDataOrNull()
          Returns the last object delivered to the connected InputPort or received from the connected OutputPort.
<T extends IOObject>
T
getData()
          Same as #getData(true).
<T extends IOObject>
T
getData(java.lang.Class<T> desiredClass)
          This method returns the object of the desired class or throws an UserError if no object is present or cannot be casted to the desiredClass
<T extends IOObject>
T
getDataOrNull()
          Returns the last object delivered to the connected InputPort or received from the connected OutputPort
 java.util.Collection<MetaDataError> getErrors()
          Returns the set of errors added since the last clear errors.
 java.lang.String getName()
          A human readable, unique (operator scope) name for the port.
 Ports<? extends Port> getPorts()
          Returns the set of ports to which this port belongs.
 java.lang.String getShortName()
          Gets a three letter abbreviation of the port's name.
 java.lang.String getSpec()
          Returns the string "OperatorName.PortName".
 boolean isLocked()
           
 void lock()
          Locks the port so port extenders do not remove the port if disconnected.
protected  void setData(IOObject object)
           
protected  void setName(java.lang.String newName)
          Don't use this method.
 boolean simulatesStack()
          Indicates whether ExecutionUnit#autoWire() should simulate the pre RM 5.0 stack behaviour of IOContainer.
 java.lang.String toString()
           
 void unlock()
           
 
Methods inherited from class com.rapidminer.tools.AbstractObservable
addObserver, addObserverAsFirst, fireUpdate, fireUpdate, removeObserver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.rapidminer.operator.ports.Port
getDescription, getMetaData, isConnected
 
Methods inherited from interface com.rapidminer.tools.Observable
addObserver, addObserverAsFirst, removeObserver
 

Constructor Detail

AbstractPort

protected AbstractPort(Ports<? extends Port> owner,
                       java.lang.String name,
                       boolean simulatesStack)
Method Detail

setData

protected final void setData(IOObject object)

getData

public final <T extends IOObject> T getData()
                                 throws UserError
Description copied from interface: Port
Same as #getData(true).

Specified by:
getData in interface Port
Throws:
UserError - if data is missing.

getAnyDataOrNull

public final IOObject getAnyDataOrNull()
Description copied from interface: Port
Returns the last object delivered to the connected InputPort or received from the connected OutputPort. Never throws an exception.

Specified by:
getAnyDataOrNull in interface Port

getData

public final <T extends IOObject> T getData(java.lang.Class<T> desiredClass)
                                 throws UserError
Description copied from interface: Port
This method returns the object of the desired class or throws an UserError if no object is present or cannot be casted to the desiredClass. * @throws UserError if data is missing or of wrong class.

Specified by:
getData in interface Port
Throws:
UserError

getDataOrNull

public final <T extends IOObject> T getDataOrNull()
                                       throws UserError
Description copied from interface: Port
Returns the last object delivered to the connected InputPort or received from the connected OutputPort

Specified by:
getDataOrNull in interface Port
Throws:
UserError - If data is not of the requested type.

getName

public final java.lang.String getName()
Description copied from interface: Port
A human readable, unique (operator scope) name for the port.

Specified by:
getName in interface Port

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getPorts

public Ports<? extends Port> getPorts()
Description copied from interface: Port
Returns the set of ports to which this port belongs.

Specified by:
getPorts in interface Port

getShortName

public java.lang.String getShortName()
Description copied from interface: Port
Gets a three letter abbreviation of the port's name.

Specified by:
getShortName in interface Port

setName

protected void setName(java.lang.String newName)
Don't use this method. Use Ports.renamePort(Port,String).


addError

public void addError(MetaDataError metaDataError)
Description copied from interface: Port
Report an error in the current process setup.

Specified by:
addError in interface Port

getErrors

public java.util.Collection<MetaDataError> getErrors()
Description copied from interface: Port
Returns the set of errors added since the last clear errors.

Specified by:
getErrors in interface Port

clear

public void clear(int clearFlags)
Description copied from interface: Port
Clears data, meta data and errors at this port.

Specified by:
clear in interface Port
Parameters:
clearFlags - disjunction of the CLEAR_XX constants.

collectQuickFixes

public java.util.List<QuickFix> collectQuickFixes()
Description copied from interface: Port
Returns a sorted list of all quick fixes applicable for this port.

Specified by:
collectQuickFixes in interface Port

getSpec

public java.lang.String getSpec()
Description copied from interface: Port
Returns the string "OperatorName.PortName".

Specified by:
getSpec in interface Port

simulatesStack

public boolean simulatesStack()
Description copied from interface: Port
Indicates whether ExecutionUnit#autoWire() should simulate the pre RM 5.0 stack behaviour of IOContainer. Normally, ports should return true here. However, ports created by PortPairExtenders should return false here, since (most of the time) they only pass data through rather adding new IOObjects to the IOContainer. TODO: delete

Specified by:
simulatesStack in interface Port

isLocked

public boolean isLocked()
Specified by:
isLocked in interface Port
See Also:
Port.lock()

unlock

public void unlock()
Specified by:
unlock in interface Port
See Also:
Port.lock()

lock

public void lock()
Description copied from interface: Port
Locks the port so port extenders do not remove the port if disconnected. unlocks it.

Specified by:
lock in interface Port

freeMemory

public void freeMemory()
Releases of the hard reference.

Specified by:
freeMemory in interface Port


Copyright © 2001-2009 by Rapid-I