KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > services > version > RevisionEntrySet


1 //
2
// ____.
3
// __/\ ______| |__/\. _______
4
// __ .____| | \ | +----+ \
5
// _______| /--| | | - \ _ | : - \_________
6
// \\______: :---| : : | : | \________>
7
// |__\---\_____________:______: :____|____:_____\
8
// /_____|
9
//
10
// . . . i n j a h i a w e t r u s t . . .
11
//
12

13 package org.jahia.services.version;
14
15 import java.util.HashMap JavaDoc;
16 import java.util.HashSet JavaDoc;
17 import java.util.Set JavaDoc;
18
19 import org.jahia.content.ObjectKey;
20
21 public abstract class RevisionEntrySet implements Comparable JavaDoc {
22
23     public static final String JavaDoc REVISION_TITLE = "RevisionTitle";
24
25     private int versionID;
26     private ObjectKey objectKey;
27
28     // Additional Properties, mostly for display purpose
29
private HashMap JavaDoc properties = new HashMap JavaDoc();
30
31     private Set JavaDoc revisions = new HashSet JavaDoc();
32
33     public RevisionEntrySet(){};
34
35     /**
36      *
37      * @param versionID
38      * @param objectKey
39      */

40     public RevisionEntrySet(int versionID, ObjectKey objectKey){
41         this.versionID = versionID;
42         this.objectKey = objectKey;
43     }
44
45     public abstract int getWorkflowState();
46
47     public abstract int getRevisionType();
48
49     public abstract String JavaDoc getDescription(String JavaDoc languageCode);
50
51     public int getVersionID(){
52         return this.versionID;
53     }
54
55     public ObjectKey getObjectKey(){
56         return objectKey;
57     }
58
59     public Set JavaDoc getRevisions(){
60         return this.revisions;
61     }
62
63     public void addRevision(RevisionEntry revisionEntry){
64         if ( revisionEntry != null ) {
65             this.revisions.add(revisionEntry);
66         }
67     }
68
69     public void setProperty(Object JavaDoc name, Object JavaDoc val ){
70         this.properties.put(name,val);
71     }
72
73     public Object JavaDoc getProperty(Object JavaDoc name){
74         return this.properties.get(name);
75     }
76
77     /**
78      * Returns :
79      * objectKey.toString()
80      * + "_" + entryState.getWorkflowState()
81      * + "_" + entryState.getVersionID()
82      * @return
83      */

84     public String JavaDoc toString(){
85         StringBuffer JavaDoc buff = new StringBuffer JavaDoc(objectKey.toString());
86         buff.append("_");
87         buff.append(getWorkflowState());
88         buff.append("_");
89         buff.append(getVersionID());
90         return buff.toString();
91     }
92
93     /**
94      * Ignore language codes equality.
95      * Compare the revision on the objectkey, the workflow_state and the version_id
96      * attributes.
97      *
98      * @param object
99      * @return
100      */

101     public boolean equals(Object JavaDoc object){
102
103         RevisionEntrySet revisionEntrySet = (RevisionEntrySet)object;
104         if ( revisionEntrySet == null ){
105             return false;
106         }
107
108         if ( this.getVersionID() != revisionEntrySet.getVersionID() ){
109             return false;
110         }
111         return (getObjectKey().equals(revisionEntrySet.getObjectKey()));
112     }
113
114     public int hashCode(){
115         return this.toString().hashCode();
116     }
117
118     /**
119      * To do
120      * @param o
121      * @return
122      */

123     public int compareTo(Object JavaDoc o) {
124         return 1;
125     }
126 }
127
Popular Tags