View Javadoc

1   // $Id: DescriptiveObject.java,v 1.4 2004/06/09 19:26:40 powerpete Exp $
2   // [JMP, 25.12.2003] Created this file.
3   package com.pnpconsult.zeiterfassung.model;
4   
5   import java.io.Serializable;
6   
7   import com.pnpconsult.zeiterfassung.util.Description;
8   
9   /***
10   * @author <a href="mailto:powerpete@users.sf.net">M. Petersen</a>
11   * @version $Id: DescriptiveObject.java,v 1.4 2004/06/09 19:26:40 powerpete Exp $
12   */
13  public class DescriptiveObject implements Comparable, Serializable
14  {
15      protected Description buildDescription()
16      {
17          return null;
18      }
19  
20      /***
21       * @see java.lang.Comparable#compareTo(java.lang.Object)
22       */
23      public int compareTo(Object o)
24      {
25          if (o == null)
26          {
27              return 1;
28          }
29          Description d1 = buildDescription();
30          Description d2 = ((DescriptiveObject) o).buildDescription();
31          if (d1 == null)
32          {
33              if (d2 == null)
34              {
35                  return 0;
36              }
37              return -1;
38          }
39          if (d2 == null)
40          {
41              return 1;
42          }
43          else
44          {
45              return d1.compareTo(d2);
46          }
47      }
48      
49      public String toString()
50      {
51          return String.valueOf(buildDescription());
52      }
53  }