Example usage for java.lang Character MIN_VALUE

List of usage examples for java.lang Character MIN_VALUE

Introduction

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

Prototype

char MIN_VALUE

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

Click Source Link

Document

The constant value of this field is the smallest value of type char , '\u005Cu0000' .

Usage

From source file:org.apache.camel.dataformat.bindy.BindyAbstractFactory.java

public static Object getDefaultValueForPrimitive(Class<?> clazz) throws Exception {
    if (clazz == byte.class) {
        return Byte.MIN_VALUE;
    } else if (clazz == short.class) {
        return Short.MIN_VALUE;
    } else if (clazz == int.class) {
        return Integer.MIN_VALUE;
    } else if (clazz == long.class) {
        return Long.MIN_VALUE;
    } else if (clazz == float.class) {
        return Float.MIN_VALUE;
    } else if (clazz == double.class) {
        return Double.MIN_VALUE;
    } else if (clazz == char.class) {
        return Character.MIN_VALUE;
    } else if (clazz == boolean.class) {
        return false;
    } else {/*from   ww  w .  j a va 2s  . c  o m*/
        return null;
    }

}

From source file:org.apache.flink.table.runtime.functions.SqlFunctionUtils.java

public static String chr(long chr) {
    if (chr < 0) {
        return "";
    } else if ((chr & 0xFF) == 0) {
        return String.valueOf(Character.MIN_VALUE);
    } else {/*  w  w w.j  a va2s.c o m*/
        return String.valueOf((char) (chr & 0xFF));
    }
}

From source file:org.apache.sling.distribution.util.impl.DigestUtils.java

public static File rewriteDigestMessage(DigestOutputStream digestOutput, File target) throws IOException {
    File targetDigest = new File(target.getParentFile(), target.getName() + '.'
            + digestOutput.getMessageDigest().getAlgorithm().toLowerCase().replace('-', Character.MIN_VALUE));
    rewriteDigestMessage(digestOutput, new FileOutputStream(targetDigest));
    return targetDigest;
}

From source file:org.janusgraph.graphdb.serializer.SerializerTest.java

License:asdf

@Test
public void comparableStringSerialization() {
    //Characters//w  w w  .j a v a 2 s  . c  o m
    DataOutput out = serialize.getDataOutput(((int) Character.MAX_VALUE) * 2 + 8);
    for (char c = Character.MIN_VALUE; c < Character.MAX_VALUE; c++) {
        out.writeObjectNotNull(c);
    }
    ReadBuffer b = out.getStaticBuffer().asReadBuffer();
    for (char c = Character.MIN_VALUE; c < Character.MAX_VALUE; c++) {
        assertEquals(c, serialize.readObjectNotNull(b, Character.class).charValue());
    }

    //String
    for (int t = 0; t < 10000; t++) {
        DataOutput out1 = serialize.getDataOutput(32 + 5);
        DataOutput out2 = serialize.getDataOutput(32 + 5);
        String s1 = RandomGenerator.randomString(1, 32);
        String s2 = RandomGenerator.randomString(1, 32);
        out1.writeObjectByteOrder(s1, String.class);
        out2.writeObjectByteOrder(s2, String.class);
        StaticBuffer b1 = out1.getStaticBuffer();
        StaticBuffer b2 = out2.getStaticBuffer();
        assertEquals(s1, serialize.readObjectByteOrder(b1.asReadBuffer(), String.class));
        assertEquals(s2, serialize.readObjectByteOrder(b2.asReadBuffer(), String.class));
        assertEquals(s1 + " vs " + s2, Integer.signum(s1.compareTo(s2)), Integer.signum(b1.compareTo(b2)));
    }
}

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);/*  ww w . j a va 2 s. co 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:org.joda.primitives.collection.impl.AbstractTestCharCollection.java

public Character[] getFullNonNullElements() {
    return new Character[] { new Character((char) 2), new Character('a'), new Character('@'),
            new Character('Z'), new Character((char) 5000), new Character((char) 202),
            new Character(Character.MIN_VALUE), new Character(Character.MAX_VALUE) };
}

From source file:org.joda.primitives.iterator.impl.TestArrayCharIterator.java

@Override
public Iterator<Character> makeFullIterator() {
    char[] data = new char[] { new Character((char) 2), new Character('a'), new Character('@'),
            new Character('Z'), new Character((char) 5000), new Character((char) 202),
            new Character(Character.MIN_VALUE), new Character(Character.MAX_VALUE) };
    return new ArrayCharIterator(data);
}

From source file:org.kuali.kfs.vnd.batch.VendorExcludeInputFileType.java

@Override
public Object parse(byte[] fileByteContent) throws ParseException {
    LOG.info("Parsing Vendor Exclude Input File ...");

    // create CSVReader, using conventional separator, quote, null escape char, skip first line, use strict quote, ignore leading white space 
    int skipLine = 1; // skip the first line, which is the header line
    Reader inReader = new InputStreamReader(new ByteArrayInputStream(fileByteContent));
    CSVReader reader = new CSVReader(inReader, ',', '"', Character.MIN_VALUE, skipLine, true, true);

    List<DebarredVendorDetail> debarredVendors = new ArrayList<DebarredVendorDetail>();
    String[] nextLine;//from www . j  av  a 2  s .  c o  m
    DebarredVendorDetail vendor;
    int lineNumber = skipLine;

    try {
        while ((nextLine = reader.readNext()) != null) {
            lineNumber++;
            LOG.debug("Line " + lineNumber + ": " + nextLine[0]);

            vendor = new DebarredVendorDetail();
            boolean emptyLine = true;

            // this should never happen, as for an empty line, CSVReader.readNext returns a string array with an empty string as the only element 
            // but just in case somehow a zero sized array is returned, we skip it.
            if (nextLine.length == 0) {
                continue;
            }

            StringBuffer name = new StringBuffer();
            // if the name field is not empty, use that as vendor name 
            if (StringUtils.isNotEmpty(nextLine[0])) {
                name.append(nextLine[0]);
            }
            // otherwise, there should be a first/middle/last name, which we concatenate into vendor name
            else {
                if (nextLine.length > 1 && !StringUtils.isNotEmpty(nextLine[1])) {
                    name.append(" " + nextLine[1]);
                }
                if (nextLine.length > 2 && !StringUtils.isNotEmpty(nextLine[2])) {
                    name.append(" " + nextLine[2]);
                }
                if (nextLine.length > 3 && !StringUtils.isNotEmpty(nextLine[3])) {
                    name.append(" " + nextLine[3]);
                }
                if (nextLine.length > 4 && !StringUtils.isNotEmpty(nextLine[4])) {
                    name.append(" " + nextLine[4]);
                }
                if (nextLine.length > 5 && StringUtils.isNotEmpty(nextLine[5])) {
                    name.append(" " + nextLine[5]);
                }
            }
            if (StringUtils.isNotEmpty(name.toString())) {
                vendor.setName(StringUtils.left(name.toString(), FIELD_SIZES[0]));
                emptyLine = false;
            }

            if (nextLine.length > 6 && StringUtils.isNotEmpty(nextLine[6])) {
                vendor.setAddress1(StringUtils.left(nextLine[6], FIELD_SIZES[1]));
                emptyLine = false;
            }
            if (nextLine.length > 7 && StringUtils.isNotEmpty(nextLine[7])) {
                vendor.setAddress2(StringUtils.left(nextLine[7], FIELD_SIZES[2]));
                emptyLine = false;
            }
            if (nextLine.length > 8 && StringUtils.isNotEmpty(nextLine[8])) {
                vendor.setCity(StringUtils.left(nextLine[8], FIELD_SIZES[3]));
                emptyLine = false;
            }
            if (nextLine.length > 9 && StringUtils.isNotEmpty(nextLine[9])) {
                vendor.setProvince(StringUtils.left(nextLine[9], FIELD_SIZES[4]));
                emptyLine = false;
            }
            if (nextLine.length > 10 && StringUtils.isNotEmpty(nextLine[10])) {
                vendor.setState(StringUtils.left(nextLine[10], FIELD_SIZES[5]));
                emptyLine = false;
            }
            if (nextLine.length > 11 && StringUtils.isNotEmpty(nextLine[11])) {
                vendor.setZip(StringUtils.left(nextLine[11], FIELD_SIZES[6]));
                emptyLine = false;
            }
            if (nextLine.length > 13 && StringUtils.isNotEmpty(nextLine[13])) {
                vendor.setAliases(StringUtils.left(StringUtils.remove(nextLine[13], "\""), FIELD_SIZES[7]));
                emptyLine = false;
            }
            if (nextLine.length > 18 && StringUtils.isNotEmpty(nextLine[18])) {
                vendor.setDescription(StringUtils.left(nextLine[18], FIELD_SIZES[8]));
                emptyLine = false;
            }

            if (emptyLine) {
                /* give warnings on a line that doesn't have any useful vendor info
                LOG.warn("Note: line " + lineNumber + " in the Vendor Exclude Input File is skipped since all parsed fields are empty.");
                */
                // throw parser exception on a line that doesn't have any useful vendor info.
                // Since the file usually doesn't contain empty lines or lines with empty fields, this happening usually is a good indicator that 
                // some line ahead has wrong data format, for ex, missing a quote on a field, which could mess up the following fields and lines. 
                throw new ParseException("Line " + lineNumber
                        + " in the Vendor Exclude Input File contains no valid field or only empty fields within quote pairs. Please check the lines ahead to see if any field is missing quotes.");
            } else {
                vendor.setLoadDate(new Date(new java.util.Date().getTime()));
                debarredVendors.add(vendor);
            }
        }
    } catch (IOException ex) {
        throw new ParseException(
                "Error reading Vendor Exclude Input File at line " + lineNumber + ": " + ex.getMessage());
    }

    LOG.info("Total number of lines read from Vendor Exclude Input File: " + lineNumber);
    LOG.info("Total number of vendors parsed from Vendor Exclude Input File: " + debarredVendors.size());
    return debarredVendors;
}

From source file:org.kuali.ole.vnd.batch.VendorExcludeInputFileType.java

@Override
public Object parse(byte[] fileByteContent) throws ParseException {
    LOG.info("Parsing Vendor Exclude Input File ...");

    // create CSVReader, using conventional separator, quote, null escape char, skip first line, use strict quote, ignore leading white space 
    int skipLine = 1; // skip the first line, which is the header line
    Reader inReader = new InputStreamReader(new ByteArrayInputStream(fileByteContent));
    CSVReader reader = new CSVReader(inReader, ',', '"', Character.MIN_VALUE);

    List<DebarredVendorDetail> debarredVendors = new ArrayList<DebarredVendorDetail>();
    String[] nextLine;//from  w  w  w . ja  va  2s .  c o m
    DebarredVendorDetail vendor;
    int lineNumber = skipLine;

    try {
        while ((nextLine = reader.readNext()) != null) {
            lineNumber++;
            LOG.debug("Line " + lineNumber + ": " + nextLine[0]);

            vendor = new DebarredVendorDetail();
            boolean emptyLine = true;

            // this should never happen, as for an empty line, CSVReader.readNext returns a string array with an empty string as the only element 
            // but just in case somehow a zero sized array is returned, we skip it.
            if (nextLine.length == 0) {
                continue;
            }

            StringBuffer name = new StringBuffer();
            // if the name field is not empty, use that as vendor name 
            if (StringUtils.isNotEmpty(nextLine[0])) {
                name.append(nextLine[0]);
            }
            // otherwise, there should be a first/middle/last name, which we concatenate into vendor name
            else {
                if (nextLine.length > 1 && !StringUtils.isNotEmpty(nextLine[1])) {
                    name.append(" " + nextLine[1]);
                }
                if (nextLine.length > 2 && !StringUtils.isNotEmpty(nextLine[2])) {
                    name.append(" " + nextLine[2]);
                }
                if (nextLine.length > 3 && !StringUtils.isNotEmpty(nextLine[3])) {
                    name.append(" " + nextLine[3]);
                }
                if (nextLine.length > 4 && !StringUtils.isNotEmpty(nextLine[4])) {
                    name.append(" " + nextLine[4]);
                }
                if (nextLine.length > 5 && StringUtils.isNotEmpty(nextLine[5])) {
                    name.append(" " + nextLine[5]);
                }
            }
            if (StringUtils.isNotEmpty(name.toString())) {
                vendor.setName(StringUtils.left(name.toString(), FIELD_SIZES[0]));
                emptyLine = false;
            }

            if (nextLine.length > 6 && StringUtils.isNotEmpty(nextLine[6])) {
                vendor.setAddress1(StringUtils.left(nextLine[6], FIELD_SIZES[1]));
                emptyLine = false;
            }
            if (nextLine.length > 7 && StringUtils.isNotEmpty(nextLine[7])) {
                vendor.setAddress2(StringUtils.left(nextLine[7], FIELD_SIZES[2]));
                emptyLine = false;
            }
            if (nextLine.length > 8 && StringUtils.isNotEmpty(nextLine[8])) {
                vendor.setCity(StringUtils.left(nextLine[8], FIELD_SIZES[3]));
                emptyLine = false;
            }
            if (nextLine.length > 9 && StringUtils.isNotEmpty(nextLine[9])) {
                vendor.setProvince(StringUtils.left(nextLine[9], FIELD_SIZES[4]));
                emptyLine = false;
            }
            if (nextLine.length > 10 && StringUtils.isNotEmpty(nextLine[10])) {
                vendor.setState(StringUtils.left(nextLine[10], FIELD_SIZES[5]));
                emptyLine = false;
            }
            if (nextLine.length > 11 && StringUtils.isNotEmpty(nextLine[11])) {
                vendor.setZip(StringUtils.left(nextLine[11], FIELD_SIZES[6]));
                emptyLine = false;
            }
            if (nextLine.length > 13 && StringUtils.isNotEmpty(nextLine[13])) {
                vendor.setAliases(StringUtils.left(StringUtils.remove(nextLine[13], "\""), FIELD_SIZES[7]));
                emptyLine = false;
            }
            if (nextLine.length > 18 && StringUtils.isNotEmpty(nextLine[18])) {
                vendor.setDescription(StringUtils.left(nextLine[18], FIELD_SIZES[8]));
                emptyLine = false;
            }

            if (emptyLine) {
                /* give warnings on a line that doesn't have any useful vendor info
                LOG.warn("Note: line " + lineNumber + " in the Vendor Exclude Input File is skipped since all parsed fields are empty.");
                */
                // throw parser exception on a line that doesn't have any useful vendor info.
                // Since the file usually doesn't contain empty lines or lines with empty fields, this happening usually is a good indicator that 
                // some line ahead has wrong data format, for ex, missing a quote on a field, which could mess up the following fields and lines. 
                throw new ParseException("Line " + lineNumber
                        + " in the Vendor Exclude Input File contains no valid field or only empty fields within quote pairs. Please check the lines ahead to see if any field is missing quotes.");
            } else {
                vendor.setLoadDate(new Date(new java.util.Date().getTime()));
                debarredVendors.add(vendor);
            }
        }
    } catch (IOException ex) {
        throw new ParseException(
                "Error reading Vendor Exclude Input File at line " + lineNumber + ": " + ex.getMessage());
    }

    LOG.info("Total number of lines read from Vendor Exclude Input File: " + lineNumber);
    LOG.info("Total number of vendors parsed from Vendor Exclude Input File: " + debarredVendors.size());
    return debarredVendors;
}

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];
    }/*  w  w  w .j  a  va2  s . c o m*/
    return 0;
}