00001 /* 00002 * OpenMobileIS - a free Java(TM) Framework for mobile applications Java(TM) 00003 * Copyright (C) 2004-2005 Philippe Delrieu 00004 * All rights reserved. 00005 * Contact: openmobileis@e-care.fr 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00020 * USA 00021 * 00022 * Author : Philippe Delrieu 00023 * 00024 */ 00025 00026 package org.openmobileis.synchro.openmsp.protocol; 00027 00028 00036 public class Command extends RequestCommand implements Element { 00041 final static long serialVersionUID = 1L; 00042 00043 00044 00045 // target : define the receiver service in charge of processing the command 00046 protected String target; 00047 protected long sessionID=-1; 00048 // source : identify the source which sent the command 00049 protected String source; 00050 00051 protected Command (int commandType) { 00052 super(commandType); 00053 } 00054 00055 public Command(int commandType, String source, String target) { 00056 super(commandType); 00057 this.source = source; 00058 this.target = target; 00059 } 00060 00061 00062 public String getTarget () { 00063 return target; 00064 } 00065 00066 public String getSource() { 00067 return source; 00068 } 00069 00074 public long getSourceSessionID() { 00075 return sessionID; 00076 } 00077 00078 public void setSource(String source) { 00079 this.source = source; 00080 } 00081 00082 public void setTarget (String target) { 00083 this.target = target; 00084 } 00085 00086 public void setSourceSessionID(long sessionid) { 00087 this.sessionID = sessionid; 00088 } 00089 00090 00091 public String toString() { 00092 return super.toString() + " source : " + source + " target : " + target+" sessionID "+sessionID; 00093 } 00094 00095 /*** Implements Element interface **/ 00096 public void writeContent(StringBuffer buffer) { 00097 super.writeContent(buffer); 00098 if (source != null) { 00099 MessageFactory.writeSource(buffer, source, sessionID); 00100 buffer.append("\n"); 00101 } 00102 if (target != null) { 00103 MessageFactory.writeTarget(buffer, target); 00104 buffer.append("\n"); 00105 } 00106 } 00107 00108 00109 }