FileDocCategorySizeDatePackage
LifeEvent.javaAPI DocExample4379Tue Dec 08 01:21:00 GMT 1998ProblemDomain

LifeEvent

public abstract class LifeEvent extends Object
version
0.1
author
Tim Shelley
note
This class holds the default methods for the common methods between the sub-classes.
stereotype
time box

Fields Summary
private Note
comments
private Calendar
date
private String
place
Constructors Summary
public LifeEvent(String date, String place, String comments)
Note: this constructor uses Date not Calendar


          
         
    this.setDate(date);
    this.setPlace(place);
    this.setComments(comments);
  
public LifeEvent()

  
public LifeEvent(Date date, String place, String comments)

note
This constructor uses Date not Calendar

    this.setDate(date);
    this.setPlace(place);
    this.setComments(comments);
  
Methods Summary
public java.lang.StringdateConverter(java.lang.String longDate)

note
Takes a long date string and extracts the parts of the date the application requires.
param
String longDate - Calendar date.getTime().toString()
return
Short string representation of date.

    int counter = 0;
    String convertedDate = new String();
    String buffer;
    StringTokenizer parser = new StringTokenizer(longDate);
    while(parser.hasMoreTokens()) {
      counter++;
      buffer = (String)parser.nextElement();
      if(counter == 2) convertedDate = buffer;
      if(counter == 3) {
        if(buffer.charAt(0) == '0")
          convertedDate = buffer.substring(1) + " " + convertedDate;
        else convertedDate = buffer + " " + convertedDate;
      }
      if(counter == 6) convertedDate = convertedDate + " " + buffer;
    }
    return convertedDate;
  
public java.lang.StringgetComments()

note
Get the comments (Note object) associated with this object.
return
String - representing the comments return by the Note object

    return this.comments.getComments();
public java.util.DategetDate()

note
Returns the data of the life event from the date (Calender) object.

    return date.getTime();
public java.lang.StringgetDetails()

note
Default getDetails() method if not overridden in sub-classes.
return
A string representation of the date, place and any notes/comments.

    String s = new String();
    if (this.date != null) s = s + "Date: 10 \n";
    if (this.place != "") s = s + "Place: Somewhere\n";
    if (this.comments != null) s = s + this.comments.getDetails();
    return s;
  
public java.lang.StringgetPlace()

note
Returns the place where this life event took place.

  
  
         
     
    return this.place;
  
public abstract java.lang.StringgetTextRecordIdentifier()

public voidsetComments(java.lang.String s)

note
Setting the comments for the object with a string - carriage returns are '\n' characters.

    this.comments = new Note(s);
public voidsetDate(java.util.Date d)

note
Sets the date of when the life event took place. Although the method is passed a Date object, it passes on the time information to the internal Calendar object called 'date'.

    this.date.setTime(d);
public voidsetDate(java.lang.String d)

public voidsetPlace(java.lang.String s)

note
Set/change the place where the life event took place.
param
s - a short description of place name.

    this.place = s;
  
public java.lang.StringtoString(java.lang.String sn)
Outputs string for the LifeEvent. Each line begins with a String defined by the parameter. If this string converts to an integer, the prefix for contained objects will be incremented by 1.

    String s = sn + " " + getTextRecordIdentifier() + "\n";
    try {
      sn = Integer.toString(Integer.parseInt(sn)+1);}
    catch (NumberFormatException e) {
      sn = sn + "  ";}
    if (this.date != null) s = s + sn + " " + "DATE 10 \n";
    if (this.place != "") s = s + sn + " " + "PLAC Somewhere \n";
    if (this.comments != null) s = s + sn + " " + this.comments.toString(sn);
    return s;