KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > repository > schema > DocumentType


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.schema;
17
18 import org.outerj.daisy.repository.RepositoryException;
19 import org.outerx.daisy.x10.DocumentTypeDocument;
20
21 import java.util.Locale JavaDoc;
22 import java.util.Date JavaDoc;
23
24 /**
25  * Describes a type of document in the repository.
26  *
27  * <p>A document type has some general properties like a name (which must
28  * be unique), and a locale-sensitive label and description. Next to these,
29  * a DocumentType is associated with a number of {@link FieldType}s
30  * and {@link PartType}s.
31  *
32  * <p>The PartTypes and FieldTypes belonging to a DocumentType are
33  * ordered collections: the order in which you add them matters. To
34  * reorder them, first remove them all and re-add them.
35  *
36  * <p>A DocumentType object can be read-only, in which case all state-modifying
37  * methods (i.e. all setters and the save method) will throw a RuntimeException.
38  * Whether a DocumentType object is read-only or not depends on where you
39  * retrieved it from. The purpose of read-only DocumentType objects is for
40  * caching, i.e. the same object can be used by multiple users who only which
41  * to consult the DocumentType information, but not modify it.
42  */

43 public interface DocumentType {
44     public long getId();
45
46     /**
47      * Returns the PartTypes contained by this DocumentType. This is an ordered
48      * collection. The returned array is a newly created copy, thus modifying
49      * the order of the PartTypes in the array, or putting other ones in it, won't
50      * modify this DocumentType.
51      */

52     public PartTypeUse[] getPartTypeUses();
53
54     /**
55      * Adds a new PartType to this DocumentType.
56      *
57      * <p>The supplied PartType should already exist in the repository, i.e.
58      * it should have an id != -1.
59      *
60      * <p>The same PartType can be added only once.
61      *
62      * <p>A PartType is always added to the end, after the already existing PartTypes.
63      *
64      * @throws IllegalArgumentException if the partType's id is -1, or if
65      * it is already contained by this DocumentType.
66      */

67     public void addPartType(PartType partType, boolean required);
68
69     /**
70      * Removes all PartTypes.
71      */

72     public void clearPartTypeUses();
73
74     /**
75      * Checks if this DocumentType contains the PartType with the given ID.
76      */

77     public boolean hasPartType(long id);
78
79     public PartTypeUse getPartTypeUse(long id);
80
81     public FieldTypeUse[] getFieldTypeUses();
82
83     public boolean hasFieldType(long id);
84
85     public FieldTypeUse getFieldTypeUse(long id);
86
87     /**
88      * The suplied FieldType should already exist in the repository, i.e.
89      * it should have an id != -1.
90      *
91      * <p>A FieldType is always added to the end, after the already existing FieldTypes.
92      *
93      * <p>The same PartType can only be added once.
94      */

95     public void addFieldType(FieldType type, boolean required);
96
97     public void clearFieldTypeUses();
98
99     public String JavaDoc getName();
100
101     public void setName(String JavaDoc name);
102
103     public String JavaDoc getDescription(Locale JavaDoc locale);
104
105     public String JavaDoc getDescriptionExact(Locale JavaDoc locale);
106
107     /**
108      *
109      * @param description if null, the description for this locale will be removed.
110      */

111     public void setDescription(Locale JavaDoc locale, String JavaDoc description);
112
113     public void clearDescriptions();
114
115     /**
116      * Returns the locales for which a description is set.
117      */

118     public Locale JavaDoc[] getDescriptionLocales();
119
120     /**
121      *
122      * @param label if null, the label for this locale will be removed.
123      */

124     public void setLabel(Locale JavaDoc locale, String JavaDoc label);
125
126     /**
127      * Gets the label in the given locale, using the usual locale fallback
128      * mechanisms if not found in the exactly specified locale, and finally
129      * returning the documenttype's name if no label is available.
130      */

131     public String JavaDoc getLabel(Locale JavaDoc locale);
132
133     public String JavaDoc getLabelExact(Locale JavaDoc locale);
134
135     public void clearLabels();
136
137     public Locale JavaDoc[] getLabelLocales();
138
139     public boolean isDeprecated();
140
141     public void setDeprecated(boolean deprecated);
142
143     /**
144      * When was this DocumentType last changed (persistently). Returns null on newly
145      * created DocumentTypes.
146      */

147     public Date JavaDoc getLastModified();
148
149     /**
150      * Who (which user) last changed this DocumentType (persistently). Returns -1 on
151      * newly created DocumentTypes.
152      */

153     public long getLastModifier();
154
155     public DocumentTypeDocument getXml();
156
157     /**
158      * Same as {@link #getXml()} but includes the XML description of the used
159      * Part Types and Field Types in the generated XML.
160      */

161     public DocumentTypeDocument getExtendedXml();
162
163     public void setAllFromXml(DocumentTypeDocument.DocumentType documentTypeXml);
164
165     public void save() throws RepositoryException;
166
167     public long getUpdateCount();
168 }
169
Popular Tags