KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jalisto > samples > basic > data > Book


1 /*
2  * Jalisto - JAva LIght STOrage
3  * Copyright (C) 2000-2005 Xcalia http://www.xcalia.com
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18  *
19  * Xcalia
20  * 71, rue Desnouettes
21  * 75014 Paris - France
22  * http://www.xcalia.com
23  */

24 package org.objectweb.jalisto.samples.basic.data;
25
26 public class Book {
27
28     private String JavaDoc title;
29     private String JavaDoc author;
30     private int price;
31
32     public Book() {
33     }
34
35     public Book(String JavaDoc title, String JavaDoc author, int price) {
36         this.title = title;
37         this.author = author;
38         this.price = price;
39     }
40
41     public String JavaDoc getAuthor() {
42         return author;
43     }
44
45     public void setAuthor(String JavaDoc author) {
46         this.author = author;
47     }
48
49     public int getPrice() {
50         return price;
51     }
52
53     public void setPrice(int price) {
54         this.price = price;
55     }
56
57     public String JavaDoc getTitle() {
58         return title;
59     }
60
61     public void setTitle(String JavaDoc title) {
62         this.title = title;
63     }
64
65     public Object JavaDoc[] toArray() {
66         Object JavaDoc[] result = new Object JavaDoc[4];
67         result[0] = title;
68         result[1] = author;
69         result[2] = new Integer JavaDoc(price);
70         return result;
71     }
72
73     public static Book toBook(Object JavaDoc[] array) {
74         Book book = new Book();
75         book.setTitle((String JavaDoc) array[0]);
76         book.setAuthor((String JavaDoc) array[1]);
77         book.setPrice(((Integer JavaDoc) array[2]).intValue());
78         return book;
79     }
80 }
81
Popular Tags