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 00036 public class Status extends ResponseCommand implements Element { 00041 final static long serialVersionUID = 1L; 00042 00043 public final static int STATUS_SYNC_IN_PROGRESS=101; 00044 public final static int STATUS_OK = 200; 00045 public final static int STATUS_NO_CONTENT = 204; 00046 public final static int STATUS_PARTIAL_CONTENT = 206; 00047 public final static int STATUS_WRONG_FORMAT = 400; 00048 public final static int STATUS_UNAUTHORIZED = 401; 00049 public final static int STATUS_NOT_FOUND = 404; 00050 public final static int STATUS_AUTHENTIFICATION_REQUIRED = 407; 00051 public final static int STATUS_TOO_LARGE = 413; 00052 public final static int STATUS_UNSUPPORTED_MEDIA = 415; 00053 public final static int STATUS_EXIST_TARGET = 418; 00054 public final static int STATUS_DEVICE_FULL = 420; 00055 public final static int STATUS_FAILED = 500; 00056 public final static int STATUS_COMMAND_NOT_IMPLEMENTED = 501; 00057 public final static int STATUS_SYNCHRO_CONFLIC = 1001; 00058 00059 00060 protected int status; 00061 00062 protected Status () { 00063 super(Element.STATUS); 00064 } 00065 00066 public Status(int cmdRef, int status) { 00067 super(AbstractCommand.STATUS, cmdRef); 00068 this.status = status; 00069 } 00070 00071 public int getStatus() { 00072 return status; 00073 } 00074 00075 public String toString() { 00076 return super.toString() + "status : " + status ; 00077 } 00078 00079 /*** Implements Element interface **/ 00080 public boolean isAtomic() { 00081 return true; 00082 } 00083 00084 public void setData (String data) { 00085 if ((data != null) && (data.length() != 0)) 00086 this.status = Integer.parseInt(data); 00087 } 00088 00089 public void writeContent(StringBuffer buffer) { 00090 super.writeContent(buffer); 00091 MessageFactory.writeElement(buffer, MessageFactory.TAG_DATA, String.valueOf(status)); 00092 buffer.append("\n"); 00093 } 00094 00095 }