/* 9P Protocol JAVA
 * P9P/type/qid9P.java
 * Autor: Jaime Garzon (2006) jgarzon@gmail.com
 *
 * Esta clase es una implementacion del tipo de dato
 * qid, usado en el protocolo 9P de Plan9P, espeficicado
 * en la seccion 5 del manual de Plan 9: "Plan 9 File Protocol"
 * Los metodos Write y Read, permiten escribir el valor
 * de la forma little-endian en un Buffer o leerlo de un
 * array de bytes, respectivamente.
*/

package P9P.type;
import java.io.*;

public class qid9P extends type9P {

   public byte9P type=new byte9P();
   public int9P vers=new int9P();
   public long9P path=new long9P();
   private int sz=13;

   /* CONSTRUCTORES */

   public qid9P (byte[] b, int i) {
      read(b,i);
   }

   public qid9P () {}


   /* METODOS */

   public void read(byte[] b, int i) {
      type.read(b,i);
      vers.read(b,i+1);
      path.read(b,i+5);
   }

   public void write(ByteArrayOutputStream buf) {
      type.write(buf);
      vers.write(buf);
      path.write(buf);
   }

   public int len() {
      return sz;
   }

   public String toString() {
      return "qid("+type+vers+path+") ";
   }
}