1 package org.rosuda.REngine.Rserve.protocol;
3 // JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/
4 // Copyright (C) 2004 Simon Urbanek
5 // --- for licensing information see LICENSE file in the original JRclient distribution ---
7 /** small class encapsulating packets from/to Rserv
10 public class RPacket {
14 /** construct new packet
16 @param Rcont content */
17 public RPacket(int Rcmd, byte[] Rcont) {
23 public int getCmd() { return cmd; }
25 /** check last response for RESP_OK
26 @return <code>true</code> if last response was OK */
27 public boolean isOk() { return ((cmd&15)==1); }
29 /** check last response for RESP_ERR
30 @return <code>true</code> if last response was ERROR */
31 public boolean isError() { return ((cmd&15)==2); }
33 /** get status code of last response
34 @return status code returned on last response */
35 public int getStat() { return ((cmd>>24)&127); }
38 @return inner package content */
39 public byte[] getCont() { return cont; }
41 public String toString() { return "RPacket[cmd="+cmd+",len="+((cont==null)?"<null>":(""+cont.length))+"]"; }