Java 类java.lang.Byte 实例源码

项目:jpuderer-things-drivers    文件:HpmSensor.java   
void processDataFrame(byte[] dataframe) {
    if (DEBUG) Log.d(TAG, "dataframe: " + bytesToHex(dataframe));

    int checksum = (Byte.toUnsignedInt(dataframe[30]) << 8) + Byte.toUnsignedInt(dataframe[31]);
    int calculatedChecksum = 0;
    for (int i = 0; i < 30; i++) {
        calculatedChecksum += Byte.toUnsignedInt(dataframe[i]);
    }
    if (checksum != calculatedChecksum) {
        Log.e(TAG, "Checksum error in data frame.  Ignoring.");
        return;
    }
    // Assign PM2.5 and PM10 values
    mPm25 = (Byte.toUnsignedInt(dataframe[6]) << 8) + Byte.toUnsignedInt(dataframe[7]);
    mPm10 = (Byte.toUnsignedInt(dataframe[8]) << 8) + Byte.toUnsignedInt(dataframe[9]);

    // Clear exception
    mLastException = null;
}
项目:OggAudioData    文件:OggAudioData.java   
private OggAudioData(InputStream is) throws Exception {
        PushbackInputStream stream = new PushbackInputStream(is, 20000000);
        long size = 0;
        int bt = 0;
        ArrayList<Byte> btList = new ArrayList<Byte>();

        while (bt != -1) {
                bt = stream.read();
                if (bt == -1) {
                        break;
                }
                btList.add(new Byte((byte) bt));
                size++;
        }

        byte[] reset = new byte[btList.size()];
        int j=0;
        for(Byte y: btList) {
                reset[j++] = y.byteValue();
        }

        stream.unread(reset);
        initValues(stream, size);
}
项目:auto-value-bundle    文件:AutoValue_TestClassBundled.java   
public static byte[] toPrimitive(Byte[] byteParam) {
    byte[] bytes = new byte[byteParam.length];
    for (int i = 0; i < byteParam.length; i++) {
        bytes[i] = byteParam[i];
    }
    return bytes;
}
项目:auto-value-bundle    文件:AutoValue_TestClassBundledGCM.java   
public static TestClassBundledGCM unbundle(Bundle bundle, Gson gson) {
    return new AutoValue_TestClassBundledGCM(
            bundle,
            Byte.parseByte(bundle.getString("some_byte")),
            Boolean.parseBoolean(bundle.getString("some_boolean")),
            Short.parseShort(bundle.getString("some_short")),
            Integer.parseInt(bundle.getString("some_int")),
            Long.parseLong(bundle.getString("some_long")),
            bundle.getString("some_char").charAt(0),
            Float.parseFloat(bundle.getString("some_float")),
            Double.parseDouble(bundle.getString("some_double")),
            bundle.getString("some_string"),
            bundle.getString("some_char_sequence"),
            gson.fromJson(bundle.getString("some_parcelable"), Parcelable.class),
            gson.fromJson(bundle.getString("some_parcelable_array_list"), new com.google.common.reflect.TypeToken<java.util.ArrayList<Parcelable>>(){}.getType()),
            gson.fromJson(bundle.getString("some_parcelable_sparse_array"), new com.google.common.reflect.TypeToken<android.util.SparseArray<Parcelable>>(){}.getType()),
            gson.fromJson(bundle.getString("some_serializable"), Serializable.class),
            gson.fromJson(bundle.getString("some_integer_array_list"), new com.google.common.reflect.TypeToken<java.util.ArrayList<Integer>>(){}.getType()),
            gson.fromJson(bundle.getString("some_string_array_list"), new com.google.common.reflect.TypeToken<java.util.ArrayList<String>>(){}.getType()),
            gson.fromJson(bundle.getString("some_char_sequence_array_list"), new com.google.common.reflect.TypeToken<java.util.ArrayList<CharSequence>>(){}.getType()),
            toPrimitive(gson.fromJson(bundle.getString("some_byte_array"), Byte[].class)),
            toPrimitive(gson.fromJson(bundle.getString("some_short_array"), Short[].class)),
            toPrimitive(gson.fromJson(bundle.getString("some_char_array"), Character[].class)),
            toPrimitive(gson.fromJson(bundle.getString("some_float_array"), Float[].class)),
            gson.fromJson(bundle.getString("some_unknown_object"), new com.google.common.reflect.TypeToken<UnknownObject>(){}.getType()),
            gson.fromJson(bundle.getString("some_unknown_object_list"), new com.google.common.reflect.TypeToken<ArrayList<UnknownObject>>(){}.getType()),
            gson.fromJson(bundle.getString("test_enum"), new com.google.common.reflect.TypeToken<TestEnum>(){}.getType()));
}
项目:auto-value-bundle    文件:AutoValue_TestClassBundledGCM.java   
public static byte[] toPrimitive(Byte[] byteParam) {
    byte[] bytes = new byte[byteParam.length];
    for (int i = 0; i < byteParam.length; i++) {
        bytes[i] = byteParam[i];
    }
    return bytes;
}
项目:thesis-disassembler    文件:TypeInsnNode_instanceof.java   
public void isInstance() {
    int localInt = 1;
    boolean bool = this instanceof Object && localInt < Byte.MIN_VALUE;
    if ("" instanceof Object) {
        localInt = 2;
    } else {
        localInt = -1;
    }
}
项目:ActivityScreens    文件:PrimitiveWrappersActivityScreen.java   
public PrimitiveWrappersActivityScreen(Character field1, Integer field2, Double field3, Float field4, Boolean field5,
                             Short field6, Byte field7, Long field8) {
    this.field1 = field1;
    this.field2 = field2;
    this.field3 = field3;
    this.field4 = field4;
    this.field5 = field5;
    this.field6 = field6;
    this.field7 = field7;
    this.field8 = field8;
}
项目:mpack-java    文件:MPack.java   
public final void encode(Byte object) throws IOException {
  this.encodeInteger(object);
}
项目:Flashtool    文件:BytesUtil.java   
public static Byte[] getBytes(String hexString) {
    int len = hexString.length();
    Byte[] data = new Byte[len / 2];
    for (int i = 0; i < len; i += 2) {
        data[i / 2] = (byte) ((Character.digit(hexString.charAt(i), 16) << 4)
                             + Character.digit(hexString.charAt(i+1), 16));
    }
    return data;
}
项目:mpack-java    文件:MPack.java   
public final void encode(Object object) throws IOException {
  if (object == null) {
    this.encodeNil();
  }
  else if (object instanceof Boolean) {
    this.encodeBoolean((Boolean) object);
  }
  else if (object instanceof Byte) {
    this.encodeInteger((Byte) object);
  }
  else if (object instanceof Short) {
    this.encodeInteger((Short) object);
  }
  else if (object instanceof Integer) {
    this.encodeInteger((Integer) object);
  }
  else if (object instanceof Long) {
    this.encodeInteger((Long) object);
  }
  else if (object instanceof Float) {
    this.encodeFloat((Float) object);
  }
  else if (object instanceof Double) {
    this.encodeFloat((Double) object);
  }
  else if (object instanceof String) {
    this.encodeString((String) object);
  }
  else if (object instanceof byte[]) {
    this.encodeBinary((byte[]) object);
  }
  else if (object instanceof List<?>) {
    this.encodeArray((List<?>) object);
  }
  else if (object instanceof Map<?, ?>) {
    this.encodeMap((Map<?, ?>) object);
  }
  else if (object instanceof Extended) {
    this.encodeExtended((Extended) object);
  }
  else {
    throw new IllegalArgumentException("MPack: no encoding available for objects of type " + object.getClass().toString());
  }
}