1 21 package com.jaspersoft.jasperserver.api.metadata.common.domain.client; 22 23 import java.util.Date ; 24 import java.util.List ; 25 26 import com.jaspersoft.jasperserver.api.metadata.common.domain.Folder; 27 import com.jaspersoft.jasperserver.api.metadata.common.domain.Resource; 28 29 30 34 public abstract class ResourceImpl implements Resource 35 { 36 private int version; 37 private Date creationDate; 38 private String name; 39 private String label; 40 private String description; 41 private String folderUri; 42 private transient String uri; 43 44 protected ResourceImpl() { 45 version = VERSION_NEW; 46 } 47 48 public String getName() 49 { 50 return name; 51 } 52 53 public void setName(String name) 54 { 55 uri = null; 56 this.name = name; 57 } 58 59 public String getLabel() 60 { 61 return label; 62 } 63 64 public void setLabel(String label) 65 { 66 this.label = label; 67 } 68 69 public String getDescription() 70 { 71 return description; 72 } 73 74 public void setDescription(String description) 75 { 76 this.description = description; 77 } 78 79 public String getURIString() 80 { 81 if (uri == null) { 82 StringBuffer sb = new StringBuffer (); 83 if (getParentFolder() != null && !getParentFolder().equals(Folder.SEPARATOR)) 84 sb.append(getParentFolder()); 85 sb.append(Folder.SEPARATOR); 86 if (!getName().equals(Folder.SEPARATOR)) 87 sb.append(getName()); 88 uri = sb.toString(); 89 } 90 return uri; 91 } 92 93 public void setURIString(String uri) 94 { 95 this.uri = uri; 96 } 97 98 101 public String getPath() { 102 return getURIString(); 103 } 104 105 108 public String getProtocol() { 109 return Resource.URI_PROTOCOL; 110 } 111 112 115 public String getURI() { 116 return getProtocol() + ":" + getPath(); 117 } 118 119 public String getParentURI() { 120 return getParentFolder() == null ? null : getProtocol() + ":" + getParentFolder(); 121 } 122 123 public String getParentPath() { 124 return getParentFolder() == null ? null : getParentFolder(); 125 } 126 127 public String getParentFolder() { 128 return folderUri; 129 } 130 131 public void setParentFolder(Folder folder) { 132 this.uri = null; 133 folderUri = (folder == null ? null : folder.getURIString()); 134 } 135 136 public void setParentFolder(String folderURI) { 137 this.uri = null; 138 folderUri = folderURI; 139 } 140 141 public List getAttributes() 142 { 143 return null; 145 } 146 147 public int getVersion() { 148 return version; 149 } 150 151 public void setVersion(int version) { 152 this.version = version; 153 } 154 155 public String getResourceType() { 156 return getImplementingItf().getName(); 157 } 158 159 protected abstract Class getImplementingItf(); 160 161 public Date getCreationDate() { 162 return creationDate; 163 } 164 165 public void setCreationDate(Date creationDate) { 166 this.creationDate = creationDate; 167 } 168 169 public boolean isNew() { 170 return version == VERSION_NEW; 171 } 172 } 173 | Popular Tags |