Example usage for java.lang Byte MAX_VALUE

List of usage examples for java.lang Byte MAX_VALUE

Introduction

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

Prototype

byte MAX_VALUE

To view the source code for java.lang Byte MAX_VALUE.

Click Source Link

Document

A constant holding the maximum value a byte can have, 27-1.

Usage

From source file:com.alvermont.terraj.fracplanet.colour.FloatRGBA.java

/**
 * Creates a new instance of FloatRGBA from an existing ByteRGBA object
 *
 *
 *
 * @param orig The FloatRGBA object to initialize the new instance from
 *//*from   ww w.  j  a v  a2  s  .  c  om*/
public FloatRGBA(ByteRGBA orig) {
    this.r = ((float) orig.getR()) / Byte.MAX_VALUE;
    this.g = ((float) orig.getG()) / Byte.MAX_VALUE;
    this.b = ((float) orig.getB()) / Byte.MAX_VALUE;
    this.a = ((float) orig.getA()) / Byte.MAX_VALUE;
}

From source file:org.apache.wink.itest.ParamQueryNotSetTest.java

/**
 * Tests that given a HttpMethod with a query or matrix parameter, if the
 * parameter is not sent, then the default value is given back for basic
 * Java types./*  w  w  w . j av a2 s  .c  o  m*/
 */
public void testByteParamEmpty() throws Exception {
    /*
     * query parameters
     */
    GetMethod getMethod = new GetMethod(getBaseURI() + "/queryparamnotset/byte");
    try {
        httpclient.executeMethod(getMethod);
        assertEquals(200, getMethod.getStatusCode());
        assertEquals("0", getMethod.getResponseBodyAsString());
    } finally {
        getMethod.releaseConnection();
    }

    byte b = (byte) r.nextInt(Byte.MAX_VALUE);
    System.out.println(b);
    getMethod = new GetMethod(getBaseURI() + "/queryparamnotset/byte?b=" + b);
    try {
        httpclient.executeMethod(getMethod);
        assertEquals(200, getMethod.getStatusCode());
        assertEquals("" + b, getMethod.getResponseBodyAsString());
    } finally {
        getMethod.releaseConnection();
    }

    /*
     * don't send in the right query
     */
    getMethod = new GetMethod(getBaseURI() + "/queryparamnotset/byte?b1=a");
    try {
        httpclient.executeMethod(getMethod);
        assertEquals(200, getMethod.getStatusCode());
        assertEquals("0", getMethod.getResponseBodyAsString());
    } finally {
        getMethod.releaseConnection();
    }

    /*
     * matrix parameters
     */
    b = (byte) r.nextInt(Byte.MAX_VALUE);
    System.out.println(b);
    getMethod = new GetMethod(getBaseURI() + "/matrixparamnotset/byte;b=" + b);
    try {
        httpclient.executeMethod(getMethod);
        assertEquals(200, getMethod.getStatusCode());
        assertEquals("" + b, getMethod.getResponseBodyAsString());
    } finally {
        getMethod.releaseConnection();
    }

    getMethod = new GetMethod(getBaseURI() + "/matrixparamnotset/byte");
    try {
        httpclient.executeMethod(getMethod);
        assertEquals(200, getMethod.getStatusCode());
        assertEquals("0", getMethod.getResponseBodyAsString());
    } finally {
        getMethod.releaseConnection();
    }

    getMethod = new GetMethod(getBaseURI() + "/matrixparamnotset/byte;b1=a");
    try {
        httpclient.executeMethod(getMethod);
        assertEquals(200, getMethod.getStatusCode());
        assertEquals("0", getMethod.getResponseBodyAsString());
    } finally {
        getMethod.releaseConnection();
    }
}

From source file:org.echocat.marquardt.common.CertificateValidatorUnitTest.java

License:asdf

private void givenSignedCertificateWithPayloadWithWrongVersion() throws IOException {
    givenSignedCertificate();
    _signedPayload[0] = Byte.MAX_VALUE;
}

From source file:com.alvermont.terraj.fracplanet.colour.ByteRGBA.java

/**
 * Creates a new instance of ByteRGBA from int colour values
 *
 * @param r The colour value for red/*from  w w  w  .  j ava2  s. c  o m*/
 * @param g The colour value for green
 * @param b The colour value for blue
 */
public ByteRGBA(int r, int g, int b) {
    this.r = (byte) r;
    this.g = (byte) g;
    this.b = (byte) b;
    this.a = Byte.MAX_VALUE;
}

From source file:org.vertx.java.http.eventbusbridge.integration.MessageSendTest.java

@Test
public void testSendingByteJson() throws IOException {
    final EventBusMessageType messageType = EventBusMessageType.Byte;
    final Byte sentByte = Byte.MAX_VALUE;
    Map<String, String> expectations = createExpectations("someaddress",
            Base64.encodeAsString(sentByte.toString()), messageType);
    Handler<Message> messageConsumerHandler = new MessageSendHandler(sentByte, expectations);
    vertx.eventBus().registerHandler(expectations.get("address"), messageConsumerHandler);
    String body = TemplateHelper.generateOutputUsingTemplate(SEND_REQUEST_TEMPLATE_JSON, expectations);
    HttpRequestHelper.sendHttpPostRequest(url, body, (VertxInternal) vertx, Status.ACCEPTED.getStatusCode(),
            MediaType.APPLICATION_JSON);
}

From source file:it.unipmn.di.dcs.common.conversion.Base64.java

/**
 * Decode a Base64 data./* w ww.java2  s. c o  m*/
 *
 * Original method name is <em>decode</em>.
 */
public static void Decode(char[] data, int off, int len, OutputStream ostream) throws IOException {
    char[] ibuf = new char[4];
    int ibufcount = 0;
    byte[] obuf = new byte[3];
    for (int i = off; i < off + len; i++) {
        char ch = data[i];
        if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
            ibuf[ibufcount++] = ch;
            if (ibufcount == ibuf.length) {
                ibufcount = 0;
                int obufcount = Decode0(ibuf, obuf, 0);
                ostream.write(obuf, 0, obufcount);
            }
        }
    }
}

From source file:org.apache.maven.classpath.munger.validation.JarValidationUtilsTest.java

private static byte[] createTestJar(Collection<? extends ZipEntry> entriesList, byte... data)
        throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream(
            data.length + entriesList.size() * 64 * 2 + Byte.MAX_VALUE);
    try (JarOutputStream jarFile = new JarOutputStream(baos)) {
        for (ZipEntry zipEntry : entriesList) {
            jarFile.putNextEntry(zipEntry);
            try {
                if (zipEntry.isDirectory()) {
                    continue;
                }//from   ww w.  j  a v  a2s .  co  m
                jarFile.write(data);
            } finally {
                jarFile.closeEntry();
            }
        }
    } finally {
        baos.close();
    }

    return baos.toByteArray();
}

From source file:com.rapidminer.operator.preprocessing.filter.InfiniteValueReplenishment.java

/**
 * Replaces the values/*  w w w  .  ja  v  a  2  s  .  c o m*/
 *
 * @throws UndefinedParameterError
 */
@Override
public double getReplenishmentValue(int functionIndex, ExampleSet exampleSet, Attribute attribute)
        throws UndefinedParameterError {
    int chosen = getParameterAsInt(PARAMETER_REPLENISHMENT_WHAT);
    switch (functionIndex) {
    case NONE:
        return Double.POSITIVE_INFINITY;
    case ZERO:
        return 0.0;
    case MAX_BYTE:
        return (chosen == 0) ? Byte.MAX_VALUE : Byte.MIN_VALUE;
    case MAX_INT:
        return (chosen == 0) ? Integer.MAX_VALUE : Integer.MIN_VALUE;
    case MAX_DOUBLE:
        return (chosen == 0) ? Double.MAX_VALUE : -Double.MAX_VALUE;
    case MISSING:
        return Double.NaN;
    case VALUE:
        return getParameterAsDouble(PARAMETER_REPLENISHMENT_VALUE);
    default:
        throw new RuntimeException("Illegal value functionIndex: " + functionIndex);
    }
}

From source file:com.qwazr.externalizor.SimpleLang.java

public SimpleLang() {

    emptyString = StringUtils.EMPTY;//from w  w  w.  ja  va 2  s .  c  o  m

    stringValue = RandomStringUtils.randomAscii(8);
    stringNullValue = null;
    stringArray = new String[RandomUtils.nextInt(5, 20)];
    stringArray[0] = null;
    for (int i = 1; i < stringArray.length; i++)
        stringArray[i] = RandomStringUtils.randomAscii(5);
    stringList = new ArrayList(Arrays.asList(stringArray));

    intLangValue = RandomUtils.nextInt();
    intNullValue = null;
    intArray = new Integer[RandomUtils.nextInt(5, 20)];
    intArray[0] = null;
    for (int i = 1; i < intArray.length; i++)
        intArray[i] = RandomUtils.nextInt();
    intList = new ArrayList(Arrays.asList(intArray));

    shortLangValue = (short) RandomUtils.nextInt(0, Short.MAX_VALUE);
    shortNullValue = null;
    shortArray = new Short[RandomUtils.nextInt(5, 20)];
    shortArray[0] = null;
    for (int i = 1; i < shortArray.length; i++)
        shortArray[i] = (short) RandomUtils.nextInt(0, Short.MAX_VALUE);
    shortList = new ArrayList(Arrays.asList(shortArray));

    longLangValue = RandomUtils.nextLong();
    longNullValue = null;
    longArray = new Long[RandomUtils.nextInt(5, 20)];
    longArray[0] = null;
    for (int i = 1; i < longArray.length; i++)
        longArray[i] = RandomUtils.nextLong();
    longList = new ArrayList(Arrays.asList(longArray));

    floatLangValue = (float) RandomUtils.nextFloat();
    floatNullValue = null;
    floatArray = new Float[RandomUtils.nextInt(5, 20)];
    floatArray[0] = null;
    for (int i = 1; i < floatArray.length; i++)
        floatArray[i] = RandomUtils.nextFloat();
    floatList = new ArrayList(Arrays.asList(floatArray));

    doubleLangValue = RandomUtils.nextDouble();
    doubleNullValue = null;
    doubleArray = new Double[RandomUtils.nextInt(5, 20)];
    doubleArray[0] = null;
    for (int i = 1; i < doubleArray.length; i++)
        doubleArray[i] = RandomUtils.nextDouble();
    doubleList = new ArrayList(Arrays.asList(doubleArray));

    booleanLangValue = RandomUtils.nextInt(0, 1) == 0;
    booleanNullValue = null;
    booleanArray = new Boolean[RandomUtils.nextInt(5, 20)];
    booleanArray[0] = null;
    for (int i = 1; i < booleanArray.length; i++)
        booleanArray[i] = RandomUtils.nextBoolean();
    booleanList = new ArrayList(Arrays.asList(booleanArray));

    byteLangValue = (byte) RandomUtils.nextInt(0, Byte.MAX_VALUE);
    byteNullValue = null;
    byteArray = new Byte[RandomUtils.nextInt(5, 20)];
    byteArray[0] = null;
    for (int i = 1; i < byteArray.length; i++)
        byteArray[i] = (byte) RandomUtils.nextInt(0, Byte.MAX_VALUE);
    byteList = new ArrayList(Arrays.asList(byteArray));

    charLangValue = (char) RandomUtils.nextInt(0, Character.MAX_VALUE);
    charNullValue = null;
    charArray = new Character[RandomUtils.nextInt(5, 20)];
    charArray[0] = null;
    for (int i = 1; i < charArray.length; i++)
        charArray[i] = (char) RandomUtils.nextInt(0, Character.MAX_VALUE);
    charList = new ArrayList(Arrays.asList(charArray));

    enumNull = null;
    enumValue = RandomUtils.nextInt(0, 1) == 0 ? EnumType.on : EnumType.off;
    enumArray = new EnumType[RandomUtils.nextInt(5, 20)];
    enumArray[0] = null;
    for (int i = 1; i < enumArray.length; i++)
        enumArray[i] = RandomUtils.nextInt(0, 1) == 0 ? EnumType.on : EnumType.off;
    enumList = new ArrayList(Arrays.asList(enumArray));
}

From source file:org.apache.hadoop.hive.ql.exec.spark.SparkReduceRecordHandler.java

@Override
@SuppressWarnings("unchecked")
public void init(JobConf job, OutputCollector output, Reporter reporter) throws Exception {
    perfLogger.PerfLogBegin(CLASS_NAME, PerfLogger.SPARK_INIT_OPERATORS);
    super.init(job, output, reporter);

    rowObjectInspector = new ObjectInspector[Byte.MAX_VALUE];
    ObjectInspector[] valueObjectInspector = new ObjectInspector[Byte.MAX_VALUE];
    ObjectInspector keyObjectInspector;/* w  w  w. ja v a 2  s .  c  o m*/

    ReduceWork gWork = Utilities.getReduceWork(job);

    reducer = gWork.getReducer();
    vectorized = gWork.getVectorMode();
    reducer.setParentOperators(null); // clear out any parents as reducer is the
    // root
    isTagged = gWork.getNeedsTagging();
    try {
        keyTableDesc = gWork.getKeyDesc();
        inputKeyDeserializer = ReflectionUtils.newInstance(keyTableDesc.getDeserializerClass(), null);
        SerDeUtils.initializeSerDe(inputKeyDeserializer, null, keyTableDesc.getProperties(), null);
        keyObjectInspector = inputKeyDeserializer.getObjectInspector();
        valueTableDesc = new TableDesc[gWork.getTagToValueDesc().size()];

        if (vectorized) {
            final int maxTags = gWork.getTagToValueDesc().size();
            keyStructInspector = (StructObjectInspector) keyObjectInspector;
            batches = new VectorizedRowBatch[maxTags];
            valueStructInspectors = new StructObjectInspector[maxTags];
            valueStringWriters = new List[maxTags];
            keysColumnOffset = keyStructInspector.getAllStructFieldRefs().size();
            buffer = new DataOutputBuffer();
        }

        for (int tag = 0; tag < gWork.getTagToValueDesc().size(); tag++) {
            // We should initialize the SerDe with the TypeInfo when available.
            valueTableDesc[tag] = gWork.getTagToValueDesc().get(tag);
            inputValueDeserializer[tag] = ReflectionUtils
                    .newInstance(valueTableDesc[tag].getDeserializerClass(), null);
            SerDeUtils.initializeSerDe(inputValueDeserializer[tag], null, valueTableDesc[tag].getProperties(),
                    null);
            valueObjectInspector[tag] = inputValueDeserializer[tag].getObjectInspector();

            ArrayList<ObjectInspector> ois = new ArrayList<ObjectInspector>();

            if (vectorized) {
                /* vectorization only works with struct object inspectors */
                valueStructInspectors[tag] = (StructObjectInspector) valueObjectInspector[tag];

                ObjectPair<VectorizedRowBatch, StandardStructObjectInspector> pair = VectorizedBatchUtil
                        .constructVectorizedRowBatch(keyStructInspector, valueStructInspectors[tag],
                                gWork.getVectorScratchColumnTypeMap());
                batches[tag] = pair.getFirst();
                final int totalColumns = keysColumnOffset
                        + valueStructInspectors[tag].getAllStructFieldRefs().size();
                valueStringWriters[tag] = new ArrayList<VectorExpressionWriter>(totalColumns);
                valueStringWriters[tag].addAll(Arrays.asList(
                        VectorExpressionWriterFactory.genVectorStructExpressionWritables(keyStructInspector)));
                valueStringWriters[tag].addAll(Arrays.asList(VectorExpressionWriterFactory
                        .genVectorStructExpressionWritables(valueStructInspectors[tag])));

                rowObjectInspector[tag] = pair.getSecond();
            } else {
                ois.add(keyObjectInspector);
                ois.add(valueObjectInspector[tag]);
                //reducer.setGroupKeyObjectInspector(keyObjectInspector);
                rowObjectInspector[tag] = ObjectInspectorFactory
                        .getStandardStructObjectInspector(Utilities.reduceFieldNameList, ois);
            }
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    ExecMapperContext execContext = new ExecMapperContext(job);
    localWork = gWork.getMapRedLocalWork();
    execContext.setJc(jc);
    execContext.setLocalWork(localWork);
    reducer.passExecContext(execContext);

    reducer.setReporter(rp);
    OperatorUtils.setChildrenCollector(Arrays.<Operator<? extends OperatorDesc>>asList(reducer), output);

    // initialize reduce operator tree
    try {
        LOG.info(reducer.dump(0));
        reducer.initialize(jc, rowObjectInspector);

        if (localWork != null) {
            for (Operator<? extends OperatorDesc> dummyOp : localWork.getDummyParentOp()) {
                dummyOp.setExecContext(execContext);
                dummyOp.initialize(jc, null);
            }
        }

    } catch (Throwable e) {
        abort = true;
        if (e instanceof OutOfMemoryError) {
            // Don't create a new object if we are already out of memory
            throw (OutOfMemoryError) e;
        } else {
            throw new RuntimeException("Reduce operator initialization failed", e);
        }
    }
    perfLogger.PerfLogEnd(CLASS_NAME, PerfLogger.SPARK_INIT_OPERATORS);
}