KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > repository > Version


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.repository;
17
18 import org.outerx.daisy.x10.VersionDocument;
19
20 import java.util.Date JavaDoc;
21
22 /**
23  * A version of a {@link Document}.
24  *
25  * <p>This object provides access to the all versioned information of a document,
26  * for a specific version of the document. Versions cannot be modified (except
27  * their state, see below),
28  * they are read-only. See {@link Document#save()} for when a version is created.
29  *
30  * <p>The methods {@link #getParts()}, {@link #getFields()} and
31  * {@link #getLinks()} can throw a RepositoryException because that information
32  * may sometimes be loaded lazily (depending on the implementation).
33  *
34  * <p>A version can have a state of either 'publish' or 'draft'. This state
35  * can be changed at any time.
36  */

37 public interface Version {
38     /**
39      * The id of the version, which is a sequence number, the first version
40      * being 1, then 2, and so on.
41      */

42     public long getId();
43
44     /**
45      * Returns the date when this version was created.
46      */

47     public Date JavaDoc getCreated();
48
49     /**
50      * Returns the id of the user that created this version. You can
51      * retrieve full information on the user via the {@link org.outerj.daisy.repository.user.UserManager}.
52      */

53     public long getCreator();
54
55     /**
56      * Returns the name of the document as it was on the time this version was created.
57      */

58     public String JavaDoc getDocumentName();
59
60     /**
61      * Returns the parts contained in this version.
62      */

63     public Parts getParts() throws RepositoryException;
64
65     /**
66      * Returns the parts contained in this version, in the order as they are
67      * defined in the document type of the document. Any parts contained in
68      * this version that are not present in the current document type are
69      * returned in no specific order, but after the ordered parts.
70      */

71     public Parts getPartsInOrder() throws RepositoryException;
72
73     /**
74      * Get a part by id.
75      *
76      * <p>Throws a PartNotFoundException if this version has no part with
77      * the specified id. Use {@link #hasPart(long)} to check if this version
78      * has the wanted part.
79      */

80     public Part getPart(long typeId);
81
82     /**
83      * Checks if this version has a certain part.
84      */

85     public boolean hasPart(long typeId);
86
87     /**
88      * Checks if this version has a certain part.
89      */

90     public boolean hasPart(String JavaDoc typeName);
91
92     /**
93      * Get a part by name.
94      *
95      * <p>Throws a PartNotFoundException if this version has not part with
96      * the specified name.
97      */

98     public Part getPart(String JavaDoc typeName) throws RepositoryException;
99
100     /**
101      * Returns the fields contained in this version.
102      */

103     public Fields getFields() throws RepositoryException;
104
105     /**
106      * Returns the fields contained in this version, in the order as they are
107      * defined in the document type of the document. Any fields contained in
108      * this version that are not present in the current document type are
109      * returned in no specific order, but after the ordered fields.
110      */

111     public Fields getFieldsInOrder() throws RepositoryException;
112
113     /**
114      * Get a field by id.
115      *
116      * <p>Throws a FieldNotFoundException if this version has no field with
117      * the specified id. Use {@link #hasField(long)} to check if this version
118      * has the wanted field.
119      */

120     public Field getField(long fieldTypeId) throws FieldNotFoundException;
121
122     /**
123      * Checks if this version has a certain field.
124      */

125     public boolean hasField(long fieldTypeId);
126
127     /**
128      * Get the links.
129      */

130     public Links getLinks() throws RepositoryException;
131
132     /**
133      * Get an XML document containing information about this version, but without
134      * the actual versioned content, thus no fields, parts, links etc. This is
135      * useful when retrieving an overview of all versions of a document.
136      */

137     public VersionDocument getShallowXml();
138
139     /**
140      * Get an XML document describing the version.
141      */

142     public VersionDocument getXml() throws RepositoryException;
143
144     /**
145      * Changes the state of this version.
146      *
147      * <p>This method has immediate effect, it is
148      * not needed to call document.save() after calling this method.
149      */

150     public void setState(VersionState state) throws RepositoryException;
151
152     /**
153      * Returns the current state of this version. This is the state as it
154      * was when this version object was loaded, it may have changed in the
155      * meantime.
156      */

157     public VersionState getState();
158
159     /**
160      * Get the id of the user that last changed the state of this version.
161      */

162     public long getStateLastModifier();
163
164     /**
165      * Get the time at which the state of this version was last changed.
166      */

167     public Date JavaDoc getStateLastModified();
168
169     /**
170      * Get the sum of the size of the parts in this version.
171      */

172     public long getTotalSizeOfParts();
173 }
174
Popular Tags