KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > books > store > BookInstanceMetaData


1 /*
2  * Copyright 2004 Outerthought bvba and Schaubroeck nv
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.outerj.daisy.books.store;
17
18 import org.outerx.daisy.x10Bookstoremeta.BookInstanceMetaDataDocument;
19
20 import java.util.Date JavaDoc;
21 import java.util.GregorianCalendar JavaDoc;
22
23 public final class BookInstanceMetaData {
24     private final Date JavaDoc createdOn;
25     private final long createdBy;
26     private String JavaDoc bookPath;
27     private String JavaDoc label;
28
29     public BookInstanceMetaData(String JavaDoc label, Date JavaDoc createdOn, long createdBy) {
30         if (createdOn == null)
31             throw new IllegalArgumentException JavaDoc("createdOn parameter can not be null");
32         if (label == null)
33             throw new IllegalArgumentException JavaDoc("label parameter can not be null");
34         this.createdOn = createdOn;
35         this.createdBy = createdBy;
36         this.label = label;
37     }
38
39     public Date JavaDoc getCreatedOn() {
40         return createdOn;
41     }
42
43     public long getCreatedBy() {
44         return createdBy;
45     }
46
47     public String JavaDoc getBookPath() {
48         return bookPath;
49     }
50
51     public String JavaDoc getLabel() {
52         return label;
53     }
54
55     public void setBookPath(String JavaDoc bookPath) {
56         this.bookPath = bookPath;
57     }
58
59     public void setLabel(String JavaDoc label) {
60         this.label = label;
61     }
62
63     public BookInstanceMetaDataDocument getXml() {
64         BookInstanceMetaDataDocument document = BookInstanceMetaDataDocument.Factory.newInstance();
65         BookInstanceMetaDataDocument.BookInstanceMetaData metaDataXml = document.addNewBookInstanceMetaData();
66         metaDataXml.setLabel(label);
67         metaDataXml.setCreatedBy(createdBy);
68         GregorianCalendar JavaDoc calendar = new GregorianCalendar JavaDoc();
69         calendar.setTime(createdOn);
70         metaDataXml.setCreatedOn(calendar);
71         if (bookPath != null)
72             metaDataXml.setBookPath(bookPath);
73         return document;
74     }
75
76     public Object JavaDoc clone() {
77         BookInstanceMetaData clone = new BookInstanceMetaData(label, createdOn, createdBy);
78         clone.bookPath = bookPath;
79         return clone;
80     }
81 }
82
Popular Tags