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:org.janusgraph.graphdb.serializer.SerializerTest.java

License:asdf

@Test
public void primitiveSerialization() {
    DataOutput out = serialize.getDataOutput(128);
    out.writeObjectNotNull(Boolean.FALSE);
    out.writeObjectNotNull(Boolean.TRUE);
    out.writeObjectNotNull(Byte.MIN_VALUE);
    out.writeObjectNotNull(Byte.MAX_VALUE);
    out.writeObjectNotNull((byte) 0);
    out.writeObjectNotNull(Short.MIN_VALUE);
    out.writeObjectNotNull(Short.MAX_VALUE);
    out.writeObjectNotNull((short) 0);
    out.writeObjectNotNull(Character.MIN_VALUE);
    out.writeObjectNotNull(Character.MAX_VALUE);
    out.writeObjectNotNull('a');
    out.writeObjectNotNull(Integer.MIN_VALUE);
    out.writeObjectNotNull(Integer.MAX_VALUE);
    out.writeObjectNotNull(0);/*from  w w  w .j  av a 2 s  . c  o m*/
    out.writeObjectNotNull(Long.MIN_VALUE);
    out.writeObjectNotNull(Long.MAX_VALUE);
    out.writeObjectNotNull(0L);
    out.writeObjectNotNull((float) 0.0);
    out.writeObjectNotNull(0.0);

    ReadBuffer b = out.getStaticBuffer().asReadBuffer();
    assertEquals(Boolean.FALSE, serialize.readObjectNotNull(b, Boolean.class));
    assertEquals(Boolean.TRUE, serialize.readObjectNotNull(b, Boolean.class));
    assertEquals(Byte.MIN_VALUE, serialize.readObjectNotNull(b, Byte.class).longValue());
    assertEquals(Byte.MAX_VALUE, serialize.readObjectNotNull(b, Byte.class).longValue());
    assertEquals(0, serialize.readObjectNotNull(b, Byte.class).longValue());
    assertEquals(Short.MIN_VALUE, serialize.readObjectNotNull(b, Short.class).longValue());
    assertEquals(Short.MAX_VALUE, serialize.readObjectNotNull(b, Short.class).longValue());
    assertEquals(0, serialize.readObjectNotNull(b, Short.class).longValue());
    assertEquals(Character.MIN_VALUE, serialize.readObjectNotNull(b, Character.class).charValue());
    assertEquals(Character.MAX_VALUE, serialize.readObjectNotNull(b, Character.class).charValue());
    assertEquals(new Character('a'), serialize.readObjectNotNull(b, Character.class));
    assertEquals(Integer.MIN_VALUE, serialize.readObjectNotNull(b, Integer.class).longValue());
    assertEquals(Integer.MAX_VALUE, serialize.readObjectNotNull(b, Integer.class).longValue());
    assertEquals(0, serialize.readObjectNotNull(b, Integer.class).longValue());
    assertEquals(Long.MIN_VALUE, serialize.readObjectNotNull(b, Long.class).longValue());
    assertEquals(Long.MAX_VALUE, serialize.readObjectNotNull(b, Long.class).longValue());
    assertEquals(0, serialize.readObjectNotNull(b, Long.class).longValue());
    assertEquals(0.0, serialize.readObjectNotNull(b, Float.class), 1e-20);
    assertEquals(0.0, serialize.readObjectNotNull(b, Double.class), 1e-20);

}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java

@Test
public void testConfigurationPropertiesWithByteArray() {
    ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray();

    Byte byteValue = config.byteArray[0];

    assertEquals(Byte.class, byteValue.getClass());
    assertEquals(Byte.MAX_VALUE, byteValue.byteValue());
    assertEquals(8, config.byteArray.length);
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java

@Test
public void testConfigurationPropertiesWithByteList() {
    ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList();

    Byte byteValue = config.byteList.get(0);

    assertEquals(Byte.class, byteValue.getClass());
    assertEquals(Byte.MAX_VALUE, byteValue.byteValue());
    assertEquals(8, config.byteList.size());
}

From source file:mil.jpeojtrs.sca.util.tests.AnyUtilsTest.java

@Test
public void test_convertAny() throws Exception {
    final Boolean result = (Boolean) AnyUtils.convertAny(this.any);

    Assert.assertTrue(result);/*from  w w  w  .  j  a  va 2s. c o  m*/

    Assert.assertNull(AnyUtils.convertAny(null));

    String str = (String) AnyUtils.convertAny(AnyUtils.toAny("2", TCKind.tk_string));
    Assert.assertEquals("2", str);
    str = (String) AnyUtils.convertAny(AnyUtils.toAny("3", TCKind.tk_wstring));
    Assert.assertEquals("3", str);
    final short b = (Short) AnyUtils.convertAny(AnyUtils.toAny(Byte.MAX_VALUE, TCKind.tk_octet));
    Assert.assertEquals(Byte.MAX_VALUE, b);
    char c = (Character) AnyUtils.convertAny(AnyUtils.toAny(Character.MAX_VALUE, TCKind.tk_char));
    Assert.assertEquals(Character.MAX_VALUE, c);
    c = (Character) AnyUtils.convertAny(AnyUtils.toAny(new Character('2'), TCKind.tk_wchar));
    Assert.assertEquals('2', c);
    final short s = (Short) AnyUtils.convertAny(AnyUtils.toAny(Short.MAX_VALUE, TCKind.tk_short));
    Assert.assertEquals(Short.MAX_VALUE, s);
    final int i = (Integer) AnyUtils.convertAny(AnyUtils.toAny(Integer.MAX_VALUE, TCKind.tk_long));
    Assert.assertEquals(Integer.MAX_VALUE, i);
    final long l = (Long) AnyUtils.convertAny(AnyUtils.toAny(Long.MAX_VALUE, TCKind.tk_longlong));
    Assert.assertEquals(Long.MAX_VALUE, l);
    final float f = (Float) AnyUtils.convertAny(AnyUtils.toAny(Float.MAX_VALUE, TCKind.tk_float));
    Assert.assertEquals(Float.MAX_VALUE, f, 0.00001);
    final double d = (Double) AnyUtils.convertAny(AnyUtils.toAny(Double.MAX_VALUE, TCKind.tk_double));
    Assert.assertEquals(Double.MAX_VALUE, d, 0.00001);
    final int us = (Integer) AnyUtils.convertAny(AnyUtils.toAny(Short.MAX_VALUE, TCKind.tk_ushort));
    Assert.assertEquals(Short.MAX_VALUE, us);
    final long ui = (Long) AnyUtils.convertAny(AnyUtils.toAny(Integer.MAX_VALUE, TCKind.tk_ulong));
    Assert.assertEquals(Integer.MAX_VALUE, ui);
    final BigInteger ul = (BigInteger) AnyUtils.convertAny(AnyUtils.toAny(Long.MAX_VALUE, TCKind.tk_ulonglong));
    Assert.assertEquals(Long.MAX_VALUE, ul.longValue());

    /** TODO Big Decimal not supported
    final BigDecimal fix = (BigDecimal) AnyUtils.convertAny(AnyUtils.toAny(new BigDecimal(1.0), TCKind.tk_fixed));
    Assert.assertEquals(1.0, fix.doubleValue(), 0.00001);
    */

    Any tmpAny = (Any) AnyUtils.convertAny(AnyUtils.toAny(AnyUtils.toAny(1, TCKind.tk_long), TCKind.tk_any));
    Assert.assertNotNull(tmpAny);
    Assert.assertEquals(1, tmpAny.extract_long());
    /** TODO Why do these not work in Jacorb? **/
    //      tmpAny = (Any) AnyUtils.convertAny(AnyUtils.toAny(AnyUtils.toAny((short) 1, TCKind.tk_short), TCKind.tk_value));
    //      Assert.assertNotNull(tmpAny);
    //      Assert.assertEquals((short) 1, tmpAny.extract_short());
    //      final TypeCode tmpType = (TypeCode) AnyUtils.convertAny(AnyUtils.toAny(tmpAny.type(), TCKind.tk_TypeCode));
    //      Assert.assertNotNull(tmpType);
    //      Assert.assertEquals(TCKind._tk_short, tmpType.kind().value());
    //      final Object obj = AnyUtils.convertAny(null, tmpType);
    //      Assert.assertNull(obj);
}

From source file:org.janusgraph.graphdb.database.log.TransactionLogHeader.java

private DataOutput serializeHeader(Serializer serializer, int capacity, LogTxStatus status,
        EnumMap<LogTxMeta, Object> meta) {
    Preconditions.checkArgument(status != null && meta != null, "Invalid status or meta");
    DataOutput out = serializer.getDataOutput(capacity);
    out.putLong(times.getTime(txTimestamp));
    VariableLong.writePositive(out, transactionId);
    out.writeObjectNotNull(status);/*from   ww  w. jav  a2  s  .c om*/

    Preconditions.checkArgument(meta.size() < Byte.MAX_VALUE, "Too much meta data: %s", meta.size());
    out.putByte(VariableLong.unsignedByte(meta.size()));
    for (Map.Entry<LogTxMeta, Object> metaentry : meta.entrySet()) {
        assert metaentry.getValue() != null;
        out.putByte(VariableLong.unsignedByte(metaentry.getKey().ordinal()));
        out.writeObjectNotNull(metaentry.getValue());
    }
    return out;
}

From source file:sh.isaac.api.chronicle.VersionType.java

/**
 * Gets the from token./*w  w w .j  a  v a2 s .c o  m*/
 *
 * @param token the token
 * @return the from token
 */
public static VersionType getFromToken(byte token) {
    switch (token) {
    case 0:
        return MEMBER;

    case 1:
        return COMPONENT_NID;

    case 2:
        return LONG;

    case 4:
        return LOGIC_GRAPH;

    case 5:
        return STRING;

    case 6:
        return DYNAMIC;

    case 7:
        return DESCRIPTION;

    case 9:
        return CONCEPT;

    case 10:
        return RF2_RELATIONSHIP;
    case 11:
        return LOINC_RECORD;

    // Ideally, all of the below would be represented as dynamic semantics, 
    // but quick, removable implementation for now. 
    case Byte.MAX_VALUE - 12:
        return Str1_Nid2_Nid3_Nid4;

    case Byte.MAX_VALUE - 11:
        return Str1_Str2_Nid3_Nid4_Nid5;

    case Byte.MAX_VALUE - 10:
        return Nid1_Nid2;

    case Byte.MAX_VALUE - 9:
        return Nid1_Nid2_Int3;

    case Byte.MAX_VALUE - 8:
        return Nid1_Nid2_Str3;

    case Byte.MAX_VALUE - 7:
        return Nid1_Int2;

    case Byte.MAX_VALUE - 6:
        return Nid1_Str2;

    case Byte.MAX_VALUE - 5:
        return Nid1_Int2_Str3_Str4_Nid5_Nid6;

    case Byte.MAX_VALUE - 4:
        return Int1_Int2_Str3_Str4_Str5_Nid6_Nid7;

    case Byte.MAX_VALUE - 3:
        return Str1_Str2;

    case Byte.MAX_VALUE - 2:
        return Str1_Str2_Nid3_Nid4;

    case Byte.MAX_VALUE - 1:
        return Str1_Str2_Str3_Str4_Str5_Str6_Str7;

    default:
        throw new UnsupportedOperationException("d Can't handle: " + token);
    }
}

From source file:streamflow.model.generator.RandomGenerator.java

public static Byte randomByte() {
    return (byte) (Byte.MIN_VALUE + RandomUtils.nextInt(Byte.MAX_VALUE - Byte.MIN_VALUE));
}

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

@Test
public void testSendingByteJsonWithResponseJson() throws IOException {
    final EventBusMessageType messageType = EventBusMessageType.Byte;
    final Byte sentByte = Byte.MAX_VALUE;
    int port = findFreePort();
    String responseUrl = createHttpServerUrl(port);
    Map<String, String> expectations = createExpectations("someaddress",
            Base64.encodeAsString(sentByte.toString()), messageType, responseUrl, MediaType.APPLICATION_JSON);
    String responseBody = TemplateHelper.generateOutputUsingTemplate(SEND_RESPONSE_TEMPLATE_JSON, expectations);
    createHttpServer(port, MediaType.APPLICATION_JSON, responseBody);
    Handler<Message> messageConsumerHandler = new MessageSendWithReplyHandler(sentByte, expectations);
    vertx.eventBus().registerHandler(expectations.get("address"), messageConsumerHandler);
    String requestBody = TemplateHelper.generateOutputUsingTemplate(SEND_REQUEST_TEMPLATE_JSON, expectations);
    HttpRequestHelper.sendHttpPostRequest(url, requestBody, (VertxInternal) vertx,
            Status.ACCEPTED.getStatusCode(), MediaType.APPLICATION_JSON);
}

From source file:egovframework.rte.fdl.idgnr.impl.AbstractIdGnrService.java

/**
 * Returns Byte ? ? ID //from  ww w  . ja va 2 s  .co m
 * @return the next Id.
 * @throws FdlException
 *         ? ?  Byte  
 */
public final byte getNextByteId() throws FdlException {
    return (byte) getNextLongIdChecked(Byte.MAX_VALUE);
}

From source file:com.mozilla.hadoop.hbase.mapreduce.MultiScanTableMapReduceUtil.java

/**
 * Same as above version but allows for specifying batch size as well
 * @param startCal/*from ww  w .ja  va  2 s  .  c om*/
 * @param endCal
 * @param dateFormat
 * @param columns
 * @param caching
 * @param cacheBlocks
 * @param batch
 * @return
 */
public static Scan[] generateBytePrefixScans(Calendar startCal, Calendar endCal, String dateFormat,
        List<Pair<String, String>> columns, int caching, boolean cacheBlocks, int batch) {
    ArrayList<Scan> scans = new ArrayList<Scan>();

    SimpleDateFormat rowsdf = new SimpleDateFormat(dateFormat);
    long endTime = DateUtil.getEndTimeAtResolution(endCal.getTimeInMillis(), Calendar.DATE);

    byte[] temp = new byte[1];
    while (startCal.getTimeInMillis() < endTime) {
        for (byte b = Byte.MIN_VALUE; b < Byte.MAX_VALUE; b++) {
            int d = Integer.parseInt(rowsdf.format(startCal.getTime()));

            Scan s = new Scan();
            s.setCaching(caching);
            s.setCacheBlocks(cacheBlocks);
            if (batch > 1) {
                s.setBatch(batch);
            }
            // add columns
            for (Pair<String, String> pair : columns) {
                s.addColumn(pair.getFirst().getBytes(), pair.getSecond().getBytes());
            }

            temp[0] = b;
            s.setStartRow(Bytes.add(temp, Bytes.toBytes(String.format("%06d", d))));
            s.setStopRow(Bytes.add(temp, Bytes.toBytes(String.format("%06d", d + 1))));
            if (LOG.isDebugEnabled()) {
                LOG.info("Adding start-stop range: " + temp + String.format("%06d", d) + " - " + temp
                        + String.format("%06d", d + 1));
            }

            scans.add(s);
        }

        startCal.add(Calendar.DATE, 1);
    }

    return scans.toArray(new Scan[scans.size()]);
}