Example usage for java.lang Character MAX_VALUE

List of usage examples for java.lang Character MAX_VALUE

Introduction

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

Prototype

char MAX_VALUE

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

Click Source Link

Document

The constant value of this field is the largest value of type char , '\u005CuFFFF' .

Usage

From source file:CharRange.java

/**
 * <p>Are all the characters of the passed in range contained in
 * this range.</p>//from w  ww . j a  va 2  s.  c  o  m
 *
 * @param range  the range to check against
 * @return <code>true</code> if this range entirely contains the input range
 * @throws IllegalArgumentException if <code>null</code> input
 */
public boolean contains(CharRange range) {
    if (range == null) {
        throw new IllegalArgumentException("The Range must not be null");
    }
    if (negated) {
        if (range.negated) {
            return start >= range.start && end <= range.end;
        } else {
            return range.end < start || range.start > end;
        }
    } else {
        if (range.negated) {
            return start == 0 && end == Character.MAX_VALUE;
        } else {
            return start <= range.start && end >= range.end;
        }
    }
}

From source file:org.largecollections.FastCacheMap.java

public int size() {
    // Not reliable. Only an approximation
    Range r = new Range(bytes(Character.toString(Character.MIN_VALUE)),
            bytes(Character.toString(Character.MAX_VALUE)));
    long[] l = this.db.getApproximateSizes(r);
    if (l != null && l.length > 0) {
        return (int) l[0];
    }// www .j a  v a2  s.c o  m
    return 0;
}

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

public SimpleLang() {

    emptyString = StringUtils.EMPTY;// w  w w . j a va  2  s  . c om

    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.hdfs.server.datanode.web.webhdfs.ParameterParser.java

/**
 * Helper to decode half of a hexadecimal number from a string.
 * @param c The ASCII character of the hexadecimal number to decode.
 * Must be in the range {@code [0-9a-fA-F]}.
 * @return The hexadecimal value represented in the ASCII character
 * given, or {@link Character#MAX_VALUE} if the character is invalid.
 *//* w w w  .  jav  a  2  s  . co m*/
private static char decodeHexNibble(final char c) {
    if ('0' <= c && c <= '9') {
        return (char) (c - '0');
    } else if ('a' <= c && c <= 'f') {
        return (char) (c - 'a' + 10);
    } else if ('A' <= c && c <= 'F') {
        return (char) (c - 'A' + 10);
    } else {
        return Character.MAX_VALUE;
    }
}

From source file:com.sun.faces.application.StateManagerImpl.java

private String createUniqueRequestId() {
    if (requestIdSerial++ == Character.MAX_VALUE) {
        requestIdSerial = 0;//from   ww  w.j  av a2  s .co m
    }
    return UIViewRoot.UNIQUE_ID_PREFIX + ((int) requestIdSerial);
}

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  ww  . j  a v  a 2s  .  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: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);//www.  j  a va 2 s.  c om

    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:streamflow.model.generator.RandomGenerator.java

public static Character randomChar() {
    return (char) (Character.MIN_VALUE + RandomUtils.nextInt(Character.MAX_VALUE - Character.MIN_VALUE));
}

From source file:xbird.xquery.misc.StringChunk.java

protected long allocateCharChunk(final char[] src, final int start, final int length) {
    assert (length < CHUNKED_THRESHOLD) : length;
    final int reqlen = length + 1; // actual length is store in first char. 
    final long lpage;
    if (((_cpointer & BLOCK_MASK) + reqlen) > DEFAULT_BLOCK_SIZE_L) {
        // spanning pages is not allowed, allocate in next chunk.
        lpage = (_cpointer >> BLOCK_SHIFT) + 1;
        _cpointer = lpage * DEFAULT_BLOCK_SIZE_L;
    } else {//from ww  w  . java  2 s.  co  m
        lpage = _cpointer >> BLOCK_SHIFT;
    }
    final int page = (int) lpage;
    if (page >= _cchunks.length) {
        enlarge((int) (_cchunks.length * ENLARGE_PAGES_FACTOR));
    }
    if (_cchunks[page] == null) {
        _cchunks[page] = new char[DEFAULT_BLOCK_SIZE];
    }
    final long lblock = _cpointer & BLOCK_MASK;
    final int block = (int) lblock;
    assert (length <= Character.MAX_VALUE) : length;
    _cchunks[page][block] = (char) length;
    System.arraycopy(src, start, _cchunks[page], block + 1, length);
    final long index = _cpointer;
    _cpointer += reqlen; // move ahead pointer
    return chunkKey(index);
}

From source file:org.dspace.browse.BrowseDAOOracle.java

public int doOffsetQuery(String column, String value, boolean isAscending) throws BrowseException {
    TableRowIterator tri = null;// ww w .  j  av a 2s. co m

    if (column == null || value == null) {
        return 0;
    }

    try {
        List<Serializable> paramsList = new ArrayList<Serializable>();
        StringBuffer queryBuf = new StringBuffer();

        queryBuf.append("COUNT(").append(column).append(") AS offset ");

        buildSelectStatement(queryBuf, paramsList);
        if (isAscending) {
            queryBuf.append(" WHERE ").append(column).append("<?");
            paramsList.add(value);
        } else {
            queryBuf.append(" WHERE ").append(column).append(">?");
            paramsList.add(value + Character.MAX_VALUE);
        }

        if (containerTable != null
                || (value != null && valueField != null && tableDis != null && tableMap != null)) {
            queryBuf.append(" AND ").append("mappings.item_id=");
            queryBuf.append(table).append(".item_id");
        }

        tri = DatabaseManager.query(context, queryBuf.toString(), paramsList.toArray());

        TableRow row;
        if (tri.hasNext()) {
            row = tri.next();
            return row.getIntColumn("offset");
        } else {
            return 0;
        }
    } catch (SQLException e) {
        throw new BrowseException(e);
    } finally {
        if (tri != null) {
            tri.close();
        }
    }
}