Example usage for java.lang Character valueOf

List of usage examples for java.lang Character valueOf

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static Character valueOf(char c) 

Source Link

Document

Returns a Character instance representing the specified char value.

Usage

From source file:com.itemanalysis.psychometrics.statistics.TwoWayTable.java

public double getColPct(char colValue) {
    return getColPct(Character.valueOf(colValue));
}

From source file:org.cloudgraph.hbase.scan.FuzzyRowKeyScanAssembler.java

private void assembleLiterals() {
    for (KeyFieldMapping fieldMapping : this.graph.getRowKeyFields()) {
        if (fieldCount > 0) {
            this.keyBytes.put(graph.getRowKeyFieldDelimiterBytes());
            this.infoBytes.put(delimMask);
        }/*from  w  w  w .j  a v a 2  s. co  m*/

        if (!(fieldMapping instanceof DataRowKeyFieldMapping)) {
            byte[] encodedValue = getEncodedKeyField(fieldMapping);
            this.keyBytes.put(encodedValue);
            byte[] tokenMask = getKeyFieldMask(fieldMapping, encodedValue.length);
            this.infoBytes.put(tokenMask);
            this.fieldCount++;
        } else {
            DataRowKeyFieldMapping dataFieldConfig = (DataRowKeyFieldMapping) fieldMapping;

            List<ScanLiteral> scanLiterals = this.scanLiterals.getLiterals(dataFieldConfig);
            // if no literal present, create a fuzzy wildcard
            // as per the field length
            if (scanLiterals == null || scanLiterals.size() == 0) {
                byte[] wildcard = new byte[dataFieldConfig.getMaxLength()];
                Arrays.fill(wildcard, (byte) Character.valueOf('*').charValue());
                this.keyBytes.put(wildcard); // no need for padding, we are
                // at max len
                byte[] fieldMask = new byte[dataFieldConfig.getMaxLength()];
                for (int i = 0; i < fieldMask.length; i++)
                    fieldMask[i] = this.variableMaskByte;
                this.infoBytes.put(fieldMask);
            } else {
                if (scanLiterals.size() > 1)
                    log.warn("expected single literal for data field - ignoring");
                FuzzyRowKeyLiteral fuzzyLiteral = (FuzzyRowKeyLiteral) scanLiterals.get(0);
                if (WildcardStringLiteral.class.isAssignableFrom(fuzzyLiteral.getClass())) {
                    WildcardStringLiteral wc = (WildcardStringLiteral) fuzzyLiteral;
                    String literal = wc.getContent();
                    if (literal.length() != wc.getFieldConfig().getMaxLength()) {
                        if (literal.startsWith(Wildcard.WILDCARD_CHAR)
                                && literal.endsWith(Wildcard.WILDCARD_CHAR)) {
                            throw new InvalidFuzzyRowKeyWildcardException(
                                    "wildcard expression length does not equal field max length ("
                                            + wc.getFieldConfig().getMaxLength() + ") for field '"
                                            + wc.getFieldConfig().getEndpointProperty().getName()
                                            + "' - fuzzy row key scan wildcard expressions, starting"
                                            + " and ending with a wildcard character, must exactly match (typically by padding with wildcards) the length of the target (composite)"
                                            + " row key field, as HBase fuzzy row key filters use fixed length masking.");
                        }
                    }
                }

                this.keyBytes.put(fuzzyLiteral.getFuzzyKeyBytes());
                this.infoBytes.put(fuzzyLiteral.getFuzzyInfoBytes());
            }

            this.fieldCount++;
        }
    }
}

From source file:pt.ist.expenditureTrackingSystem.presentationTier.actions.statistics.ChartGenerator.java

private static CategoryDataset refundProcessStatisticsActivityTimeChart(
        final RefundProcessActivityLogStatistics refundProcessActivityLogStatistics) {
    final DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    char c = 'A';
    for (final LogEntry logEntry : refundProcessActivityLogStatistics.getLogEntries()) {
        final WorkflowActivity abstractActivity = logEntry.getAbstractActivity();
        if (isRelevanteActivity(abstractActivity)) {
            final String name = abstractActivity.getLocalizedName();
            int indexOfSpan = name.indexOf('<');
            final String label = indexOfSpan > 0 ? name.substring(0, indexOfSpan) : name;
            dataset.addValue(logEntry.getDays(), "" + c + " - " + label, Character.valueOf(c++));
        }//from  ww w .  j a v  a 2 s  .  com
    }

    return dataset;
}

From source file:com.objy.se.ClassAccessor.java

public Object getCorrectValue(String strValue, LogicalType logicalType) {
    Object retValue = null;//from w w w .j av  a2  s  .  co  m
    switch (logicalType) {
    case INTEGER: {
        long attrValue = 0;
        try {
            if (!strValue.equals("")) {
                attrValue = Long.parseLong(strValue);
            }
        } catch (NumberFormatException nfEx) {
            //        System.out.println("... entry: " + entry.getValue() + " for raw: " + entry.getKey());
            nfEx.printStackTrace();
            throw nfEx;
        }
        retValue = Long.valueOf(attrValue);
    }
        break;
    case REAL: {
        double attrValue = 0;
        try {
            if (!strValue.equals("")) {
                attrValue = Double.parseDouble(strValue);
            }
        } catch (NumberFormatException nfEx) {
            //        System.out.println("... entry: " + entry.getValue() + " for raw: " + entry.getKey());
            nfEx.printStackTrace();
            throw nfEx;
        }
        retValue = Double.valueOf(attrValue);
    }
        break;
    case STRING:
        retValue = strValue;
        break;
    case BOOLEAN: {
        if (strValue.equalsIgnoreCase("TRUE") || strValue.equals("1")) {
            retValue = Boolean.valueOf(true);
        } else if (strValue.equalsIgnoreCase("FALSE") || strValue.equals("0")) {
            retValue = Boolean.valueOf(false);
        } else {
            LOG.error("Expected Boolean value but got: {}", strValue);
            throw new IllegalStateException("Possible invalid configuration... check mapper vs. schema"
                    + "... or check records for invalid values");
        }
    }
        break;

    case CHARACTER: {
        if (strValue.length() == 1) {
            retValue = Character.valueOf(strValue.charAt(0));
        } else { /* not a char value... report that */
            LOG.error("Expected Character value but got: {}", strValue);
            throw new IllegalStateException("Possible invalid configuration... check mapper vs. schema"
                    + "... or check records for invalid values");
        }
    }
        break;
    case DATE: {
        try {
            LocalDate ldate = LocalDate.parse(strValue, dateFormatter);
            //            System.out.println("... ... year: " + ldate.getYear() + " - month:" + ldate.getMonthValue());
            retValue = new com.objy.db.Date(ldate.getYear(), ldate.getMonthValue(), ldate.getDayOfMonth());
        } catch (DateTimeParseException ex) {
            LOG.error(ex.toString());
            throw new IllegalStateException("Possible invalid configuration... check mapper vs. schema"
                    + "... or check records for invalid values");
        }
    }
        break;
    case DATE_TIME: {
        try {
            //            System.out.println(".... formatter: " + mapper.getDateTimeFormat());
            LocalDateTime ldt = LocalDateTime.parse(strValue, dateTimeFormatter);
            //            System.out.println("... ... year: " + ldt.getYear() + 
            //                    " - month:" + ldt.getMonthValue() + " - day: " +
            //                    ldt.getDayOfMonth() + " - hour: " + ldt.getHour() +
            //                    " - min: " + ldt.getMinute() + " - sec: " + 
            //                    ldt.getSecond() + " - nsec: " + ldt.getNano() );
            //retValue = new com.objy.db.DateTime(date.getTime(), TimeKind.LOCAL);
            retValue = new com.objy.db.DateTime(ldt.getYear(), ldt.getMonthValue(), ldt.getDayOfMonth(),
                    ldt.getHour(), ldt.getMinute(), ldt.getSecond(), ldt.getNano());
        } catch (DateTimeParseException ex) {
            LOG.error(ex.toString());
            throw new IllegalStateException("Possible invalid configuration... check mapper vs. schema"
                    + "... or check records for invalid values");
        }
    }
        break;
    case TIME: {
        try {
            //            System.out.println(".... formatter: " + mapper.getTimeFormat());
            LocalDateTime ltime = LocalDateTime.parse(strValue, dateFormatter);
            //            System.out.println("... ... hour: " + ltime.getHour() +
            //                    " - min: " + ltime.getMinute() + " - sec: " + 
            //                    ltime.getSecond() + " - nsec: " + ltime.getNano() );
            //retValue = new com.objy.db.DateTime(date.getTime(), TimeKind.LOCAL);
            retValue = new com.objy.db.Time(ltime.getHour(), ltime.getMinute(), ltime.getSecond(),
                    ltime.getNano());
        } catch (DateTimeParseException ex) {
            LOG.error(ex.toString());
            throw new IllegalStateException("Possible invalid configuration... check mapper vs. schema"
                    + "... or check records for invalid values");
        }
    }
    default: {
        throw new UnsupportedOperationException("LogicalType: " + logicalType + " is not supported!!!");
    }
    }
    return retValue;
}

From source file:RealFunctionValidation.java

public static Object readAndWritePrimitiveValue(final DataInputStream in, final DataOutputStream out,
        final Class<?> type) throws IOException {

    if (!type.isPrimitive()) {
        throw new IllegalArgumentException("type must be primitive");
    }//from   w  w w .  ja  va 2  s  . c o  m
    if (type.equals(Boolean.TYPE)) {
        final boolean x = in.readBoolean();
        out.writeBoolean(x);
        return Boolean.valueOf(x);
    } else if (type.equals(Byte.TYPE)) {
        final byte x = in.readByte();
        out.writeByte(x);
        return Byte.valueOf(x);
    } else if (type.equals(Character.TYPE)) {
        final char x = in.readChar();
        out.writeChar(x);
        return Character.valueOf(x);
    } else if (type.equals(Double.TYPE)) {
        final double x = in.readDouble();
        out.writeDouble(x);
        return Double.valueOf(x);
    } else if (type.equals(Float.TYPE)) {
        final float x = in.readFloat();
        out.writeFloat(x);
        return Float.valueOf(x);
    } else if (type.equals(Integer.TYPE)) {
        final int x = in.readInt();
        out.writeInt(x);
        return Integer.valueOf(x);
    } else if (type.equals(Long.TYPE)) {
        final long x = in.readLong();
        out.writeLong(x);
        return Long.valueOf(x);
    } else if (type.equals(Short.TYPE)) {
        final short x = in.readShort();
        out.writeShort(x);
        return Short.valueOf(x);
    } else {
        // This should never occur.
        throw new IllegalStateException();
    }
}

From source file:com.cburch.logisim.util.LocaleManager.java

private static String replaceAccents(String src, HashMap<Character, String> repl) {
    // find first non-standard character - so we can avoid the
    // replacement process if possible
    int i = 0;/*from w ww  .j  a  v a 2 s . c o m*/
    int n = src.length();
    for (; i < n; i++) {
        char ci = src.charAt(i);
        if (ci < 32 || ci >= 127)
            break;
    }
    if (i == n)
        return src;

    // ok, we'll have to consider replacing accents
    char[] cs = src.toCharArray();
    StringBuilder ret = new StringBuilder(src.substring(0, i));
    for (int j = i; j < cs.length; j++) {
        char cj = cs[j];
        if (cj < 32 || cj >= 127) {
            String out = repl.get(Character.valueOf(cj));
            if (out != null) {
                ret.append(out);
            } else {
                ret.append(cj);
            }
        } else {
            ret.append(cj);
        }
    }
    return ret.toString();
}

From source file:com.itemanalysis.psychometrics.statistics.TwoWayTable.java

public long getRowCumFreq(char rowValue) {
    return getRowCumFreq(Character.valueOf(rowValue));
}

From source file:com.github.gerbsen.math.Frequency.java

/**
 * Returns the number of values = v./* ww  w  .j a v  a  2 s  .  co  m*/
 *
 * @param v the value to lookup.
 * @return the frequency of v.
 */
public long getCount(char v) {
    return getCount(Character.valueOf(v));
}

From source file:asmlib.Type.java

public static UtilList<Type> getArgumentTypes(String methodDescriptor) {
    String input = methodDescriptor;
    UtilList<Type> outList = new UtilArrayList<Type>();
    char c;/*from   ww w.  ja  v a  2  s  .c  om*/
    int array = 0;
    Type t;

    // Exemplo descrio com "constraints" de generics
    // <T:Ljava/lang/Object;>([TT;)[TT;
    if ((input.charAt(0) != '(') && (input.charAt(0) == '<')) {
        input = input.substring(input.indexOf('('));
    }

    while (input.length() > 0) {
        c = input.charAt(0);
        input = input.substring(1);
        if (c == '[') {
            array++;
        } else if ((c == 'L') || (c == 'T')) {
            int pos = input.indexOf(';') + 1;
            String s = input.substring(0, pos);
            // Handling generics
            int genCount = StringUtils.countMatches(s, "<");
            if (genCount > 0) {
                while (genCount > 0) {
                    pos = input.indexOf('>', pos);
                    genCount--;
                }
                pos = input.indexOf(';', pos) + 1;
                s = input.substring(0, pos);
            }
            input = input.substring(pos);

            t = Type.fromBytecode(c + s);
            if (array > 0) {
                t = t.toArray(array);
                array = 0;
            }

            outList.add(t);
        } else if (c == '(') {
            // do nothing
        } else if (c == 'V') {
            throw new AssertionError("Invalid type in methodDescriptor");
        } else if (c == ')') {
            return outList;
        } else {
            t = Type.fromBytecode(Character.valueOf(c).toString());
            if (!t.isPrimitive())
                throw new AssertionError("Invalid type in methodDescriptor");

            if (array > 0) {
                t = t.toArray(array);
                array = 0;
            }

            outList.add(t);
        }
    }

    throw new Error("Malformed methodDescriptor");
}

From source file:com.neovisionaries.security.DigestTest.java

@Test
public void test12() {
    List<Character> list = new ArrayList<Character>();
    list.add(Character.valueOf('a'));
    list.add(Character.valueOf('b'));
    list.add(Character.valueOf('c'));

    String digest1 = md5().update(list).digestAsString();

    String digest2 = md5().update('a').update('b').update('c').digestAsString();

    String digest3 = md5().update(new char[] { 'a', 'b', 'c' }).digestAsString();

    String digest4 = md5().update('a', 'b', 'c').digestAsString();

    assertEquals(digest1, digest2);//  www .  j  a va2  s  .  co m
    assertEquals(digest1, digest3);
    assertEquals(digest1, digest4);
}