KickJava   Java API By Example, From Geeks To Geeks.

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


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.PublicationsInfoDocument;
19
20 import java.util.Date JavaDoc;
21 import java.util.GregorianCalendar JavaDoc;
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 JavaDoc name;
29     private final String JavaDoc label;
30     private final String JavaDoc startResource;
31     private final long publishedBy;
32     private final Date JavaDoc publishedOn;
33     private String JavaDoc bookPackage;
34
35     public PublicationInfo(String JavaDoc name, String JavaDoc label, String JavaDoc startResource, String JavaDoc bookPackage, long publishedBy, Date JavaDoc publishedOn) {
36         if (name == null)
37             throw new IllegalArgumentException JavaDoc("name argument can not be null");
38         if (label == null)
39             throw new IllegalArgumentException JavaDoc("label argument can not be null");
40         if (startResource == null)
41             throw new IllegalArgumentException JavaDoc("startResource argument can not be null");
42         if (publishedOn == null)
43             throw new IllegalArgumentException JavaDoc("publishedOn argument can not be null");
44
45         this.name = name;
46         this.label = label;
47         this.startResource = startResource;
48         this.bookPackage = bookPackage;
49         this.publishedBy = publishedBy;
50         this.publishedOn = publishedOn;
51     }
52
53     public String JavaDoc getName() {
54         return name;
55     }
56
57     public String JavaDoc getLabel() {
58         return label;
59     }
60
61     public String JavaDoc getStartResource() {
62         return startResource;
63     }
64
65     public String JavaDoc getBookPackage() {
66         return bookPackage;
67     }
68
69     public long getPublishedBy() {
70         return publishedBy;
71     }
72
73     public Date JavaDoc getPublishedOn() {
74         return (Date JavaDoc)publishedOn.clone();
75     }
76
77     public PublicationsInfoDocument.PublicationsInfo.PublicationInfo getXml() {
78         PublicationsInfoDocument.PublicationsInfo.PublicationInfo infoXml = PublicationsInfoDocument.PublicationsInfo.PublicationInfo.Factory.newInstance();
79         infoXml.setName(name);
80         infoXml.setLabel(label);
81         infoXml.setStartResource(startResource);
82         if (bookPackage != null)
83             infoXml.setPackage(bookPackage);
84         infoXml.setPublishedBy(publishedBy);
85         GregorianCalendar JavaDoc calendar = new GregorianCalendar JavaDoc();
86         calendar.setTime(publishedOn);
87         infoXml.setPublishedOn(calendar);
88         return infoXml;
89     }
90 }
91
Popular Tags