KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > repository > serverimpl > linkextraction > LinkInfo


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.serverimpl.linkextraction;
17
18 import org.outerj.daisy.linkextraction.LinkType;
19
20 public class LinkInfo {
21     public final long sourceDocumentId;
22     public final long sourceBranchId;
23     public final long sourceLanguageId;
24     public final long sourcePartTypeId;
25     public boolean occursInLastVersion;
26     public boolean occursInLiveVersion;
27     public final long targetDocumentId;
28     public final long targetBranchId;
29     public final long targetLanguageId;
30     public final LinkType linkType;
31     public final long targetVersionId;
32
33     public LinkInfo(long sourceDocumentId, long sourceBranchId, long sourceLanguageId, long sourcePartTypeId,
34                     boolean occursInLastVersion, boolean occursInLiveVersion, long targetDocumentId, long targetBranchId,
35                     long targetLanguageId, long versionId, LinkType linkType) {
36         this.sourceDocumentId = sourceDocumentId;
37         this.sourceBranchId = sourceBranchId;
38         this.sourceLanguageId = sourceLanguageId;
39         this.sourcePartTypeId = sourcePartTypeId;
40         this.occursInLastVersion = occursInLastVersion;
41         this.occursInLiveVersion = occursInLiveVersion;
42         this.targetDocumentId = targetDocumentId;
43         this.targetBranchId = targetBranchId;
44         this.targetLanguageId = targetLanguageId;
45         this.targetVersionId = versionId;
46         this.linkType = linkType;
47     }
48
49     public String JavaDoc getKey() {
50         return sourceDocumentId + "," + sourceBranchId + "," + sourceLanguageId + "," + sourcePartTypeId + "," + targetDocumentId + "," + targetBranchId + "," + targetLanguageId + "," + targetVersionId + "," + linkType;
51     }
52
53     public void merge(LinkInfo linkInfo) {
54         if (sourceDocumentId != linkInfo.sourceDocumentId
55                 || sourceBranchId != linkInfo.sourceBranchId
56                 || sourceLanguageId != linkInfo.sourceLanguageId
57                 || sourcePartTypeId != linkInfo.sourcePartTypeId
58                 || targetDocumentId != linkInfo.targetDocumentId
59                 || linkType != linkInfo.linkType
60                 || targetVersionId != linkInfo.targetVersionId
61                 || targetBranchId != linkInfo.targetBranchId
62                 || targetLanguageId != linkInfo.targetLanguageId) {
63             throw new RuntimeException JavaDoc("Cannot merge");
64         }
65
66         occursInLastVersion = occursInLastVersion | linkInfo.occursInLastVersion;
67         occursInLiveVersion = occursInLiveVersion | linkInfo.occursInLiveVersion;
68     }
69 }
70
Popular Tags