⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 primfmttrs.java

📁 卡耐基.梅隆大学的机器人仿真软件(Redhat linux 9下安装)
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
  }  private static class BYTE_Trans extends TransFormat {    BYTE_Trans() { super(BYTE_SIZE); }    void Encode (Object dataStruct, int dstart, int buffer) throws Exception {      formatPutByte(buffer, getByteField(dataStruct, dstart));     }    void Decode (Object dataStruct, int dstart, int buffer) throws Exception {      setByteField(dataStruct, dstart, formatGetByte(buffer));    }    void EncodeElement(int type, Object array, int index, int buffer) {      formatPutByte(buffer, ((byte[])array)[index]);    }    void DecodeElement(int type, Object array, int index, int buffer) {      ((byte[])array)[index] = formatGetByte(buffer);    }  }  private static class UBYTE_Trans extends TransFormat {    UBYTE_Trans() { super(BYTE_SIZE); }    void Encode (Object dataStruct, int dstart, int buffer) throws Exception {      formatPutUByte(buffer, getByteField(dataStruct, dstart));     }    void Decode (Object dataStruct, int dstart, int buffer) throws Exception {      setByteField(dataStruct, dstart, formatGetUByte(buffer));    }    void EncodeElement(int type, Object array, int index, int buffer) {      formatPutUByte(buffer, ((byte[])array)[index]);    }    void DecodeElement(int type, Object array, int index, int buffer) {      ((byte[])array)[index] = formatGetUByte(buffer);    }  }  private static class SHORT_Trans extends TransFormat {    SHORT_Trans() { super(SHORT_SIZE); }    void Encode (Object dataStruct, int dstart, int buffer) throws Exception {      formatPutShort(buffer, getShortField(dataStruct, dstart));     }    void Decode (Object dataStruct, int dstart, int buffer) throws Exception {      setShortField(dataStruct, dstart, formatGetShort(buffer));    }    void EncodeElement(int type, Object array, int index, int buffer) {      formatPutShort(buffer, ((short[])array)[index]);    }    void DecodeElement(int type, Object array, int index, int buffer) {      ((short[])array)[index] = formatGetShort(buffer);    }  }  private static class INT_Trans extends TransFormat {    INT_Trans() { super(INT_SIZE); }    void Encode (Object dataStruct, int dstart, int buffer) throws Exception {      formatPutInt(buffer, getIntField(dataStruct, dstart));     }    void Decode (Object dataStruct, int dstart, int buffer) throws Exception {      setIntField(dataStruct, dstart, formatGetInt(buffer));    }    void EncodeElement(Object array, int index, int buffer) {      formatPutInt(buffer, ((int[])array)[index]);    }    void DecodeElement(Object array, int index, int buffer) {      ((int[])array)[index] = formatGetInt(buffer);    }  }  private static class CHAR_Trans extends TransFormat {    CHAR_Trans() { super(CHAR_SIZE); }    void Encode (Object dataStruct, int dstart, int buffer) throws Exception {      formatPutChar(buffer, getCharField(dataStruct, dstart));     }    void Decode (Object dataStruct, int dstart, int buffer) throws Exception {      setCharField(dataStruct, dstart, formatGetChar(buffer));    }    void EncodeElement(Object array, int index, int buffer) {      formatPutChar(buffer, ((char[])array)[index]);    }    void DecodeElement(Object array, int index, int buffer) {      ((char[])array)[index] = formatGetChar(buffer);    }  }  private static class FLOAT_Trans extends TransFormat {    FLOAT_Trans() { super(FLOAT_SIZE); }    void Encode (Object dataStruct, int dstart, int buffer) throws Exception {      formatPutFloat(buffer, getFloatField(dataStruct, dstart));     }    void Decode (Object dataStruct, int dstart, int buffer) throws Exception {      setFloatField(dataStruct, dstart, formatGetFloat(buffer));    }    void EncodeElement(Object array, int index, int buffer) {      formatPutFloat(buffer, ((float[])array)[index]);    }    void DecodeElement(Object array, int index, int buffer) {      ((float[])array)[index] = formatGetFloat(buffer);    }  }  private static class DOUBLE_Trans extends TransFormat {    DOUBLE_Trans() { super(DOUBLE_SIZE); }    void Encode (Object dataStruct, int dstart, int buffer) throws Exception {      formatPutDouble(buffer, getDoubleField(dataStruct, dstart));     }    void Decode (Object dataStruct, int dstart, int buffer) throws Exception {      setDoubleField(dataStruct, dstart, formatGetDouble(buffer));    }    void EncodeElement(Object array, int index, int buffer) {      formatPutDouble(buffer, ((double[])array)[index]);    }    void DecodeElement(Object array, int index, int buffer) {      ((double[])array)[index] = formatGetDouble(buffer);    }  }  private static class BOOLEAN_Trans extends TransFormat {    BOOLEAN_Trans() { super(INT_SIZE); }    void Encode (Object dataStruct, int dstart, int buffer) throws Exception {      formatPutBoolean(buffer, getBooleanField(dataStruct, dstart));     }    void Decode (Object dataStruct, int dstart, int buffer) throws Exception {      setBooleanField(dataStruct, dstart, formatGetBoolean(buffer));    }    boolean SimpleType () { return false; }    void EncodeElement(Object array, int index, int buffer) {      formatPutBoolean(buffer, ((boolean[])array)[index]);    }    void DecodeElement(Object array, int index, int buffer) {      ((boolean[])array)[index] = formatGetBoolean(buffer);    }  }  private static class USHORT_Trans extends TransFormat {    USHORT_Trans() { super(SHORT_SIZE); }    void Encode (Object dataStruct, int dstart, int buffer) throws Exception {      formatPutUShort(buffer, getShortField(dataStruct, dstart));     }    void Decode (Object dataStruct, int dstart, int buffer) throws Exception {      setShortField(dataStruct, dstart, formatGetUShort(buffer));    }    void EncodeElement(Object array, int index, int buffer) {      formatPutUShort(buffer, ((short[])array)[index]);    }    void DecodeElement(Object array, int index, int buffer) {      ((short[])array)[index] = formatGetUShort(buffer);    }  }  private static class UINT_Trans extends TransFormat {    UINT_Trans() { super(INT_SIZE); }    void Encode (Object dataStruct, int dstart, int buffer) throws Exception {      formatPutUInt(buffer, getIntField(dataStruct, dstart));     }    void Decode (Object dataStruct, int dstart, int buffer) throws Exception {      setIntField(dataStruct, dstart, formatGetUInt(buffer));    }    void EncodeElement(Object array, int index, int buffer) {      formatPutUInt(buffer, ((int[])array)[index]);    }    void DecodeElement(Object array, int index, int buffer) {      ((int[])array)[index] = formatGetUInt(buffer);    }  }  private static class LONG_Trans extends TransFormat {    LONG_Trans() { super(LONG_SIZE); }    void Encode (Object dataStruct, int dstart, int buffer) throws Exception {      long theLong = getLongField(dataStruct, dstart);      if ((theLong > 0 && theLong > Integer.MAX_VALUE) ||	  (theLong < 0 && theLong < Integer.MIN_VALUE)) {	throw new Exception("Will lose precision in transferring long: "			    + theLong);      }      formatPutLong(buffer, theLong);    }    void Decode (Object dataStruct, int dstart, int buffer) throws Exception {      setLongField(dataStruct, dstart, formatGetLong(buffer));    }    void EncodeElement(Object array, int index, int buffer)      throws Exception {      long theLong = ((long[])array)[index];      if ((theLong > 0 && theLong > Integer.MAX_VALUE) ||	  (theLong < 0 && theLong < Integer.MIN_VALUE)) {	throw new Exception("Will lose precision in transferring long: "			    + theLong);      }            formatPutLong(buffer, theLong);    }    void DecodeElement(Object array, int index, int buffer) {      ((long[])array)[index] = formatGetLong(buffer);    }  }  private static TransFormat strTrans = new STR_Trans();  private static TransFormat byteTrans = new BYTE_Trans();  private static TransFormat ubyteTrans = new UBYTE_Trans();  private static TransFormat shortTrans = new SHORT_Trans();  private static TransFormat intTrans = new INT_Trans();  private static TransFormat charTrans = new CHAR_Trans();  private static TransFormat floatTrans = new FLOAT_Trans();  private static TransFormat doubleTrans = new DOUBLE_Trans();  private static TransFormat booleanTrans = new BOOLEAN_Trans();  private static TransFormat ushortTrans = new USHORT_Trans();  private static TransFormat uintTrans = new UINT_Trans();  private static TransFormat longTrans = new LONG_Trans();  private static TransFormat pickTrans (int type) throws Exception {    switch (type) {    case STR_FMT: return strTrans;    case BYTE_FMT: return byteTrans;    case UBYTE_FMT: return ubyteTrans;    case SHORT_FMT: return shortTrans;    case INT_FMT: return intTrans;    case CHAR_FMT: return charTrans;    case FLOAT_FMT: return floatTrans;    case DOUBLE_FMT: return doubleTrans;    case BOOLEAN_FMT: return booleanTrans;    case USHORT_FMT: return ushortTrans;    case UINT_FMT: return uintTrans;    case LONG_FMT:     case ULONG_FMT: return longTrans;    default: throw new Exception("Unhandled format "+ type);    }  }  public static void Encode(int type, Object dataStruct, int dstart,			    int buffer) throws Exception {    pickTrans(type).Encode(dataStruct, dstart, buffer);  }  public static void Decode(int type, Object dataStruct, int dstart, 			    int buffer) throws Exception {    pickTrans(type).Decode(dataStruct, dstart, buffer);  }  public static int ELength(int type, Object dataStruct,			    int dstart) throws Exception{    return pickTrans(type).ELength(dataStruct, dstart);  }  public static int ALength(int type) throws Exception {     return pickTrans(type).ALength();  }  public static boolean SimpleType(int type) throws Exception {   return pickTrans(type).SimpleType();  }  public static void EncodeElement(int type, Object array, int index,				   int buffer) throws Exception {    pickTrans(type).EncodeElement(array, index, buffer);  }  public static void DecodeElement(int type, Object array, int index,				   int buffer) throws Exception {    pickTrans(type).DecodeElement(array, index, buffer);  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -