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.repository;
17:
18: import org.outerx.daisy.x10.FieldDocument;
19:
20: /**
21: * Fields belong to documents (or versions of documents), and can
22: * be used for various purposes.
23: *
24: * <p>Often, fields will be used for meta-data about the document, though
25: * you can use them for whatever data that you want to have addressable
26: * on a finer level then that contained in the {@link Parts}.
27: *
28: * <p>A field is always based upon a {@link org.outerj.daisy.repository.schema.FieldType},
29: * which defines the kind of data that the field can contain.
30: *
31: * <p>Note that a field has no setters methods, modifications can only
32: * be done through the containing {@link Document}. This is because
33: * fields can also be obtained from {@link Version}s, which are not
34: * modifiable.
35: */
36: public abstract interface Field {
37:
38: /**
39: * The id of the field type of this field. More information on the field type
40: * can then be retrieved from the {@link org.outerj.daisy.repository.schema.RepositorySchema}.
41: */
42: long getTypeId();
43:
44: /**
45: * The name of the field type (for convenience, this is retrieved from the RepositorySchema).
46: */
47: String getTypeName();
48:
49: /**
50: * The ValueType of the field, which defines the kind of object you
51: * will get from {@link #getValue()}. This method is here for convenience,
52: * the information is retrieved from the RepositorySchema.
53: */
54: ValueType getValueType();
55:
56: /**
57: * Indicates if this field is a multivalue field. This method is here
58: * for convenience, the information is retrieved from the RepositorySchema.
59: */
60: boolean isMultiValue();
61:
62: /**
63: * Indicates if this field is a hierarchical field. This method is here
64: * for convenience, the information is retrieved from the RepositorySchema.
65: */
66: boolean isHierarchical();
67:
68: /**
69: * The value of the field. This will never be null (otherwise the document
70: * wouldn't have the field in the first place). The kind of object returned
71: * is dependent of the {@link ValueType}, and of whether it concerns a multi-value
72: * and/or hierarchical field type. For multi-value fields, an array (Object[]) is returned.
73: * For hierarchical fields, a {@link HierarchyPath} object is returned.
74: * It hence follows that for hierarchical-and-multivalue fields,
75: * an array of HierarchyPath objects is returned.
76: */
77: Object getValue();
78:
79: /**
80: * Get an XML document describing this field.
81: */
82: FieldDocument getXml();
83: }
|