KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > docdiff > DocDiffOutputHelper


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.docdiff;
17
18 import org.outerj.daisy.repository.Repository;
19 import org.outerj.daisy.repository.Version;
20 import org.outerj.daisy.repository.Document;
21 import org.outerj.daisy.repository.schema.PartType;
22 import org.outerj.daisy.repository.schema.FieldType;
23 import org.outerj.daisy.repository.schema.RepositorySchema;
24
25 import java.util.Locale JavaDoc;
26
27 /**
28  * A context/helper object for implementations of {@link DocDiffOutput}.
29  */

30 public class DocDiffOutputHelper {
31     private Repository repository;
32     private RepositorySchema repositorySchema;
33     private Document document1;
34     private Document document2;
35     private Version version1;
36     private Version version2;
37     private Locale JavaDoc locale;
38
39     public DocDiffOutputHelper(Document document1, Document document2, Version version1, Version version2,
40             Repository repository, Locale JavaDoc locale) {
41         this.repository = repository;
42         this.repositorySchema = repository.getRepositorySchema();
43         this.locale = locale;
44         this.document1 = document1;
45         this.document2 = document2;
46         this.version1 = version1;
47         this.version2 = version2;
48     }
49
50     public String JavaDoc getPartLabel(long typeId) throws Exception JavaDoc {
51         PartType partType = repositorySchema.getPartTypeById(typeId, false);
52         return partType.getLabel(locale);
53     }
54
55     public PartType getPartType(long typeId) throws Exception JavaDoc {
56         return repositorySchema.getPartTypeById(typeId, false);
57     }
58
59     public String JavaDoc getFieldLabel(long typeId) throws Exception JavaDoc {
60         FieldType fieldType = repositorySchema.getFieldTypeById(typeId, false);
61         return fieldType.getLabel(locale);
62     }
63
64     public FieldType getFieldType(long typeId) throws Exception JavaDoc {
65         return repositorySchema.getFieldTypeById(typeId, false);
66     }
67
68     public Version getVersion1() {
69         return version1;
70     }
71
72     public Version getVersion2() {
73         return version2;
74     }
75
76     public Document getDocument1() {
77         return document1;
78     }
79
80     public Document getDocument2() {
81         return document2;
82     }
83
84     public Locale JavaDoc getLocale() {
85         return locale;
86     }
87
88     public Repository getRepository() {
89         return repository;
90     }
91 }
92
Popular Tags