KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > repository > commonimpl > comment > CommentImpl


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.commonimpl.comment;
17
18 import org.outerj.daisy.repository.comment.Comment;
19 import org.outerj.daisy.repository.comment.CommentVisibility;
20 import org.outerx.daisy.x10.CommentDocument;
21
22 import java.util.Date JavaDoc;
23 import java.util.GregorianCalendar JavaDoc;
24
25 public class CommentImpl implements Comment {
26     private long ownerDocumentId;
27     private long ownerBranchId;
28     private long ownerLanguageId;
29     private long id;
30     private String JavaDoc text;
31     private CommentVisibility visibility;
32     private Date JavaDoc createdOn;
33     private long createdBy;
34
35     public CommentImpl(long ownerDocumentId, long ownerBranchId, long ownerLanguageId, long id, String JavaDoc text, CommentVisibility visibility, Date JavaDoc createdOn, long createdBy) {
36         this.ownerDocumentId = ownerDocumentId;
37         this.ownerBranchId = ownerBranchId;
38         this.ownerLanguageId = ownerLanguageId;
39         this.id = id;
40         this.text = text;
41         this.visibility = visibility;
42         this.createdOn = createdOn;
43         this.createdBy = createdBy;
44     }
45
46     public String JavaDoc getText() {
47         return text;
48     }
49
50     public long getId() {
51         return id;
52     }
53
54     public long getOwnerDocumentId() {
55         return ownerDocumentId;
56     }
57
58     public long getOwnerBranchId() {
59         return ownerBranchId;
60     }
61
62     public long getOwnerLanguageId() {
63         return ownerLanguageId;
64     }
65
66     public CommentVisibility getVisibility() {
67         return visibility;
68     }
69
70     public long getCreatedBy() {
71         return createdBy;
72     }
73
74     public Date JavaDoc getCreatedOn() {
75         return (Date JavaDoc)createdOn.clone();
76     }
77
78     public CommentDocument getXml() {
79         CommentDocument commentDocument = CommentDocument.Factory.newInstance();
80         CommentDocument.Comment commentXml = commentDocument.addNewComment();
81         commentXml.setContent(text);
82         commentXml.setId(id);
83         commentXml.setVisibility(CommentDocument.Comment.Visibility.Enum.forString(visibility.toString()));
84         commentXml.setCreatedBy(createdBy);
85         commentXml.setDocumentId(ownerDocumentId);
86         commentXml.setBranchId(ownerBranchId);
87         commentXml.setLanguageId(ownerLanguageId);
88         GregorianCalendar JavaDoc createdOnCalendar = new GregorianCalendar JavaDoc();
89         createdOnCalendar.setTime(createdOn);
90         commentXml.setCreatedOn(createdOnCalendar);
91         return commentDocument;
92     }
93 }
94
Popular Tags