Status.java

00001 /*
00002  * OpenMobileIS - a free Java(TM) Framework for mobile applications Java(TM)
00003  * Copyright (C) 2004-2006 Philippe Delrieu
00004  * All rights reserved.
00005  * Contact: pdelrieu@openmobileis.org
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   public final static int STATUS_HOST_UNKNOW = 1002;
00059   public final static int STATUS_WRONG_AUTHENTIFICATION = 1003;
00060   public final static int STATUS_OK_RESTART_APPLICATION = 1004;
00061   
00062 
00063 
00064   protected int status;
00065 
00066   protected Status () {
00067      super(Element.STATUS);
00068   }
00069 
00070   public Status(int cmdRef, int status) {
00071     super(AbstractCommand.STATUS, cmdRef);
00072     this.status = status;
00073   }
00074 
00075   public int getStatus() {
00076     return status;
00077   }
00078 
00079  public String toString() {
00080   return super.toString() + "status : " + status ;
00081  }
00082 
00083    /*** Implements Element interface **/
00084  public boolean isAtomic() {
00085     return true;
00086    }
00087 
00088  public void setData (String data) {
00089   if ((data != null) && (data.length() != 0))
00090     this.status = Integer.parseInt(data);
00091  }
00092 
00093  public void writeContent(StringBuffer buffer) {
00094       super.writeContent(buffer);
00095       MessageFactory.writeElement(buffer, MessageFactory.TAG_DATA, String.valueOf(status));
00096       buffer.append("\n");
00097   }
00098 
00099 }

Generated on Mon Jan 11 21:19:17 2010 for OpenMobileIS by  doxygen 1.5.4