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 long getCount(char rowValue, char colValue) {
    return getCount(Character.valueOf(rowValue), Character.valueOf(colValue));
}

From source file:org.apache.directory.fortress.web.panel.ObjectListPanel.java

public ObjectListPanel(String id, final boolean isAdmin) {
    super(id);//from   ww w  .ja  v a 2 s .  c o m
    ObjectListModel objectListModel = new ObjectListModel(new PermObj(""), isAdmin, SecUtils.getSession(this));
    setDefaultModel(objectListModel);
    addGrid();
    radioGroup = new RadioGroup("searchOptions", new PropertyModel(this, "selectedRadioButton"));
    add(radioGroup);
    Radio objectRb = new Radio("objectRb", new Model(Character.valueOf(NAMES)));
    radioGroup.add(objectRb);
    Radio ouRb = new Radio("ouRb", new Model(Character.valueOf(OUS)));
    radioGroup.add(ouRb);
    addOUSearchModal(ouRb);
    radioGroup.setOutputMarkupId(true);
    radioGroup.setRenderBodyOnly(false);
    searchValFld = new TextField(GlobalIds.SEARCH_VAL, new PropertyModel<String>(this, GlobalIds.SEARCH_VAL));
    searchValFld.setOutputMarkupId(true);
    AjaxFormComponentUpdatingBehavior ajaxUpdater = new AjaxFormComponentUpdatingBehavior(GlobalIds.ONBLUR) {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            target.add(searchValFld);
        }
    };
    searchValFld.add(ajaxUpdater);
    radioGroup.add(searchValFld);

    this.listForm.add(radioGroup);
    selectedRadioButton = NAMES;

    this.listForm.add(new SecureIndicatingAjaxButton(GlobalIds.SEARCH, GlobalIds.REVIEW_MGR, "findPermObjs") {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form form) {
            log.debug(".search.onSubmit selected radio button: " + selectedRadioButton);
            info("Searching Permission Objects...");
            if (!StringUtils.isNotEmpty(searchVal)) {
                searchVal = "";
            }
            PermObj srchObject = new PermObj();
            switch (selectedRadioButton) {
            case NAMES:
                log.debug(".onSubmit OBJECT RB selected");
                srchObject.setObjName(searchVal);
                break;
            case OUS:
                log.debug(".onSubmit OUS RB selected");
                srchObject.setOu(searchVal);
                break;
            }
            setDefaultModel(new ObjectListModel(srchObject, isAdmin, SecUtils.getSession(this)));
            treeModel.reload();
            rootNode.removeAllChildren();
            List<PermObj> permObjs = (List<PermObj>) getDefaultModelObject();
            if (CollectionUtils.isNotEmpty(permObjs)) {
                for (PermObj permObj : permObjs)
                    rootNode.add(new DefaultMutableTreeNode(permObj));
                info("Search returned " + permObjs.size() + " matching objects");
            } else {
                info("No matching objects found");
            }
            target.add(grid);
        }

        @Override
        public void onError(AjaxRequestTarget target, Form form) {
            log.warn(".search.onError");
            target.add();
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            AjaxCallListener ajaxCallListener = new AjaxCallListener() {
                /** Default serialVersionUID */
                private static final long serialVersionUID = 1L;

                @Override
                public CharSequence getFailureHandler(Component component) {
                    return GlobalIds.WINDOW_LOCATION_REPLACE_COMMANDER_HOME_HTML;
                }
            };
            attributes.getAjaxCallListeners().add(ajaxCallListener);
        }
    });
}

From source file:com.tc.cli.CommandLineBuilder.java

public static String readPassword() {
    try {//from  w  w  w  . j av a2  s  . c  om
        System.out.print("Enter password: ");
        return new jline.ConsoleReader().readLine(Character.valueOf('*'));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:org.apache.click.util.RequestTypeConverter.java

/**
 * Return the converted value for the given value object and target type.
 *
 * @param value the value object to convert
 * @param toType the target class type to convert the value to
 * @return a converted value into the specified type
 *///from  w  w w . j a v a2  s  . c  om
protected Object convertValue(Object value, Class<?> toType) {
    Object result = null;

    if (value != null) {

        // If array -> array then convert components of array individually
        if (value.getClass().isArray() && toType.isArray()) {
            Class<?> componentType = toType.getComponentType();

            result = Array.newInstance(componentType, Array.getLength(value));

            for (int i = 0, icount = Array.getLength(value); i < icount; i++) {
                Array.set(result, i, convertValue(Array.get(value, i), componentType));
            }

        } else {
            if ((toType == Integer.class) || (toType == Integer.TYPE)) {
                result = Integer.valueOf((int) OgnlOps.longValue(value));

            } else if ((toType == Double.class) || (toType == Double.TYPE)) {
                result = new Double(OgnlOps.doubleValue(value));

            } else if ((toType == Boolean.class) || (toType == Boolean.TYPE)) {
                result = Boolean.valueOf(value.toString());

            } else if ((toType == Byte.class) || (toType == Byte.TYPE)) {
                result = Byte.valueOf((byte) OgnlOps.longValue(value));

            } else if ((toType == Character.class) || (toType == Character.TYPE)) {
                result = Character.valueOf((char) OgnlOps.longValue(value));

            } else if ((toType == Short.class) || (toType == Short.TYPE)) {
                result = Short.valueOf((short) OgnlOps.longValue(value));

            } else if ((toType == Long.class) || (toType == Long.TYPE)) {
                result = Long.valueOf(OgnlOps.longValue(value));

            } else if ((toType == Float.class) || (toType == Float.TYPE)) {
                result = new Float(OgnlOps.doubleValue(value));

            } else if (toType == BigInteger.class) {
                result = OgnlOps.bigIntValue(value);

            } else if (toType == BigDecimal.class) {
                result = bigDecValue(value);

            } else if (toType == String.class) {
                result = OgnlOps.stringValue(value);

            } else if (toType == java.util.Date.class) {
                long time = getTimeFromDateString(value.toString());
                if (time > Long.MIN_VALUE) {
                    result = new java.util.Date(time);
                }

            } else if (toType == java.sql.Date.class) {
                long time = getTimeFromDateString(value.toString());
                if (time > Long.MIN_VALUE) {
                    result = new java.sql.Date(time);
                }

            } else if (toType == java.sql.Time.class) {
                long time = getTimeFromDateString(value.toString());
                if (time > Long.MIN_VALUE) {
                    result = new java.sql.Time(time);
                }

            } else if (toType == java.sql.Timestamp.class) {
                long time = getTimeFromDateString(value.toString());
                if (time > Long.MIN_VALUE) {
                    result = new java.sql.Timestamp(time);
                }
            }
        }

    } else {
        if (toType.isPrimitive()) {
            result = OgnlRuntime.getPrimitiveDefaultValue(toType);
        }
    }
    return result;
}

From source file:therian.operator.immutablecheck.DefaultImmutableCheckerTest.java

@Test
public void testWrapper() {
    assertTrue(therianContext.eval(ImmutableCheck.of(Positions.readOnly(Integer.valueOf(666)))).booleanValue());
    assertTrue(therianContext.eval(ImmutableCheck.of(Positions.readOnly(Long.valueOf(666L)))).booleanValue());
    assertTrue(//from  ww  w  . j  a va  2s  . com
            therianContext.eval(ImmutableCheck.of(Positions.readOnly(Byte.valueOf((byte) 0)))).booleanValue());
    assertTrue(therianContext.eval(ImmutableCheck.of(Positions.readOnly(Short.valueOf((short) 0))))
            .booleanValue());
    assertTrue(therianContext.eval(ImmutableCheck.of(Positions.readOnly(Character.valueOf((char) 0))))
            .booleanValue());
    assertTrue(therianContext.eval(ImmutableCheck.of(Positions.readOnly(Boolean.TRUE))).booleanValue());
    assertTrue(therianContext.eval(ImmutableCheck.of(Positions.readOnly(Float.valueOf(0.0f)))).booleanValue());
    assertTrue(therianContext.eval(ImmutableCheck.of(Positions.readOnly(Double.valueOf(0.0)))).booleanValue());
}

From source file:org.apache.camel.dataformat.csv.CsvDataFormatTest.java

@Test
public void shouldOverrideDelimiter() {
    CsvDataFormat dataFormat = new CsvDataFormat().setDelimiter('d');

    // Properly saved
    assertSame(CSVFormat.DEFAULT, dataFormat.getFormat());
    assertEquals(Character.valueOf('d'), dataFormat.getDelimiter());

    // Properly used
    assertEquals('d', dataFormat.getActiveFormat().getDelimiter());
}

From source file:org.apache.openmeetings.screenshare.job.OmKeyEvent.java

public OmKeyEvent(Map<String, Object> obj) {
     alt = TRUE.equals(obj.get("alt"));
     ctrl = TRUE.equals(obj.get("ctrl"));
     shift = TRUE.equals(obj.get("shift")) || isUpperCase(ch);
     ch = (char) getInt(obj, "char");
     key = inKey = getInt(obj, "key");
     Integer _key = null;// www  . j  ava2s  .  c o m
     if (CharUtils.isAsciiPrintable(ch)) {
         boolean alpha = Character.isAlphabetic(ch);
         if (alpha) { // can't be combined due to different types
             key = getKeyStroke(toUpperCase(ch), 0).getKeyCode();
         } else {
             key = getKeyStroke(Character.valueOf(ch), 0).getKeyCode();
         }
         if (key == 0) {
             _key = CHAR_MAP.get(ch);
             if (_key == null) {
                 // fallback
                 key = inKey;
             }
         }
         if (!alpha && _key == null) {
             _key = KEY_MAP.get(key);
         }
     } else {
         _key = KEY_MAP.get(key);
     }
     this.key = _key == null ? key : _key;
     log.debug("sequence:: shift {}, ch {}, orig {} -> key {}({}), map {}", shift, ch == 0 ? ' ' : ch, inKey,
             key, Integer.toHexString(key), _key);
 }

From source file:org.apache.wiki.util.comparators.HumanComparator.java

public int compare(String str1, String str2) {
    // Some quick and easy checks
    if (StringUtils.equals(str1, str2)) {
        // they're identical, possibly both null
        return 0;
    } else if (str1 == null) {
        // str1 is null and str2 isn't so str1 is smaller
        return -1;
    } else if (str2 == null) {
        // str2 is null and str1 isn't so str1 is bigger
        return 1;
    }//from www.ja v a2  s. c  om

    char[] s1 = str1.toCharArray();
    char[] s2 = str2.toCharArray();
    int len1 = s1.length;
    int len2 = s2.length;
    int idx = 0;
    // caseComparison used to defer a case sensitive comparison
    int caseComparison = 0;

    while (idx < len1 && idx < len2) {
        char c1 = s1[idx];
        char c2 = s2[idx++];

        // Convert to lower case
        char lc1 = Character.toLowerCase(c1);
        char lc2 = Character.toLowerCase(c2);

        // If case makes a difference, note the difference the first time
        // it's encountered
        if (caseComparison == 0 && c1 != c2 && lc1 == lc2) {
            if (Character.isLowerCase(c1))
                caseComparison = 1;
            else if (Character.isLowerCase(c2))
                caseComparison = -1;
        }
        // Do the rest of the tests in lower case
        c1 = lc1;
        c2 = lc2;

        // leading zeros are a special case
        if (c1 != c2 || c1 == '0') {
            // They might be different, now we can do a comparison
            CharType type1 = mapCharTypes(c1);
            CharType type2 = mapCharTypes(c2);

            // Do the character class check
            int result = compareCharTypes(type1, type2);
            if (result != 0) {
                // different character classes so that's sufficient
                return result;
            }

            // If they're not digits, use character to character comparison
            if (type1 != CharType.TYPE_DIGIT) {
                Character ch1 = Character.valueOf(c1);
                Character ch2 = Character.valueOf(c2);
                return ch1.compareTo(ch2);
            }

            // The only way to get here is both characters are digits
            assert (type1 == CharType.TYPE_DIGIT && type2 == CharType.TYPE_DIGIT);
            result = compareDigits(s1, s2, idx - 1);
            if (result != 0) {
                // Got a result so return it
                return result;
            }

            // No result yet, spin through the digits and continue trying
            while (idx < len1 && idx < len2 && Character.isDigit(s1[idx])) {
                idx++;
            }
        }
    }

    if (len1 == len2) {
        // identical so return any case dependency
        return caseComparison;
    }

    // Shorter String is less
    return len1 - len2;
}

From source file:com.igormaznitsa.zxpspritecorrector.files.FileNameDialog.java

private Character getCharacter(final JFormattedTextField field) {
    final String text = field.getText().trim();
    return text.isEmpty() ? null : Character.valueOf(text.charAt(0));
}

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

public double getPct(char rowValue, char colValue) {
    return getPct(Character.valueOf(rowValue), Character.valueOf(colValue));
}