00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 package org.openmobileis.synchro.openmsp.protocol;
00027
00038 public class Item implements Element {
00039 static final long serialVersionUID = 5521257935120563452L;
00040
00041 protected String target;
00042 protected String source;
00043 protected int itemType;
00044 protected long sessionID = -1;
00045
00046
00047 public Item(int itemType, String source, String target) {
00048 this.target = target;
00049 this.source = source;
00050 this.itemType = itemType;
00051 }
00052
00053
00054 protected Item (int itemType) {
00055 this.itemType = itemType;
00056 }
00057
00058 public int getCmdId() {
00059 return 0;
00060 }
00061
00062 public boolean hasCommmandId() {
00063 return false;
00064 }
00065
00066 public String getSource() {
00067 return source;
00068 }
00069
00074 public long getSourceSessionID() {
00075 return sessionID;
00076 }
00077
00078 public String getTarget() {
00079 return target;
00080 }
00081
00082 public int getElementType() {
00083 return itemType;
00084 }
00085
00086 public String toString() {
00087 return "type : " + itemType + " source : " + source + " target : " + target;
00088 }
00089
00090
00091
00092 public void setTarget (String target) {
00093 this.target = target;
00094 }
00095
00096 public void setSource (String source) {
00097 this.source = source;
00098 }
00099
00100 public void setSourceSessionID(long sessionid) {
00101 this.sessionID = sessionid;
00102 }
00103
00104 public void setElementType(int elementType) {
00105 this.itemType = elementType;
00106 }
00107
00108 public void setCmdId (int cmdId) {}
00109 public void setCredentialData (String data) {}
00110 public void setCredentialMeta (String meta){}
00111 public void setMetaInformation (String meta){}
00112 public void setCmdRef (int cmdRef){}
00113 public void setSourceRef(String source){}
00114 public void setTargetRef(String target){}
00115 public void setData (String data){ }
00116
00117
00118 public void writeBeginTag(StringBuffer buffer) {
00119 MessageFactory.writeBeginTagForElement(buffer, itemType);
00120 buffer.append("\n");
00121 }
00122
00123
00124 public void writeContent(StringBuffer buffer) {
00125 if (source != null) {
00126 MessageFactory.writeSource(buffer, source, sessionID);
00127 buffer.append("\n");
00128 }
00129 if (target != null) {
00130 MessageFactory.writeTarget(buffer, target);
00131 buffer.append("\n");
00132 }
00133 }
00134
00135 public void writeEndTag(StringBuffer buffer) {
00136 MessageFactory.writeEndTagForElement(buffer, itemType);
00137 buffer.append("\n");
00138 }
00139
00140 }