com.avian.foods.basefoods
Class DefaultFood

java.lang.Object
  extended by com.avian.foods.basefoods.DefaultFood
All Implemented Interfaces:
Manna
Direct Known Subclasses:
BlackFood, BlueFood, BrownFood, GreenFood, OrangeFood, PurpleFood, RedFood, WhiteFood, YellowFood

public class DefaultFood
extends java.lang.Object
implements Manna

DefaultFood implements the Manna interface, providing simple instances of each required method. The process method simply does a little housekeeping, counts to 1 million, does a little more housekeeping, and then completes. Real foods types will have to implement more sophisticated process methods.


Field Summary
protected  java.lang.String contents
          The thing that gets worked on by all the different birds.
protected  java.lang.String description
          Description of this food
protected  java.lang.String mannaHistory
          History of this food and who ate it
protected  MilliTimeString mts
          A helper object that hides the details of formatting millisecond time Strings.
protected  java.lang.String name
          Name of this food
 
Constructor Summary
DefaultFood()
          Default constructor for DefaultFood objects.
DefaultFood(java.lang.String food)
          Other constructor for DefaultFood objects.
DefaultFood(java.lang.String historyMsg, boolean magicallyAdded)
          Another constructor for DefaultFood objects.
 
Method Summary
 java.lang.String getDescription()
          Gets the description of this food object.
 java.lang.String getName()
          Gets the name of this food object.
 void setDescription(java.lang.String description)
          Sets the description of this food object.
 void setName(java.lang.String newName)
          Sets the name of this food object to newName.
 java.lang.String toHistoryString()
          Gets the history of this individual food chunk.
 java.lang.String toHistoryStringShort()
          Gets a short chunk of text that describes the last event or several events that happened to this food object.
 java.lang.String toString()
          Gets a String that represents the contents of this food object
 java.lang.String toStringShort()
          Gets a chunk of text not to exceed 70 characters in length.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
Name of this food


description

protected java.lang.String description
Description of this food


mannaHistory

protected java.lang.String mannaHistory
History of this food and who ate it


contents

protected java.lang.String contents
The thing that gets worked on by all the different birds. In this case, it is simply a String. In real cases, this could be some complicated Object or a database result object.


mts

protected MilliTimeString mts
A helper object that hides the details of formatting millisecond time Strings. This object helps to prevent the formatting from being repeated throughout the code base.

Constructor Detail

DefaultFood

public DefaultFood()
Default constructor for DefaultFood objects. It sets all the fields to reasonable values.


DefaultFood

public DefaultFood(java.lang.String food)
Other constructor for DefaultFood objects. It sets all the fields to reasonable values. The food object that is passed in is the line that was read from a file

Parameters:
food - is the line that was read from a file as a String

DefaultFood

public DefaultFood(java.lang.String historyMsg,
                   boolean magicallyAdded)
Another constructor for DefaultFood objects. It sets all the fields to reasonable values. This constructor should be used if the calling bird created this food out of nothing. The food chain has to start somewhere and if a bird eats DefaultFood and it doesn't exist in the TupleTree, it gets created automatically with this constructor.

Parameters:
historyMsg - is the event description to add to the food's history
magicallyAdded - is true if the food should be magically created.
Method Detail

toHistoryString

public java.lang.String toHistoryString()
Gets the history of this individual food chunk.

Returns:
String history of this individual food object

toHistoryStringShort

public java.lang.String toHistoryStringShort()
Gets a short chunk of text that describes the last event or several events that happened to this food object. This is useful because it allows a 1-line quickie snapshot of latest events to be displayed on screen.

Returns:
String that is a substring of the end (or latest portion) of the history of this food object's history.

toStringShort

public java.lang.String toStringShort()
Gets a chunk of text not to exceed 70 characters in length. This string is used to easily display some of the contents of this food object

Returns:
String not to exceed 70 characters

toString

public java.lang.String toString()
Gets a String that represents the contents of this food object

Overrides:
toString in class java.lang.Object
Returns:
String representation of the contents of this food object

getName

public java.lang.String getName()
Gets the name of this food object.

Specified by:
getName in interface Manna
Returns:
String name of this food object.

setName

public void setName(java.lang.String newName)
Sets the name of this food object to newName.

Specified by:
setName in interface Manna
Parameters:
newName - String value that will become the new name for this food object.

getDescription

public java.lang.String getDescription()
Gets the description of this food object.

Specified by:
getDescription in interface Manna
Returns:
String description of this food object.

setDescription

public void setDescription(java.lang.String description)
Sets the description of this food object.

Specified by:
setDescription in interface Manna
Parameters:
description - String that describes this food object.