de.dfki.mycbr.core
Class DefaultCaseBase

java.lang.Object
  extended by java.util.Observable
      extended by de.dfki.mycbr.core.DefaultCaseBase
All Implemented Interfaces:
ICaseBase, java.util.Observer

public final class DefaultCaseBase
extends java.util.Observable
implements ICaseBase

Class DefaultCasebase. Represents cases as a c attribute. Therefore, uses myCBR's default classes for internal case representation contained in the package de.dfki.mycbr.core.casebase.

Since:
myCBR 3.0.0
Author:
myCBR Team

Nested Class Summary
 
Nested classes/interfaces inherited from interface de.dfki.mycbr.core.ICaseBase
ICaseBase.Meta
 
Constructor Summary
DefaultCaseBase(Project p, java.lang.String cbName, int count)
           
 
Method Summary
 void addCase(Instance caze)
          Adds a new case to the list of known cases for the given description.
 Instance containsCase(java.lang.String caseName)
          Tells whether this case base contains a case with the given name.
 java.lang.String getAuthor()
           
 java.util.Collection<Instance> getCases()
          Returns the list of cases known for this case base
 java.util.Date getDate()
           
 java.text.DateFormat getDateFormat()
           
 java.lang.String getName()
          Returns the unique name of this case base.
 Project getProject()
          Returns the project this case base belongs to
 boolean removeCase(Instance c)
          Removes the given c attribute from the list of known cases.
 boolean removeCase(java.lang.String caseName)
          Removes the first case with the given name.
 void setAuthor(java.lang.String author)
           
 void setDate(java.util.Date date)
           
 void setName(java.lang.String cbName)
          Sets the name of this case base to the given name.
 void update(java.util.Observable arg0, java.lang.Object arg1)
          This observes all cases.
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultCaseBase

public DefaultCaseBase(Project p,
                       java.lang.String cbName,
                       int count)
                throws java.lang.Exception
Parameters:
cbName - the name of the case base
p - the project this cb should belong to
count - the number of cases expected for this case base
Throws:
java.lang.Exception - if name is null or empty or if the given project is null or already has a case base with this name
Method Detail

getCases

public java.util.Collection<Instance> getCases()
Returns the list of cases known for this case base

Specified by:
getCases in interface ICaseBase
Returns:
cases for the given description

addCase

public void addCase(Instance caze)
Adds a new case to the list of known cases for the given description. If there is no case known for this description yet, a new list is created and the new case is added to this list.

Specified by:
addCase in interface ICaseBase
Parameters:
caze - the case to be added to this case base

removeCase

public boolean removeCase(Instance c)
Removes the given c attribute from the list of known cases. Returns true, if att has really been a case and if this case has been removed successfully, false otherwise.

Parameters:
c - the case to be removed
Returns:
true, if the case has be removed successfully, false otherwise

getName

public java.lang.String getName()
Returns the unique name of this case base.

Specified by:
getName in interface ICaseBase
Returns:
the unique name of this case base

setName

public void setName(java.lang.String cbName)
             throws java.lang.Exception
Sets the name of this case base to the given name. This method should not be called when name is not unique.

Specified by:
setName in interface ICaseBase
Parameters:
cbName - the new name of this case base
Throws:
java.lang.Exception - if name is null or empty or there is a case base with this name in the corresponding project

containsCase

public Instance containsCase(java.lang.String caseName)
Tells whether this case base contains a case with the given name.

Specified by:
containsCase in interface ICaseBase
Parameters:
caseName - the name of the case to be checked for
Returns:
the case, if there is a case with the given name, null otherwise.

removeCase

public boolean removeCase(java.lang.String caseName)
Removes the first case with the given name. If there is no case with the given name, does nothing.

Specified by:
removeCase in interface ICaseBase
Parameters:
caseName - the name of the case to be removed

update

public void update(java.util.Observable arg0,
                   java.lang.Object arg1)
This observes all cases. On change of any of those cases, the observers of this are notified such that they can react on the changes.

Specified by:
update in interface java.util.Observer
Parameters:
arg0 - observable
arg1 - object

setAuthor

public void setAuthor(java.lang.String author)
Parameters:
author - the author to set

getAuthor

public java.lang.String getAuthor()
Returns:
the author

setDate

public void setDate(java.util.Date date)
Parameters:
date - the date to set

getDate

public java.util.Date getDate()
Returns:
the date

getDateFormat

public java.text.DateFormat getDateFormat()
Returns:
the current date format

getProject

public Project getProject()
Description copied from interface: ICaseBase
Returns the project this case base belongs to

Specified by:
getProject in interface ICaseBase
Returns:
the project this case base belongs to