Example usage for java.lang Byte parseByte

List of usage examples for java.lang Byte parseByte

Introduction

In this page you can find the example usage for java.lang Byte parseByte.

Prototype

public static byte parseByte(String s) throws NumberFormatException 

Source Link

Document

Parses the string argument as a signed decimal byte .

Usage

From source file:gsn.beans.StreamElement.java

/***
 * Used with the new JRuby/Mongrel/Rest interface
 *//*from  ww  w  .  j  a va 2  s.c  o m*/

public static StreamElement fromREST(DataField[] outputFormat, String[] fieldNames, String[] fieldValues,
        String timestamp) {
    Serializable[] values = new Serializable[outputFormat.length];
    for (int i = 0; i < fieldNames.length; i++) {
        switch (findIndexInDataField(outputFormat, (String) fieldNames[i])) {
        case DataTypes.DOUBLE:
            values[i] = Double.parseDouble(fieldValues[i]);
            break;
        case DataTypes.FLOAT:
            values[i] = Float.parseFloat((String) fieldValues[i]);
            break;
        case DataTypes.BIGINT:
            //        case DataTypes.TIME :
            values[i] = Long.parseLong((String) fieldValues[i]);
            break;
        case DataTypes.TINYINT:
            values[i] = Byte.parseByte((String) fieldValues[i]);
            break;
        case DataTypes.SMALLINT:
        case DataTypes.INTEGER:
            values[i] = Integer.parseInt(fieldValues[i]);
            break;
        case DataTypes.CHAR:
        case DataTypes.VARCHAR:
            values[i] = new String(Base64.decodeBase64(fieldValues[i].getBytes()));
            break;
        case DataTypes.BINARY:
            values[i] = (byte[]) Base64.decodeBase64(fieldValues[i].getBytes());
            break;
        case -1:
        default:
            logger.error("The field name doesn't exit in the output structure : FieldName : "
                    + (String) fieldNames[i]);
        }
    }
    return new StreamElement(outputFormat, values, Long.parseLong(timestamp));
}

From source file:com.plusub.lib.annotate.JsonParserUtils.java

/**
 * ?// ww w.  j  a  v a  2  s  . c om
 * <p>Title: getType
 * <p>Description: 
 * @param field ?
 * @param defaultValue (Json?String)
 * @return defaultValue?obj
 */
private static Object getType(Field field, Object defaultValue, String fieldName) {
    Object value = defaultValue;
    if (showLog) {
        Logger.i(TAG,
                "getType:" + field.getName() + " " + field.getType().getName() + " " + " " + defaultValue);
    }
    if (defaultValue == null) {
        return value;
    }

    String type = field.getType().getName();
    Class clazz = field.getType();
    try {
        if (isBaseDataType(field.getType())) {
            String str = defaultValue + "";
            if (clazz.equals(String.class)) {
                value = defaultValue;
            } else if (clazz.equals(Integer.class) || type.equals("int")) {
                value = Integer.parseInt(str);
            } else if (clazz.equals(Boolean.class) || type.equals("boolean")) {
                String defaultStr = str;
                String result = defaultStr.toLowerCase();
                if (result.equals("true")) {
                    value = true;
                } else if (result.equals("false")) {
                    value = false;
                } else {
                    value = Integer.parseInt(result) > 0 ? true : false;
                }
            } else if (clazz.equals(Double.class) || type.equals("double")) {
                value = Double.parseDouble(str);
            } else if (clazz.equals(Float.class) || type.equals("float")) {
                value = Float.parseFloat(str);
            } else if (clazz.equals(Short.class) || type.equals("short")) {
                value = Short.parseShort(str);
            } else if (clazz.equals(Long.class) || type.equals("long")) {
                value = Long.parseLong(str);
            } else if (clazz.equals(Byte.class) || type.equals("byte")) {
                value = Byte.parseByte(str);
            }
        } else { //?
            if (showLog) {
                Logger.i(TAG, "?, " + defaultValue);
            }
        }
    } catch (Exception e) {
        // TODO: handle exception
        if (showLog) {
            Logger.e(TAG, "?" + fieldName + "String-->" + field.getType().getName()
                    + ", " + value);
            e.printStackTrace();
        }
        return value;
    }
    return value;
}

From source file:org.apache.jmeter.protocol.jdbc.AbstractJDBCTestElement.java

private void setArgument(PreparedStatement pstmt, String argument, int targetSqlType, int index)
        throws SQLException {
    switch (targetSqlType) {
    case Types.INTEGER:
        pstmt.setInt(index, Integer.parseInt(argument));
        break;//  w ww. j av  a 2  s  . c  om
    case Types.DECIMAL:
    case Types.NUMERIC:
        pstmt.setBigDecimal(index, new BigDecimal(argument));
        break;
    case Types.DOUBLE:
    case Types.FLOAT:
        pstmt.setDouble(index, Double.parseDouble(argument));
        break;
    case Types.CHAR:
    case Types.LONGVARCHAR:
    case Types.VARCHAR:
        pstmt.setString(index, argument);
        break;
    case Types.BIT:
    case Types.BOOLEAN:
        pstmt.setBoolean(index, Boolean.parseBoolean(argument));
        break;
    case Types.BIGINT:
        pstmt.setLong(index, Long.parseLong(argument));
        break;
    case Types.DATE:
        pstmt.setDate(index, Date.valueOf(argument));
        break;
    case Types.REAL:
        pstmt.setFloat(index, Float.parseFloat(argument));
        break;
    case Types.TINYINT:
        pstmt.setByte(index, Byte.parseByte(argument));
        break;
    case Types.SMALLINT:
        pstmt.setShort(index, Short.parseShort(argument));
        break;
    case Types.TIMESTAMP:
        pstmt.setTimestamp(index, Timestamp.valueOf(argument));
        break;
    case Types.TIME:
        pstmt.setTime(index, Time.valueOf(argument));
        break;
    case Types.BINARY:
    case Types.VARBINARY:
    case Types.LONGVARBINARY:
        pstmt.setBytes(index, argument.getBytes());
        break;
    case Types.NULL:
        pstmt.setNull(index, targetSqlType);
        break;
    default:
        pstmt.setObject(index, argument, targetSqlType);
    }
}

From source file:com.ibm.bi.dml.hops.cost.CostEstimator.java

/**
 * /*from ww w  .j  a v  a2  s .c o  m*/
 * @param inst
 * @param stats
 * @throws DMLRuntimeException 
 * @throws DMLUnsupportedOperationException 
 */
private void maintainMRJobInstVariableStatistics(Instruction inst, HashMap<String, VarStats> stats)
        throws DMLRuntimeException, DMLUnsupportedOperationException {
    MRJobInstruction jobinst = (MRJobInstruction) inst;

    //input sizes (varname, index mapping)
    String[] inVars = jobinst.getInputVars();
    int index = -1;
    for (String varname : inVars) {
        VarStats vs = stats.get(varname);
        if (vs == null)
            vs = _unknownStats;
        stats.put(String.valueOf(++index), vs);
    }

    //rand output
    String rdInst = jobinst.getIv_randInstructions();
    if (rdInst != null && rdInst.length() > 0) {
        StringTokenizer st = new StringTokenizer(rdInst, Lop.INSTRUCTION_DELIMITOR);
        while (st.hasMoreTokens()) //foreach rand instruction
        {
            String[] parts = InstructionUtils.getInstructionParts(st.nextToken());
            byte outIndex = Byte.parseByte(parts[2]);
            long rlen = parts[3].contains("##") ? -1 : UtilFunctions.parseToLong(parts[3]);
            long clen = parts[4].contains("##") ? -1 : UtilFunctions.parseToLong(parts[4]);
            long brlen = Long.parseLong(parts[5]);
            long bclen = Long.parseLong(parts[6]);
            long nnz = (long) (Double.parseDouble(parts[9]) * rlen * clen);
            VarStats vs = new VarStats(rlen, clen, brlen, bclen, nnz, false);
            stats.put(String.valueOf(outIndex), vs);
        }
    }

    //compute intermediate result indices
    HashMap<Byte, MatrixCharacteristics> dims = new HashMap<Byte, MatrixCharacteristics>();
    //populate input indices
    for (Entry<String, VarStats> e : stats.entrySet()) {
        if (UtilFunctions.isIntegerNumber(e.getKey())) {
            byte ix = Byte.parseByte(e.getKey());
            VarStats vs = e.getValue();
            if (vs != null) {
                MatrixCharacteristics mc = new MatrixCharacteristics(vs._rlen, vs._clen, (int) vs._brlen,
                        (int) vs._bclen, (long) vs._nnz);
                dims.put(ix, mc);
            }
        }
    }
    //compute dims for all instructions
    String[] instCat = new String[] { jobinst.getIv_randInstructions(),
            jobinst.getIv_recordReaderInstructions(), jobinst.getIv_instructionsInMapper(),
            jobinst.getIv_shuffleInstructions(), jobinst.getIv_aggInstructions(),
            jobinst.getIv_otherInstructions() };
    for (String linstCat : instCat)
        if (linstCat != null && linstCat.length() > 0) {
            String[] linst = linstCat.split(Instruction.INSTRUCTION_DELIM);
            for (String instStr : linst) {
                String instStr2 = replaceInstructionPatch(instStr);
                MRInstruction mrinst = MRInstructionParser.parseSingleInstruction(instStr2);
                MatrixCharacteristics.computeDimension(dims, mrinst);
            }
        }

    //create varstats if necessary
    for (Entry<Byte, MatrixCharacteristics> e : dims.entrySet()) {
        byte ix = e.getKey();
        if (!stats.containsKey(String.valueOf(ix))) {
            MatrixCharacteristics mc = e.getValue();
            VarStats vs = new VarStats(mc.getRows(), mc.getCols(), mc.getRowsPerBlock(), mc.getColsPerBlock(),
                    mc.getNonZeros(), false);
            stats.put(String.valueOf(ix), vs);
        }
    }

    //map result indexes
    String[] outLabels = jobinst.getOutputVars();
    byte[] resultIndexes = jobinst.getIv_resultIndices();
    for (int i = 0; i < resultIndexes.length; i++) {
        String varname = outLabels[i];
        VarStats varvs = stats.get(String.valueOf(resultIndexes[i]));
        if (varvs == null) {
            varvs = stats.get(outLabels[i]);
        }
        varvs._inmem = false;
        stats.put(varname, varvs);
    }
}

From source file:com.asakusafw.runtime.io.csv.CsvParser.java

@SuppressWarnings("deprecation")
private void fill0(ByteOption option, boolean doRecover) throws CsvFormatException {
    if (lineBuffer.hasRemaining()) {
        try {/*from   w ww . j a va  2  s . com*/
            byte value = Byte.parseByte(lineBuffer.toString());
            option.modify(value);
        } catch (NumberFormatException e) {
            if (doRecover && trimWhitespaces()) {
                fill0(option, false);
                return;
            }
            throw new CsvFormatException(createStatusInLine(Reason.INVALID_CELL_FORMAT, "byte value"), e);
        }
    } else {
        option.setNull();
    }
}

From source file:org.openiot.gsn.beans.StreamElement.java

public static StreamElement createElementFromREST(DataField[] outputFormat, String[] fieldNames,
        Object[] fieldValues) {/*www  .j  a  v  a 2 s  . co  m*/
    ArrayList<Serializable> values = new ArrayList<Serializable>();
    // ArrayList<String> fields = new ArrayList<String>();

    long timestamp = -1;
    for (int i = 0; i < fieldNames.length; i++) {
        if (fieldNames[i].equalsIgnoreCase("TIMED")) {
            timestamp = Long.parseLong((String) fieldValues[i]);
            continue;
        }
        boolean found = false;
        for (DataField f : outputFormat) {
            if (f.getName().equalsIgnoreCase(fieldNames[i])) {
                //     fields.add(fieldNames[i]);
                found = true;
                break;
            }
        }
        if (found == false)
            continue;

        switch (findIndexInDataField(outputFormat, fieldNames[i])) {
        case DataTypes.DOUBLE:
            values.add(Double.parseDouble((String) fieldValues[i]));
            break;
        case DataTypes.BIGINT:
            values.add(Long.parseLong((String) fieldValues[i]));
            break;
        case DataTypes.TINYINT:
            values.add(Byte.parseByte((String) fieldValues[i]));
            break;
        case DataTypes.SMALLINT:
            values.add(Short.parseShort((String) fieldValues[i]));
            break;
        case DataTypes.INTEGER:
            values.add(Integer.parseInt((String) fieldValues[i]));
            break;
        case DataTypes.CHAR:
        case DataTypes.VARCHAR:
            values.add(new String((byte[]) fieldValues[i]));
            break;
        case DataTypes.BINARY:
            try {
                //          StreamElementTest.md5Digest(fieldValues[ i ]);
            } catch (Exception e) {
                e.printStackTrace();
            }
            values.add((byte[]) fieldValues[i]);
            break;
        case -1:
        default:
            logger.error("The field name doesn't exit in the output structure : FieldName : "
                    + (String) fieldNames[i]);
        }

    }
    if (timestamp == -1)
        timestamp = System.currentTimeMillis();
    return new StreamElement(outputFormat, values.toArray(new Serializable[] {}), timestamp);
}

From source file:keel.Algorithms.Neural_Networks.NNEP_Common.data.DoubleTransposedDataSet.java

/**
  * <p>/*  w  ww .  ja  va  2s . co  m*/
 * Init the array stored in the DataSet
 * </p>
 * @throws IOException, NumberFormatException
 */

public void read() throws IOException, NumberFormatException {
    try {
        //DataInputStream to read of
        BufferedReader reader = new BufferedReader(new FileReader(fileName));

        //------------------//
        //Reading first line//
        //------------------//
        String values[] = reader.readLine().split("[\\s\\t]"); //Space or tab separated
        //Check the text format
        if (values.length < 3)
            throw new IOException("Illegal Text Format");
        //Reads number of observations
        setNofobservations(Integer.parseInt(values[0]));
        //Reads number of inputs
        setNofinputs(Integer.parseInt(values[1]));
        //Reads number of outputs
        setNofoutputs(Integer.parseInt(values[2]));

        //-------------------//
        //Reading second line//
        //-------------------//
        values = reader.readLine().split("[\\s\\t]"); //Space or tab separated
        //Count the number of real variables
        int nofrealvariables = 0;
        for (int i = 0; i < values.length; i++)
            if (Byte.parseByte(values[i]) == 1 || Byte.parseByte(values[i]) == 2)
                nofrealvariables++;
        //Check the text format
        if (nofrealvariables != nofvariables)
            throw new IOException("Illegal Text Format");
        //Reads the input schema array
        byte iSchema[] = new byte[values.length];
        for (int i = 0; i < iSchema.length; i++)
            iSchema[i] = Byte.parseByte(values[i]);

        //-------------------//
        //Reading other lines//
        //-------------------//
        //Input Counter
        int ic = 0;
        //Output Counter
        int oc = 0;
        //For each observation
        for (int i = 0; i < nofobservations; i++) {
            //Read a line
            values = reader.readLine().split("[\\s\\t]"); //Space or tab
            //Check the text format
            if (values.length < iSchema.length)
                throw new IOException("Illegal Text Format");
            //Read values
            for (int j = 0; j < iSchema.length; j++) {
                //Read value
                double value = Double.parseDouble(values[j]);
                //If it is an input
                if (iSchema[j] == 1) {
                    array[ic % nofinputs][i] = value;
                    ic++;
                }
                //If it is an output
                if (iSchema[j] == 2) {
                    array[nofinputs + (oc % nofoutputs)][i] = value;
                    oc++;
                }
                //If (iSchema[j]!=2 && iSchema[j]!=1)
                //    then the value is ignored
            }
        }
    } catch (EOFException e) {
        System.out.println("Illegal Text Format");
        throw new IOException("Illegal Text Format");
    } catch (NumberFormatException e) {
        System.out.println("Number format exception");
        throw e;
    } catch (FileNotFoundException e) {
        System.out.println("File not found");
        throw e;
    }

    calculateMeans();
}

From source file:net.starschema.clouddb.jdbc.ScrollableResultset.java

/** {@inheritDoc} */
@Override//from w ww  .j ava2 s  .  c o  m
public byte getByte(int columnIndex) throws SQLException {
    String Value = this.getString(columnIndex);
    if (this.wasNull()) {
        return 0;
    } else {
        try {
            return Byte.parseByte(Value);
        } catch (NumberFormatException e) {
            throw new BQSQLException(e);
        }
    }
}

From source file:com.yangtsaosoftware.pebblemessenger.services.PebbleCenter.java

@Override
public void onCreate() {
    super.onCreate();
    Handler pebbleCenterHandler = new PebbleCenterHandler();
    mPebbleCenterHandler = new Messenger(pebbleCenterHandler);
    Constants.log(TAG_NAME, "Create PebbleCenter Messenger.");
    loadPref();/*from   ww  w . ja v  a 2  s . c o  m*/
    _contex = this;
    //   busyBegin=new Time();
    //        waitQueue=new ArrayDeque<PebbleMessage>();
    sendQueue = new ArrayDeque<PebbleDictionary>();
    bindService(new Intent(this, MessageProcessingService.class), connToMessageProcessing,
            Context.BIND_AUTO_CREATE);
    Thread prepareThread = new PrepareThread();
    prepareThread.start();
    Thread sendMsgThread = new SendMsgThread();
    sendMsgThread.start();
    isPebbleEnable = PebbleKit.isWatchConnected(_contex);
    PebbleKit.registerReceivedDataHandler(_contex, new PebbleKit.PebbleDataReceiver(Constants.PEBBLE_UUID) {
        @Override
        public void receiveData(Context context, int transactionId, PebbleDictionary data) {
            PebbleKit.sendAckToPebble(_contex, transactionId);
            //          appStatue++;
            Constants.log(TAG_NAME, "Received data form pebble");
            switch (data.getUnsignedIntegerAsLong(ID_COMMAND).intValue()) {
            case REQUEST_TRANSID_CALL_TABLE: {
                Constants.log(TAG_NAME, "Request call table.");
                clean_SendQue();
                Message msg = Message.obtain();
                msg.what = MessageProcessingService.MSG_GET_CALL_TABLE;
                try {
                    rMessageProcessingHandler.send(msg);
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
            }
                break;
            case REQUEST_TRANSID_MESSAGE_TABLE: {
                Constants.log(TAG_NAME, "Request message table.");
                clean_SendQue();
                Message msg = Message.obtain();
                msg.what = MessageProcessingService.MSG_GET_MESSAGE_TABLE;
                try {
                    rMessageProcessingHandler.send(msg);
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
            }
                break;
            case REQUEST_TRANSID_CALL: {
                clean_SendQue();
                Message msg = Message.obtain();
                msg.what = MessageProcessingService.MSG_GET_CALL;
                Bundle b = new Bundle();
                b.putString(MessageDbHandler.COL_CALL_ID, data.getString(ID_EXTRA_DATA));
                Constants.log(TAG_NAME, "Request call id:" + data.getString(ID_EXTRA_DATA));

                msg.setData(b);
                try {
                    rMessageProcessingHandler.send(msg);
                } catch (RemoteException e) {
                    e.printStackTrace();
                }

            }
                break;
            case REQUEST_TRANSID_MESSAGE:
                clean_SendQue();
                Message msg = Message.obtain();
                msg.what = MessageProcessingService.MSG_GET_MESSAGE;
                Bundle b = new Bundle();
                b.putString(MessageDbHandler.COL_MESSAGE_ID, data.getString(ID_EXTRA_DATA));
                Constants.log(TAG_NAME, "Request message id:" + data.getString(ID_EXTRA_DATA));

                msg.setData(b);
                try {
                    rMessageProcessingHandler.send(msg);
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
                break;
            case REQUEST_TRANSID_PICKUP_PHONE:
                TelephonyManager telMag = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
                Constants.log("Receivephone", "Receive phone:" + data.getString(ID_EXTRA_DATA2));
                if (telMag.getCallState() == TelephonyManager.CALL_STATE_RINGING) {
                    switch (data.getUnsignedIntegerAsLong(ID_EXTRA_DATA).intValue()) {
                    case REQUEST_EXTRA_SPEAKER_ON:
                        answerCall(true);
                        break;
                    case REQUEST_EXTRA_SPEAKER_OFF:
                        answerCall(false);
                        break;
                    }
                } else {
                    switch (data.getUnsignedIntegerAsLong(ID_EXTRA_DATA).intValue()) {
                    case REQUEST_EXTRA_SPEAKER_ON:
                        dialNumber(data.getString(ID_EXTRA_DATA2), true);
                        break;
                    case REQUEST_EXTRA_SPEAKER_OFF:
                        dialNumber(data.getString(ID_EXTRA_DATA2), false);
                        break;
                    }

                }
                //                pebbleBusy = false;
                break;
            case REQUEST_TRANSID_HANGOFF_PHONE:
                endCall();
                //                pebbleBusy=false;

                break;
            case REQUEST_TRANSID_HANGOFF_SMS1:
                Constants.log(TAG_NAME, "Request hangoff and send sms1");

                endCall();
                doSendSMSTo(data.getString(ID_EXTRA_DATA), sms1);
                //               pebbleBusy=false;

                break;
            case REQUEST_TRANSID_HANGOFF_SMS2:
                Constants.log(TAG_NAME, "Request hangoff and send sms2");

                endCall();
                doSendSMSTo(data.getString(ID_EXTRA_DATA), sms2);
                //              pebbleBusy=false;

                break;
            case REQUEST_TRANSID_CLOSE_APP:
                Constants.log(TAG_NAME, "Request close app command.");
                sendMsgThreadHandler.sendEmptyMessage(SEND_CLOSE_APP);
                //               need_delay=true;

                break;
            case REQUEST_TRANSID_NEXTPAGE:
                Constants.log(TAG_NAME, "Request send next page.");

                sendMsgThreadHandler.sendEmptyMessage(SEND_NEXT_PAGE);
                break;
            case REQUEST_TRANSID_READ_NOTIFY: {
                Constants.log(TAG_NAME, "Request  read msg");
                Message read_msg = Message.obtain();
                read_msg.what = MessageProcessingService.MSG_READ;
                Bundle bd = new Bundle();
                bd.putString(MessageDbHandler.COL_MESSAGE_ID,
                        data.getUnsignedIntegerAsLong(ID_EXTRA_DATA).toString());
                read_msg.setData(bd);
                try {
                    rMessageProcessingHandler.send(read_msg);
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
            }
                break;
            case REQUEST_TRANSID_IM_FREE:
                Constants.log(TAG_NAME, "Request pebble app is free to receive data.");

                //               need_delay = data.getUnsignedInteger(ID_EXTRA_DATA).intValue() == REQUEST_EXTRA_DELAY_ON ;
                //               clean_SendQue();
                break;
            case REQUEST_TRANSID_VERSION: {
                send_test_get_return = true;
                String result = data.getString(ID_EXTRA_DATA);
                Constants.log("PmpVersion", result);
                StringTokenizer tokens = new StringTokenizer(result, ".");

                Intent inner_intent = new Intent(SetupFragment.class.getName());
                inner_intent.putExtra(Constants.BROADCAST_VERSION,
                        new byte[] { Byte.parseByte(tokens.nextToken()), Byte.parseByte(tokens.nextToken()),
                                Byte.parseByte(tokens.nextToken()) });
                LocalBroadcastManager.getInstance(context).sendBroadcast(inner_intent);
                sendMsgThreadHandler.sendEmptyMessage(SEND_CLOSE_APP);
                break;
            }
            }
        }
    });

    PebbleKit.registerReceivedAckHandler(_contex, new PebbleKit.PebbleAckReceiver(Constants.PEBBLE_UUID) {
        @Override
        public void receiveAck(Context context, int transactionId) {
            Constants.log(TAG_NAME, "Get a receiveAck:" + String.valueOf(transactionId));
            switch (transactionId) {
            case TRANS_ID_COMMON:
                Constants.log(TAG_NAME, "Send continue...");
                //                  pebbleBusy=true;
                sendMsgThreadHandler.sendEmptyMessage(SEND_CONTINUE);
                break;
            case TRANS_ID_END:
                send_full_page = true;
                break;
            case TRANS_ID_EMPTY:
                //                 pebbleBusy=true;
                sendMsgThreadHandler.sendEmptyMessage(SEND_CONTINUE);
                break;
            case TRANS_ID_TEST: {
                break;
            }
            }
        }
    });

    PebbleKit.registerReceivedNackHandler(_contex, new PebbleKit.PebbleNackReceiver(Constants.PEBBLE_UUID) {
        @Override
        public void receiveNack(Context context, int transactionId) {
            Constants.log(TAG_NAME, "Get a receivedNack:" + String.valueOf(transactionId));
            if (PebbleKit.isWatchConnected(_contex)) {
                switch (transactionId) {
                case TRANS_ID_COMMON:
                    sendMsgThreadHandler.sendEmptyMessage(SEND_CONTINUE);
                    break;
                case TRANS_ID_END:
                    send_full_page = true;
                    break;
                case TRANS_ID_EMPTY:
                    //                   appStatue=0;
                    sendMsgThreadHandler.sendEmptyMessage(SEND_OPEN_APP);
                    break;
                case TRANS_ID_TEST: {
                    Intent inner_intent = new Intent(SetupFragment.class.getName());
                    inner_intent.putExtra(Constants.BROADCAST_VERSION, new byte[] { 0, 0, 0 });
                    LocalBroadcastManager.getInstance(context).sendBroadcast(inner_intent);
                }
                }
            } else {
                sendMsgThreadHandler.sendEmptyMessage(SEND_CLOSE_APP);
            }

        }
    });

    PebbleKit.registerPebbleConnectedReceiver(_contex, new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            isPebbleEnable = true;
        }
    });

    PebbleKit.registerPebbleDisconnectedReceiver(_contex, new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            isPebbleEnable = false;
            sendMsgThreadHandler.sendEmptyMessage(SEND_CLOSE_APP);
        }
    });

    BroadcastReceiver br = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            int command = intent.getIntExtra(Constants.BROADCAST_COMMAND, Constants.BROADCAST_PREFER_CHANGED);

            switch (command) {
            case Constants.BROADCAST_PREFER_CHANGED:
                loadPref();
                break;
            case Constants.BROADCAST_CALL_IDLE:
                if (callEnable) {
                    sendMsgThreadHandler.sendEmptyMessage(SEND_CALL_END);
                }
                break;
            case Constants.BROADCAST_CALL_HOOK:
                if (callEnable) {
                    sendMsgThreadHandler.sendEmptyMessage(SEND_CALL_HOOK);
                }
                break;
            case Constants.BROADCAST_PEBBLE_TEST:
                if (isPebbleEnable) {
                    prepareThreadHandler.sendEmptyMessage(PREPARE_TEST);
                }
                break;
            }
        }
    };
    IntentFilter intentFilter = new IntentFilter(PebbleCenter.class.getName());
    LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(br, intentFilter);
}

From source file:com.gdevelop.gwt.syncrpc.SyncClientSerializationStreamReader.java

public byte readByte() {
    Log.d("PROBLEMA", "Before parsing readChar: " + index);
    return Byte.parseByte(results.get(--index));
}