KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > dotmarketing > portlets > links > model > Link


1 package com.dotmarketing.portlets.links.model;
2
3 import java.io.Serializable JavaDoc;
4 import java.util.Map JavaDoc;
5
6 import com.dotmarketing.beans.WebAsset;
7 import com.dotmarketing.portlets.folders.model.Folder;
8
9 /** @author Hibernate CodeGenerator */
10 public class Link extends WebAsset implements Serializable JavaDoc, Comparable JavaDoc {
11
12     private static final long serialVersionUID = 1L;
13
14     /** identifier field */
15     private long parent;
16     
17     private String JavaDoc title;
18     
19     private String JavaDoc protocal;
20
21     private String JavaDoc url;
22
23     private String JavaDoc target;
24     
25     private long internalLinkIdentifier;
26     
27     /** nullable persistent field */
28     private boolean internal;
29
30
31     /** default constructor */
32     public Link() {
33         super.setType("links");
34     }
35
36     public long getInode() {
37         return this.inode;
38     }
39
40     /**
41      * Returns the parent.
42      * @return long
43      */

44     public long getParent() {
45         return parent;
46     }
47
48     /**
49      * Sets the parent.
50      * @param parent The parent to set
51      */

52     public void setParent(long parent) {
53         this.parent = parent;
54     }
55     
56
57
58     /**
59      * Sets the inode.
60      * @param inode The inode to set
61      */

62     public void setInode(long inode) {
63         this.inode = inode;
64     }
65
66     //Every Web Asset should implement this method!!!
67
public void copy(Link newLink) {
68         this.setParent(newLink.getParent());
69         this.setTitle(newLink.getTitle());
70         this.setUrl(newLink.getUrl());
71         this.setTarget(newLink.getTarget());
72         this.setInternal(newLink.isInternal());
73         super.copy(newLink);
74     }
75
76
77     /**
78      * Returns the title.
79      * @return String
80      */

81     public String JavaDoc getTitle() {
82         return title;
83     }
84
85     /**
86      * Returns the url.
87      * @return String
88      */

89     public String JavaDoc getUrl() {
90         return url;
91     }
92
93     /**
94      * Sets the title.
95      * @param title The title to set
96      */

97     public void setTitle(String JavaDoc title) {
98         this.title = title;
99     }
100
101     /**
102      * Sets the url.
103      * @param url The url to set
104      */

105     public void setUrl(String JavaDoc url) {
106         this.url = url;
107
108     }
109     
110     /**
111      * Returns the target.
112      * @return String
113      */

114     public String JavaDoc getTarget() {
115         return target;
116     }
117
118     /**
119      * Sets the target.
120      * @param target The target to set
121      */

122     public void setTarget(String JavaDoc target) {
123         this.target = target;
124     }
125
126     public int compareTo(Object JavaDoc compObject){
127         if(!(compObject instanceof Link))return -1;
128         
129         Link link = (Link) compObject;
130         return (link.getTitle().compareTo(this.getTitle()));
131     }
132
133
134     /**
135      * Returns the protocal.
136      * @return String
137      */

138     public String JavaDoc getProtocal() {
139         return protocal;
140     }
141
142     /**
143      * Sets the protocal.
144      * @param protocal The protocal to set
145      */

146     public void setProtocal(String JavaDoc protocal) {
147         this.protocal = protocal;
148     }
149
150     /**
151      * Returns the internal.
152      * @return boolean
153      */

154     public boolean isInternal() {
155         return internal;
156     }
157
158     /**
159      * Sets the internal.
160      * @param internal The internal to set
161      */

162     public void setInternal(boolean internal) {
163         this.internal = internal;
164     }
165
166     /**
167      * Returns the protocal.
168      * @return String
169      */

170     public String JavaDoc getWorkingURL() {
171         
172         StringBuffer JavaDoc workingURL = new StringBuffer JavaDoc();
173         if(this.protocal!=null && this.url.indexOf("http://")<0 && this.url.indexOf("https://")<0 && this.url.indexOf("mailto:")<0 && this.url.indexOf("ftp://")<0 && this.url.indexOf("javascript:")<0){
174             workingURL.append(this.protocal);
175         }
176         if(this.url!=null){
177             workingURL.append(this.url);
178         }
179         return workingURL.toString();
180     }
181
182     public String JavaDoc getURI(Folder folder) {
183
184         return folder.getPath() + this.getInode();
185     }
186
187
188     /**
189      * Returns the internalLinkIdentifier.
190      * @return long
191      */

192     public long getInternalLinkIdentifier() {
193         return internalLinkIdentifier;
194     }
195
196     /**
197      * Sets the internalLinkIdentifier.
198      * @param internalLinkIdentifier The internalLinkIdentifier to set
199      */

200     public void setInternalLinkIdentifier(long internalLinkIdentifier) {
201         this.internalLinkIdentifier = internalLinkIdentifier;
202     }
203
204     public Map JavaDoc<String JavaDoc, Object JavaDoc> getMap() {
205         Map JavaDoc<String JavaDoc, Object JavaDoc> map = super.getMap();
206
207         map.put("parent", parent);
208         map.put("title", title);
209         map.put("protocol", protocal);
210         map.put("url", url);
211         map.put("target", target);
212         map.put("internalLinkIdentifier", internalLinkIdentifier);
213         map.put("internal", internal);
214         
215         return map;
216     }
217 }
218
Popular Tags