View Javadoc

1   package org.neuclear.ledger;
2   
3   import java.io.Serializable;
4   import java.util.Date;
5   
6   /*
7    *  The NeuClear Project and it's libraries are
8    *  (c) 2002-2004 Antilles Software Ventures SA
9    *  For more information see: http://neuclear.org
10   *
11   *  This library is free software; you can redistribute it and/or
12   *  modify it under the terms of the GNU Lesser General Public
13   *  License as published by the Free Software Foundation; either
14   *  version 2.1 of the License, or (at your option) any later version.
15   *
16   *  This library is distributed in the hope that it will be useful,
17   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19   *  Lesser General Public License for more details.
20   *
21   *  You should have received a copy of the GNU Lesser General Public
22   *  License along with this library; if not, write to the Free Software
23   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24   */
25  
26  /***
27   * User: pelleb
28   * Date: Apr 19, 2004
29   * Time: 10:51:01 AM
30   */
31  public class Book implements Serializable {
32      protected Book() {
33      }
34  
35      public Book(String id, String nickname, String type, String source, Date registered, Date updated, String registrationid) {
36          this.id = id;
37          this.nickname = nickname;
38          this.type = type;
39          this.source = source;
40          this.registered = registered;
41          this.updated = updated;
42          this.registrationid = registrationid;
43      }
44  
45      public Book(String id, Date registered) {
46          this.id = id;
47          System.out.println("ID=" + id);
48          this.nickname = (id.length() == 32) ? (
49                  id.substring(0, 4) + '-'
50                  + id.substring(4, 8)
51                  ) : id;
52          this.type = "identity";
53          this.source = null;
54          this.registered = registered;
55          this.updated = registered;
56          this.registrationid = null;
57      }
58  
59      public String getId() {
60          return id;
61      }
62  
63      public String getNickname() {
64          return nickname;
65      }
66  
67      public String getType() {
68          return type;
69      }
70  
71      public String getSource() {
72          return source;
73      }
74  
75      public Date getRegistered() {
76          return registered;
77      }
78  
79      public Date getUpdated() {
80          return updated;
81      }
82  
83      public String getRegistrationId() {
84          return registrationid;
85      }
86  
87      public boolean equals(Object o) {
88          return o.getClass().equals(this.getClass()) && id.equals(((Book) o).getId());
89      }
90  
91      public int hashCode() {
92          return id.hashCode();
93      }
94  
95      protected String id;
96      protected String nickname;
97      protected String type;
98      protected String source;
99      protected Date registered;
100     protected Date updated;
101     protected String registrationid;
102 }