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.PublicationsInfoDocument;
19:
20: import java.util.Date;
21: import java.util.GregorianCalendar;
22:
23: /**
24: * Holds information about a publication in the book instance.
25: * This is an immutable object.
26: */
27: public final class PublicationInfo {
28: private final String name;
29: private final String label;
30: private final String startResource;
31: private final long publishedBy;
32: private final Date publishedOn;
33: private String bookPackage;
34:
35: public PublicationInfo(String name, String label,
36: String startResource, String bookPackage, long publishedBy,
37: Date publishedOn) {
38: if (name == null)
39: throw new IllegalArgumentException(
40: "name argument can not be null");
41: if (label == null)
42: throw new IllegalArgumentException(
43: "label argument can not be null");
44: if (startResource == null)
45: throw new IllegalArgumentException(
46: "startResource argument can not be null");
47: if (publishedOn == null)
48: throw new IllegalArgumentException(
49: "publishedOn argument can not be null");
50:
51: this .name = name;
52: this .label = label;
53: this .startResource = startResource;
54: this .bookPackage = bookPackage;
55: this .publishedBy = publishedBy;
56: this .publishedOn = publishedOn;
57: }
58:
59: public String getName() {
60: return name;
61: }
62:
63: public String getLabel() {
64: return label;
65: }
66:
67: public String getStartResource() {
68: return startResource;
69: }
70:
71: public String getBookPackage() {
72: return bookPackage;
73: }
74:
75: public long getPublishedBy() {
76: return publishedBy;
77: }
78:
79: public Date getPublishedOn() {
80: return (Date) publishedOn.clone();
81: }
82:
83: public PublicationsInfoDocument.PublicationsInfo.PublicationInfo getXml() {
84: PublicationsInfoDocument.PublicationsInfo.PublicationInfo infoXml = PublicationsInfoDocument.PublicationsInfo.PublicationInfo.Factory
85: .newInstance();
86: infoXml.setName(name);
87: infoXml.setLabel(label);
88: infoXml.setStartResource(startResource);
89: if (bookPackage != null)
90: infoXml.setPackage(bookPackage);
91: infoXml.setPublishedBy(publishedBy);
92: GregorianCalendar calendar = new GregorianCalendar();
93: calendar.setTime(publishedOn);
94: infoXml.setPublishedOn(calendar);
95: return infoXml;
96: }
97: }
|