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   
00061 
00062 
00063   protected int status;
00064 
00065   protected Status () {
00066      super(Element.STATUS);
00067   }
00068 
00069   public Status(int cmdRef, int status) {
00070     super(AbstractCommand.STATUS, cmdRef);
00071     this.status = status;
00072   }
00073 
00074   public int getStatus() {
00075     return status;
00076   }
00077 
00078  public String toString() {
00079   return super.toString() + "status : " + status ;
00080  }
00081 
00082    /*** Implements Element interface **/
00083  public boolean isAtomic() {
00084     return true;
00085    }
00086 
00087  public void setData (String data) {
00088   if ((data != null) && (data.length() != 0))
00089     this.status = Integer.parseInt(data);
00090  }
00091 
00092  public void writeContent(StringBuffer buffer) {
00093       super.writeContent(buffer);
00094       MessageFactory.writeElement(buffer, MessageFactory.TAG_DATA, String.valueOf(status));
00095       buffer.append("\n");
00096   }
00097 
00098 }

Generated on Tue May 22 23:01:12 2007 for OpenMobileIS by  doxygen 1.5.1-p1