1 18 19 20 package sync4j.framework.database; 21 22 import java.security.Principal ; 23 24 import org.apache.commons.lang.builder.ToStringBuilder; 25 26 import sync4j.framework.core.*; 27 28 34 public class Database { 35 36 38 41 private String name = null; 42 43 public String getName() { 44 return this.name; 45 } 46 47 52 public void setName(String name) { 53 if (name == null) { 54 throw new NullPointerException ("name cannot be null"); 55 } 56 int qMark = name.indexOf('?'); 57 if (qMark == -1) { 58 this.name = name; 59 } else { 60 this.name = name.substring(0, qMark); 61 } 62 } 63 64 67 private String type = null; 68 69 public String getType() { 70 return this.type; 71 } 72 73 public void setType(String type) { 74 this.type = type; 75 } 76 77 80 private Target target = null; 81 82 public Target getTarget() { 83 return this.target; 84 } 85 86 public void setTarget(Target target) { 87 this.target = target; 88 } 89 90 93 private Source source = null; 94 95 public Source getSource() { 96 return this.source; 97 } 98 99 public void setSource(Source source) { 100 this.source = source; 101 } 102 103 106 private Anchor anchor = null; 107 108 public Anchor getAnchor() { 109 return anchor; 110 } 111 112 public void setAnchor(Anchor anchor) { 113 this.anchor = anchor; 114 } 115 116 119 private Anchor serverAnchor = null; 120 121 public Anchor getServerAnchor() { 122 return serverAnchor; 123 } 124 125 public void setServerAnchor(Anchor serverAnchor) { 126 this.serverAnchor = serverAnchor; 127 } 128 129 132 private int method = AlertCode.SLOW; 133 134 public int getMethod() { 135 return this.method; 136 } 137 138 public void setMethod(int method) { 139 this.method = method; 140 } 141 142 145 private int statusCode = StatusCode.OK; 146 147 public int getStatusCode() { 148 return statusCode; 149 } 150 151 public void setStatusCode(int statusCode) { 152 this.statusCode = statusCode; 153 } 154 155 158 private String statusMessage = null; 159 160 public String getStatusMessage() { 161 return statusMessage; 162 } 163 164 public void setStatusMessage(String statusMessage) { 165 this.statusMessage = statusMessage; 166 } 167 168 171 private Alert alertCommand = null; 172 173 public Alert getAlertCommand() { 174 return this.alertCommand; 175 } 176 177 public void setAlertCommand(Alert alertCommand) { 178 this.alertCommand = alertCommand; 179 } 180 181 184 private Principal principal = null; 185 186 190 public Principal getPrincipal() { 191 return principal; 192 } 193 194 198 public void setPrincipal(Principal principal) { 199 this.principal = principal; 200 } 201 202 204 207 private Item[] addItems = null; 208 private Item[] copyItems = null; 209 private Item[] deleteItems = null; 210 private Item[] execItems = null; 211 private Item[] replaceItems = null; 212 private Item[] existingItems = null; 213 214 public void setAddItems(Item[] items) { 215 this.addItems = items; 216 } 217 218 public Item[] getAddItems() { 219 return this.addItems; 220 } 221 222 public void setCopyItems(Item[] items) { 223 this.copyItems = items; 224 } 225 226 public Item[] getCopyItems() { 227 return this.copyItems; 228 } 229 230 public void setDeleteItems(Item[] items) { 231 this.deleteItems = items; 232 } 233 234 public Item[] getDeleteItems() { 235 return this.deleteItems; 236 } 237 238 public void setExecItems(Item[] items) { 239 this.execItems = items; 240 } 241 242 public Item[] getExecItems() { 243 return this.execItems; 244 } 245 246 public void setReplaceItems(Item[] items) { 247 this.replaceItems = items; 248 } 249 250 public Item[] getReplaceItems() { 251 return this.replaceItems; 252 } 253 254 public void setExistingItems(Item[] items) { 255 this.existingItems = items; 256 } 257 258 public Item[] getExistingItems() { 259 return this.existingItems; 260 } 261 262 264 274 public Database(String name , 275 String type , 276 Target target , 277 Source source , 278 Anchor anchor , 279 Principal principal) { 280 setName(name); 281 this.type = type ; 282 this.target = target; 283 this.source = source; 284 this.anchor = anchor; 285 this.principal = principal; 286 } 287 288 293 public Database(String name) { 294 this(name, null, null, null, null, null); 295 } 296 297 299 public String getLast() { 300 return (anchor != null) ? anchor.getLast() : null; 301 } 302 303 public String getNext() { 304 return (anchor != null) ? anchor.getNext() : null; 305 } 306 307 313 public boolean isOkStatusCode() { 314 return (statusCode == StatusCode.OK) || 315 (statusCode == StatusCode.REFRESH_REQUIRED); 316 } 317 318 public String toString() { 319 ToStringBuilder sb = new ToStringBuilder(this); 320 321 sb.append("name", name ). 322 append("type", type ). 323 append("statusCode", statusCode). 324 append("target", target ). 325 append("source", source ). 326 append("anchor", anchor ). 327 append("principal", principal ); 328 329 return sb.toString(); 330 } 331 } 332 | Popular Tags |