01: /*
02: * Copyright 2004 Outerthought bvba and Schaubroeck nv
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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;
21: import java.util.GregorianCalendar;
22:
23: public final class BookInstanceMetaData {
24: private final Date createdOn;
25: private final long createdBy;
26: private String bookPath;
27: private String label;
28:
29: public BookInstanceMetaData(String label, Date createdOn,
30: long createdBy) {
31: if (createdOn == null)
32: throw new IllegalArgumentException(
33: "createdOn parameter can not be null");
34: if (label == null)
35: throw new IllegalArgumentException(
36: "label parameter can not be null");
37: this .createdOn = createdOn;
38: this .createdBy = createdBy;
39: this .label = label;
40: }
41:
42: public Date getCreatedOn() {
43: return createdOn;
44: }
45:
46: public long getCreatedBy() {
47: return createdBy;
48: }
49:
50: public String getBookPath() {
51: return bookPath;
52: }
53:
54: public String getLabel() {
55: return label;
56: }
57:
58: public void setBookPath(String bookPath) {
59: this .bookPath = bookPath;
60: }
61:
62: public void setLabel(String label) {
63: this .label = label;
64: }
65:
66: public BookInstanceMetaDataDocument getXml() {
67: BookInstanceMetaDataDocument document = BookInstanceMetaDataDocument.Factory
68: .newInstance();
69: BookInstanceMetaDataDocument.BookInstanceMetaData metaDataXml = document
70: .addNewBookInstanceMetaData();
71: metaDataXml.setLabel(label);
72: metaDataXml.setCreatedBy(createdBy);
73: GregorianCalendar calendar = new GregorianCalendar();
74: calendar.setTime(createdOn);
75: metaDataXml.setCreatedOn(calendar);
76: if (bookPath != null)
77: metaDataXml.setBookPath(bookPath);
78: return document;
79: }
80:
81: public Object clone() {
82: BookInstanceMetaData clone = new BookInstanceMetaData(label,
83: createdOn, createdBy);
84: clone.bookPath = bookPath;
85: return clone;
86: }
87: }
|