Example usage for java.lang Byte toString

List of usage examples for java.lang Byte toString

Introduction

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

Prototype

public static String toString(byte b) 

Source Link

Document

Returns a new String object representing the specified byte .

Usage

From source file:edu.cornell.med.icb.goby.alignments.TestSkipTo.java

private void read10(InputStream is, long startOffset) throws IOException {
    DataInputStream dis = new DataInputStream(is);
    for (int i = 0; i < 10; i++) {
        final byte b = dis.readByte();
        System.out.println(Byte.toString(b));
        if (i == 9) {
            switch ((int) startOffset) {
            case 0:
                assertEquals(2, b);// w ww  .j  a v  a  2 s  .  c  om
                break;
            case 2:
                assertEquals(-59, b);
                break;
            case 9:
                assertEquals(0, b);
                break;

            }
        }
    }
}

From source file:org.shirdrn.tinyframework.core.conf.Context.java

public void setByte(String name, byte value) {
    set(name, Byte.toString(value));
}

From source file:com.alibaba.citrus.service.requestcontext.support.ValueListSupport.java

/**
 * ???/?
 *
 * @param value ?
 */
public void addValue(byte value) {
    addValue(Byte.toString(value));
}

From source file:com.sun.honeycomb.adm.client.AdminClientImpl.java

public HCSetupCell getSetupCell() throws MgmtException, ConnectException {

    // Fetch dummy object from server.
    HCSetupCell props = Fetcher.fetchHCSetupCell(SiloInfo.getInstance().getSiloUrl());

    ///*w  w w .  ja  va  2s.co  m*/
    // Fill initial values from HCCell and HCSilo adapters
    //
    HCCellProps cellProps = getCellProps(SiloInfo.getInstance().getUniqueCellId());

    HCSiloProps siloProps = getSiloProps();
    props.setCellId(Byte.toString(SiloInfo.getInstance().getUniqueCellId()));

    if (cellProps.getAdminVIP() != null) {
        props.setAdminVIP(cellProps.getAdminVIP());
    } else {
        props.setAdminVIP("uninitialized");
    }

    if (cellProps.getDataVIP() != null) {
        props.setDataVIP(cellProps.getDataVIP());
    } else {
        props.setDataVIP("uninitialized");
    }

    if (cellProps.getSpVIP() != null) {
        props.setSpVIP(cellProps.getSpVIP());
    } else {
        props.setSpVIP("uninitialized");
    }

    if (cellProps.getSubnet() != null) {
        props.setSubnet(cellProps.getSubnet());
    } else {
        props.setSubnet("uninitialized");
    }

    if (cellProps.getGateway() != null) {
        props.setGateway(cellProps.getGateway());
    } else {
        props.setGateway("uninitialized");
    }

    if (siloProps.getNtpServer() != null) {
        props.setNtpServer(siloProps.getNtpServer());
    } else {
        props.setNtpServer("uninitialized");
    }
    if (siloProps.getSmtpServer() != null) {
        props.setSmtpServer(siloProps.getSmtpServer());
    } else {
        props.setSmtpServer("uninitialized");
    }

    if (siloProps.getSmtpPort() != null) {
        props.setSmtpPort(siloProps.getSmtpPort());
    } else {
        props.setSmtpPort("uninitialized");
    }

    props.setAuthorizedClients("all");
    if (siloProps.getAuthorizedClients() != null) {
        props.setAuthorizedClients(siloProps.getAuthorizedClients());
    }

    if (siloProps.getExtLogger() != null) {
        props.setExtLogger(siloProps.getExtLogger());
    } else {
        props.setExtLogger("uninitialized");
    }

    if (siloProps.getDns() != null) {
        props.setDns(siloProps.getDns());
    } else {
        props.setDns("uninitialized");
    }

    if (siloProps.getDomainName() != null) {
        props.setDomainName(siloProps.getDomainName());
    } else {
        props.setDomainName("uninitialized");
    }
    if (siloProps.getDnsSearch() != null) {
        props.setDnsSearch(siloProps.getDnsSearch());
    } else {
        props.setDnsSearch("uninitialized");
    }

    if (siloProps.getPrimaryDnsServer() != null) {
        props.setPrimaryDnsServer(siloProps.getPrimaryDnsServer());
    } else {
        props.setPrimaryDnsServer("uninitialized");
    }
    if (siloProps.getSecondaryDnsServer() != null) {
        props.setSecondaryDnsServer(siloProps.getSecondaryDnsServer());
    } else {
        props.setSecondaryDnsServer("uninitialized");
    }
    if (siloProps.getNumAuthRules() != null) {
        props.setNumAuthRules(siloProps.getNumAuthRules());
    } else {
        props.setSecondaryDnsServer("uninitialized");
    }
    return props;
}

From source file:com.impetus.kundera.validation.rules.AttributeConstraintRule.java

/**
 * @param validationObject/*from  w  w w . j ava2s.co m*/
 * @return
 */
private String toString(Object validationObject) {
    String stringObject = null;
    if (validationObject.getClass().isAssignableFrom(int.class)
            || validationObject.getClass().isAssignableFrom(Integer.class)) {
        stringObject = Integer.toString((Integer) validationObject);

    } else if (validationObject.getClass().isAssignableFrom(byte.class)
            || validationObject.getClass().isAssignableFrom(Byte.class)) {
        stringObject = Byte.toString((Byte) validationObject);
    } else if (validationObject.getClass().isAssignableFrom(short.class)
            || validationObject.getClass().isAssignableFrom(Short.class)) {
        stringObject = Short.toString((Short) validationObject);
    }

    else if (validationObject.getClass().isAssignableFrom(BigDecimal.class)) {
        stringObject = validationObject.toString();
    } else if (validationObject.getClass().isAssignableFrom(Long.class)
            || validationObject.getClass().isAssignableFrom(long.class)) {
        stringObject = Long.toString((Long) validationObject);
    }

    else if (validationObject.getClass().isAssignableFrom(String.class)
            || validationObject.getClass().isAssignableFrom(String.class)) {
        stringObject = (String) validationObject;
    }

    return stringObject;
}

From source file:net.sbbi.upnp.messages.ActionMessage.java

/**
 * Set the value of an input parameter before a message service call
 * @param parameterName the parameter name
 * @param parameterValue the byte parameter value
 * @return the current ActionMessage object instance
 * @throws IllegalArgumentException if the provided parameterName is not valid for this message
 *         or if no input parameters are required for this message
 *//*  w w  w  . j  ava 2 s .  com*/
public ActionMessage setInputParameter(String parameterName, byte parameterValue)
        throws IllegalArgumentException {
    return setInputParameter(parameterName, Byte.toString(parameterValue));
}

From source file:org.apache.vxquery.index.IndexDocumentBuilder.java

private String[] printByte(TaggedValuePointable tvp, String path) {
    String[] result = { "", path };
    BytePointable bp = pp.takeOne(BytePointable.class);
    try {/*from w  ww. ja  va2s .co  m*/
        tvp.getValue(bp);
        result[0] = Byte.toString(bp.byteValue());
        result[1] = path + "/" + result[0];
    } finally {
        pp.giveBack(bp);
    }
    return result;
}

From source file:com.blackberry.logtools.LogTools.java

public void runPigLocal(Map<String, String> params, String out, String tmp, final boolean quiet,
        final boolean silent, Configuration conf, String queue_name, String additional_jars, File pig_tmp,
        ArrayList<String> D_options, String PIG_DIR, FileSystem fs)
        throws IllegalArgumentException, IOException {
    //Create temp file on local to hold data to sort
    final File local_tmp = Files.createTempDir();
    local_tmp.deleteOnExit();//from w w w . j a v  a  2 s. co  m

    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                logConsole(quiet, silent, warn, "Deleting tmp files in local tmp");
                delete(local_tmp);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }));

    //Set input parameter for pig job
    params.put("tmpdir", local_tmp.toString() + "/" + tmp);

    //Check for an out of '-', meaning write to stdout
    String pigout;
    if (out.equals("-")) {
        params.put("out", local_tmp + "/" + tmp + "/final");
        pigout = local_tmp + "/" + tmp + "/final";
    } else {
        params.put("out", local_tmp + "/" + StringEscapeUtils.escapeJava(out));
        pigout = StringEscapeUtils.escapeJava(out);
    }

    //Copy the tmp folder from HDFS to the local tmp directory, and delete the remote folder
    fs.copyToLocalFile(true, new Path(tmp), new Path(local_tmp + "/" + tmp));

    try {
        logConsole(quiet, silent, info, "Running PIG Command");
        conf.set("mapred.job.queue.name", queue_name);
        conf.set("pig.additional.jars", additional_jars);
        conf.set("pig.exec.reducers.bytes.per.reducer", Integer.toString(100 * 1000 * 1000));
        conf.set("pig.logfile", pig_tmp.toString());
        conf.set("hadoopversion", "23");
        //PIG temp directory set to be able to delete all temp files/directories
        conf.set("pig.temp.dir", local_tmp.getAbsolutePath());

        //Setting output separator for logdriver
        String DEFAULT_OUTPUT_SEPARATOR = "\t";
        Charset UTF_8 = Charset.forName("UTF-8");
        String outputSeparator = conf.get("logdriver.output.field.separator", DEFAULT_OUTPUT_SEPARATOR);
        byte[] bytes = outputSeparator.getBytes(UTF_8);
        if (bytes.length != 1) {
            System.err.println(
                    ";******************** The output separator must be a single byte in UTF-8. ******************** ");
            System.exit(1);
        }
        conf.set("logdriver.output.field.separator", Byte.toString(bytes[0]));

        dOpts(D_options, silent, out, conf);

        PigServer pigServer = new PigServer(ExecType.LOCAL, conf);
        UserGroupInformation.setConfiguration(new Configuration(false));
        pigServer.registerScript(PIG_DIR + "/formatAndSortLocal.pg", params);
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }

    logConsole(quiet, silent, warn, "PIG Job Completed.");

    if (out.equals("-")) {
        System.out.println(";#################### DATA RESULTS ####################");
        try {
            File results = new File(pigout);
            String[] resultList = results.list();

            //Find the files in the directory, open and printout results
            for (int i = 0; i < resultList.length; i++) {
                if (resultList[i].contains("part-") && !resultList[i].contains(".crc")) {
                    BufferedReader br = new BufferedReader(
                            new FileReader(new File(pigout + "/" + resultList[i])));
                    String line;
                    line = br.readLine();
                    while (line != null) {
                        System.out.println(line);
                        line = br.readLine();
                    }
                    br.close();
                }
            }
            System.out.println(";#################### END OF RESULTS ####################");
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    } else {
        fs.copyFromLocalFile(new Path(local_tmp + "/" + StringEscapeUtils.escapeJava(out)), new Path(pigout));
        System.out.println(
                ";#################### Done. Search results are in " + pigout + " ####################");
    }
}

From source file:com.sun.honeycomb.adm.client.AdminClientImpl.java

public void setSetupCell(HCSetupCell newProps)
        throws MgmtException, ConnectException, PermissionException, AdmException {

    if (!loggedIn())
        throw new PermissionException();

    byte thisCellId = SiloInfo.getInstance().getUniqueCellId();
    HCCell cell = getCell(SiloInfo.getInstance().getServerUrl(thisCellId));

    // This push call should be changed in a future release to
    // invoke a method on the HCSetupCellAdapter instead of doing the
    // push.  See CR6684437
    newProps.push();/* w  ww  .  j a v  a 2  s  .  c om*/

    String methodName = "setSetupCell";
    logSetupCellProps(Byte.toString(thisCellId), newProps, methodName);
    try {
        System.out.print("\nUpdating Switches ...");
        cell.updateSwitch(BigInteger.valueOf(0));
        System.out.print("\nUpdating Service Node ...");
        cell.updateServiceProcessor(BigInteger.valueOf(0));
        this._internalCall = true;
        System.out.println("\nRebooting nodes, switches, and service node ...");
        rebootCell(cell, true, true);
    } finally {
        System.out.println();
        this._internalCall = false;
    }
}

From source file:oracle.kv.hadoop.hive.table.TableSerDeBase.java

private void displayInitParams(final LazySerDeParameters params) {

    final String[] helperHosts = getKvHelperHosts();
    String helperHostsStr = null;
    if (helperHosts != null) {
        helperHostsStr = (Arrays.asList(helperHosts)).toString();
    }//w w w.j  av  a 2s.  c  o m

    final String[] hadoopHosts = getKvHadoopHosts();
    String hadoopHostsStr = null;
    if (hadoopHosts != null) {
        hadoopHostsStr = (Arrays.asList(hadoopHosts)).toString();
    }

    String hiveColumnNamesStr = null;
    String hiveColumnTypesStr = null;
    String nullSequenceStr = null;
    String isLastColumnTakesRestStr = null;
    String isEscapedStr = null;
    String escapeCharStr = null;
    if (params != null) {
        hiveColumnNamesStr = (params.getColumnNames()).toString();
        hiveColumnTypesStr = (params.getColumnTypes()).toString();
        nullSequenceStr = (params.getNullSequence()).toString();
        isLastColumnTakesRestStr = Boolean.toString(params.isLastColumnTakesRest());
        isEscapedStr = Boolean.toString(params.isEscaped());
        escapeCharStr = Byte.toString(params.getEscapeChar());
    }

    LOG.debug("kvStoreName = " + getKvStoreName());
    LOG.debug("kvHelperHosts = " + helperHostsStr);
    LOG.debug("kvHadoopHosts = " + hadoopHostsStr);
    LOG.debug("kvTableName = " + getKvTableName());
    LOG.debug("kvFieldNames = " + getKvFieldNames());
    LOG.debug("kvFieldTypes = " + getKvFieldTypes());
    LOG.debug("hiveTableName = " + getHiveTableName());
    LOG.debug("hiveSeparators = " + getSeparatorsStr(params));
    LOG.debug("hiveColumnNames = " + hiveColumnNamesStr);
    LOG.debug("hiveColumnTypes = " + hiveColumnTypesStr);
    LOG.debug("nullSequence = " + nullSequenceStr);
    LOG.debug("lastColumnTakesRest = " + isLastColumnTakesRestStr);
    LOG.debug("isEscaped = " + isEscapedStr);
    LOG.debug("escapeChar = " + escapeCharStr);
}