1 package com.dotmarketing.portlets.links.model; 2 3 import java.io.Serializable ; 4 import java.util.Map ; 5 6 import com.dotmarketing.beans.WebAsset; 7 import com.dotmarketing.portlets.folders.model.Folder; 8 9 10 public class Link extends WebAsset implements Serializable , Comparable { 11 12 private static final long serialVersionUID = 1L; 13 14 15 private long parent; 16 17 private String title; 18 19 private String protocal; 20 21 private String url; 22 23 private String target; 24 25 private long internalLinkIdentifier; 26 27 28 private boolean internal; 29 30 31 32 public Link() { 33 super.setType("links"); 34 } 35 36 public long getInode() { 37 return this.inode; 38 } 39 40 44 public long getParent() { 45 return parent; 46 } 47 48 52 public void setParent(long parent) { 53 this.parent = parent; 54 } 55 56 57 58 62 public void setInode(long inode) { 63 this.inode = inode; 64 } 65 66 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 81 public String getTitle() { 82 return title; 83 } 84 85 89 public String getUrl() { 90 return url; 91 } 92 93 97 public void setTitle(String title) { 98 this.title = title; 99 } 100 101 105 public void setUrl(String url) { 106 this.url = url; 107 108 } 109 110 114 public String getTarget() { 115 return target; 116 } 117 118 122 public void setTarget(String target) { 123 this.target = target; 124 } 125 126 public int compareTo(Object 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 138 public String getProtocal() { 139 return protocal; 140 } 141 142 146 public void setProtocal(String protocal) { 147 this.protocal = protocal; 148 } 149 150 154 public boolean isInternal() { 155 return internal; 156 } 157 158 162 public void setInternal(boolean internal) { 163 this.internal = internal; 164 } 165 166 170 public String getWorkingURL() { 171 172 StringBuffer workingURL = new StringBuffer (); 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 getURI(Folder folder) { 183 184 return folder.getPath() + this.getInode(); 185 } 186 187 188 192 public long getInternalLinkIdentifier() { 193 return internalLinkIdentifier; 194 } 195 196 200 public void setInternalLinkIdentifier(long internalLinkIdentifier) { 201 this.internalLinkIdentifier = internalLinkIdentifier; 202 } 203 204 public Map <String , Object > getMap() { 205 Map <String , Object > 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 |