Example usage for java.lang Character Character

List of usage examples for java.lang Character Character

Introduction

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

Prototype

@Deprecated(since = "9")
public Character(char value) 

Source Link

Document

Constructs a newly allocated Character object that represents the specified char value.

Usage

From source file:org.jbpm.formModeler.core.processing.fieldHandlers.CharacterFieldHandler.java

/**
 * Read a parameter value (normally from a request), and translate it to
 * an object with desired class (that must be one of the returned by this handler)
 *
 * @return a object with desired class//w  ww.j  a  v  a  2  s.  c o  m
 * @throws Exception
 */
@Override
public Object getValue(Field field, String inputName, Map parametersMap, Map filesMap, String desiredClassName,
        Object previousValue) throws Exception {
    String[] paramValue = (String[]) parametersMap.get(inputName);
    if (paramValue == null || paramValue.length == 0 || StringUtils.isEmpty(paramValue[0]))
        return null;

    return new Character(paramValue[0].charAt(0));
}

From source file:agilejson.JSON.java

/**
 * This method takes in a primitive that has been converted to an object
 * and creates a copy of it so that .equals results in different objects.
 * @param v//from  ww  w. ja  v a 2  s. c o m
 * @throws java.lang.Exception
 */
private static Object getObjectForPrimitive(Object v) throws Exception {
    Class c = v.getClass();
    if (c == Byte.class) {
        return new String(new byte[] { ((Byte) v).byteValue() });
    } else if (c == Boolean.class) {
        return new Boolean((Boolean) v);
    } else if (c == Character.class) {
        return new Character((Character) v);
    } else if (c == Short.class) {
        return new Short((Short) v);
    } else if (c == Integer.class) {
        return new Integer((Integer) v);
    } else if (c == Long.class) {
        return new Long((Long) v);
    } else if (c == Float.class) {
        return new Float((Float) v);
    } else if (c == Double.class) {
        return new Double((Double) v);
    } else {
        throw new Exception("Unknown Primitive");
    }
}

From source file:org.werelate.util.PlaceUtils.java

/**
 * Convert non-roman letters in the specified string to their roman (a-zA-Z) equivalents.
 * For example, strip accents from characters, and expand ligatures.  This function attempts to mimic
 * the character conversion that Google does.
 * @param in//from  w  w w.java2s .co  m
 * @return boolean
 */
public static String romanize(String in) {
    if (in == null) {
        return "";
    }
    if (isAscii(in)) {
        return in;
    }

    char[] srcChar = new char[1];
    char[] destChars = new char[8];
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < in.length(); i++) {
        // decompose the character
        srcChar[0] = in.charAt(i);
        Normalizer.decompose(srcChar, destChars, false, 0);
        char c = destChars[0];

        if ((int) c >= 0x0300 && (int) c <= 0x036f) {
            // ignore combining diacritics
        } else if ((int) c >= 127) {
            String transliteration = (String) SPECIAL_MAPPINGS.get(new Character(c));
            if (transliteration != null) {
                buf.append(transliteration);
            } else {
                buf.append(c);
            }
        } else {
            buf.append(c);
        }
    }
    return buf.toString();
}

From source file:org.radeox.filter.ListFilter.java

public ListFilter() {
    super();/*from ww  w.j  a va2s.c  o m*/
    openList.put(new Character('-'), "<ul class=\"minus\">");
    openList.put(new Character('*'), "<ul class=\"star\">");
    openList.put(new Character('#'), "<ol>");
    openList.put(new Character('i'), "<ol class=\"roman\">");
    openList.put(new Character('I'), "<ol class=\"ROMAN\">");
    openList.put(new Character('a'), "<ol class=\"alpha\">");
    openList.put(new Character('A'), "<ol class=\"ALPHA\">");
    openList.put(new Character('g'), "<ol class=\"greek\">");
    openList.put(new Character('h'), "<ol class=\"hiragana\">");
    openList.put(new Character('H'), "<ol class=\"HIRAGANA\">");
    openList.put(new Character('k'), "<ol class=\"katakana\">");
    openList.put(new Character('K'), "<ol class=\"KATAKANA\">");
    openList.put(new Character('j'), "<ol class=\"HEBREW\">");
    openList.put(new Character('1'), "<ol>");
    closeList.put(new Character('-'), UL_CLOSE);
    closeList.put(new Character('*'), UL_CLOSE);
    closeList.put(new Character('#'), OL_CLOSE);
    closeList.put(new Character('i'), OL_CLOSE);
    closeList.put(new Character('I'), OL_CLOSE);
    closeList.put(new Character('a'), OL_CLOSE);
    closeList.put(new Character('A'), OL_CLOSE);
    closeList.put(new Character('1'), OL_CLOSE);
    closeList.put(new Character('g'), OL_CLOSE);
    closeList.put(new Character('G'), OL_CLOSE);
    closeList.put(new Character('h'), OL_CLOSE);
    closeList.put(new Character('H'), OL_CLOSE);
    closeList.put(new Character('k'), OL_CLOSE);
    closeList.put(new Character('K'), OL_CLOSE);
    closeList.put(new Character('j'), OL_CLOSE);
}

From source file:com.redhat.rhn.common.util.CharacterMap.java

/**
 * Retrieve value/*from  w w w . j a  va 2s.co  m*/
 * @param key Character you want the starting position of
 * @return Integer for corresponding key
 */
public Integer get(char key) {
    return (Integer) innerMap.get(new Character(key));
}

From source file:Getopts.java

/**
 * This constructor takes a list of legal options and a list of (usually
 * command line) arguments. Each option in optionListString may be followed
 * by a ':' to signify that option takes an argument.
 *
 * @param optionListString option chars with optional ':' specifying arg.
 * For example, "ab:c" specifies three options, a, b, and c. Option b takes
 * a (required) argument./*  w  ww  .  jav a  2  s. co  m*/
 * @param args array of command line arguments
 */
public Getopts(String optionListString, String[] args) {
    String optChoices = optionListString;

    for (int index = 0; index < args.length; ++index) {
        String arg = args[index];
        if (arg.startsWith("-")) {
            char optionChar = arg.charAt(1);
            int optionLoc = optChoices.indexOf(optionChar);
            if (optionLoc == -1)
                errorFlag = true;
            else {
                // Look for argument, if any
                boolean hasArgument = optChoices.length() > optionLoc + 1
                        && optChoices.charAt(optionLoc + 1) == ':';
                if (hasArgument) {
                    String optarg = arg.substring(2);
                    if (optarg.equals("")) {
                        ++index;
                        try {
                            optarg = args[index];
                        } catch (Exception e) { // Catch ArrayOutOfBounds
                            optarg = "";
                            errorFlag = true;
                        }
                    }
                    options.put(new Character(optionChar), optarg);
                } else {
                    // No arg, store empty string
                    options.put(new Character(optionChar), "");
                }
            }
        } else { // End of options. Store rest of args
            argv = new String[args.length - index];
            int offset = index;
            while (index < args.length) {
                argv[index - offset] = args[index];
                ++index;
            }
            break;
        }
    }
}

From source file:com.base.dao.sql.ReflectionUtils.java

public static Object convertValue(Object value, Class toType) {
    Object result = null;/*w w w  .j  a v a  2  s.  co m*/
    if (value != null) {
        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) longValue(value));
            if ((toType == Double.class) || (toType == Double.TYPE))
                result = new Double(doubleValue(value));
            if ((toType == Boolean.class) || (toType == Boolean.TYPE))
                result = booleanValue(value) ? Boolean.TRUE : Boolean.FALSE;
            if ((toType == Byte.class) || (toType == Byte.TYPE))
                result = Byte.valueOf((byte) longValue(value));
            if ((toType == Character.class) || (toType == Character.TYPE))
                result = new Character((char) longValue(value));
            if ((toType == Short.class) || (toType == Short.TYPE))
                result = Short.valueOf((short) longValue(value));
            if ((toType == Long.class) || (toType == Long.TYPE))
                result = Long.valueOf(longValue(value));
            if ((toType == Float.class) || (toType == Float.TYPE))
                result = new Float(doubleValue(value));
            if (toType == BigInteger.class)
                result = bigIntValue(value);
            if (toType == BigDecimal.class)
                result = bigDecValue(value);
            if (toType == String.class)
                result = stringValue(value);
            if (toType == Date.class) {
                result = DateUtils.toDate(stringValue(value));
            }
            if (Enum.class.isAssignableFrom(toType))
                result = enumValue((Class<Enum>) toType, value);
        }
    } else {
        if (toType.isPrimitive()) {
            result = primitiveDefaults.get(toType);
        }
    }
    return result;
}

From source file:com.lrodriguez.SVNEntryFacade.java

public SVNEntryFacade(File file, SVNLogEntryPath entryPath, SVNLogEntry logEntry, boolean selected) {
    this.logEntry = logEntry;
    this.file = file;
    this.author = logEntry.getAuthor();
    this.timestamp = logEntry.getDate();
    this.message = logEntry.getMessage();
    this.revision = logEntry.getRevision();

    this.copyPath = entryPath.getCopyPath();
    this.copyRevision = entryPath.getCopyRevision();
    this.path = entryPath.getPath();
    this.type = new Character(entryPath.getType()).toString();
    this.nodeKind = entryPath.getKind().toString();

}

From source file:com.blackducksoftware.tools.commonframework.core.encoding.Ascii85EncoderTest.java

public static String generateRandomPassword(final int maxLen) {
    final List<Character> badChars = Arrays.asList(Password.PROHIBITED_CHARS);

    int len = 0;//from w w w.j  a va 2s . c  om
    while (len < Password.MIN_LENGTH) {
        len = rand.nextInt() % maxLen;
    }
    final byte[] outputBuffer = new byte[len];

    final int numPossibleCharValues = Password.MAX_CHAR_VALUE - Password.MIN_CHAR_VALUE + 1;
    for (int i = 0; i < len; i++) {

        int charValue = -1;
        do {
            int charValueOffset = -1;
            while (charValueOffset < 0) {
                charValueOffset = rand.nextInt();
            }
            charValue = Password.MIN_CHAR_VALUE + charValueOffset % numPossibleCharValues;
        } while (badChars.contains(new Character((char) charValue)));

        outputBuffer[i] = (byte) charValue;
    }
    final String randomString = new String(outputBuffer, UTF8);
    return randomString;
}

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) };
}