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:hudson.plugins.freezewindow.FreezeWindowMonitor.java

/**
 * quartz's version of cron is slightly different from the standard cron format.
 * For example: day of week starts with 0 in standard cron format but in quartz it starts with 1.
 * Therefore normalize will convert standard cron to quartz cron, assuming that the input is valid
 * @param fw a cron expression/*from   ww  w .j  a va2 s  . c  o  m*/
 * @return string of the corn expression after normailization
 */
public static String normalize(String fw) {
    StringBuilder sb = new StringBuilder();
    String[] cronParts = fw.split(" ");
    List<Character> validDaysOfWeek = new ArrayList<Character>();
    validDaysOfWeek.add(new Character('0'));
    validDaysOfWeek.add(new Character('1'));
    validDaysOfWeek.add(new Character('2'));
    validDaysOfWeek.add(new Character('3'));
    validDaysOfWeek.add(new Character('4'));
    validDaysOfWeek.add(new Character('5'));
    validDaysOfWeek.add(new Character('6'));

    sb.append("* ");
    sb.append(cronParts[0] + " ");
    sb.append(cronParts[1] + " ");
    sb.append(cronParts[2] + " ");
    sb.append(cronParts[3] + " ");

    // Only increment digits by 1
    // example: standard cron expression: 5-6,MON
    //          quartz cron expression: 6-7,MON
    char[] chars = cronParts[4].toCharArray();
    int i;
    for (i = 0; i < chars.length; i++) {
        if (validDaysOfWeek.contains(chars[i])) {
            sb.append((chars[i] - '0') + 1);
        } else {
            sb.append(chars[i]);
        }
    }

    if (cronParts.length == 6) {
        sb.append(" " + cronParts[5]);
    }

    //System.out.println("Input freeze window cron format: " + fw);
    //System.out.println("After normalize: " + sb);
    return sb.toString();
}

From source file:CharUtils.java

/**
 * <p>Converts the character to a Character.</p>
 * //from   w w w . j a  v  a2 s  .  c  o m
 * <p>For ASCII 7 bit characters, this uses a cache that will return the
 * same Character object each time.</p>
 *
 * <pre>
 *   CharUtils.toCharacterObject(' ')  = ' '
 *   CharUtils.toCharacterObject('A')  = 'A'
 * </pre>
 *
 * @param ch  the character to convert
 * @return a Character of the specified character
 */
public static Character toCharacterObject(char ch) {
    if (ch < CHAR_ARRAY.length) {
        return CHAR_ARRAY[ch];
    }
    return new Character(ch);
}

From source file:org.jahia.services.pwdpolicy.PolicyEvaluator.java

private static ConditionEvaluator getEvaluator(char type) {
    ConditionEvaluator evaluator = (ConditionEvaluator) EVALUATORS.get(new Character(type));

    if (evaluator == null) {
        throw new UnsupportedOperationException("Not supported evaluator type '" + type + "'");
    }// w  w  w.  j  a  va 2 s .c om

    return evaluator;
}

From source file:org.ow2.proactive.resourcemanager.utils.VIRMNodeStarter.java

/**
 * Fills the command line options./* w  w  w  . j a va2 s .  c  o m*/
 * @param options the options to fill
 */
protected void fillOptions(final Options options) {
    // The name of the holding virtual machine
    final Option vmName = new Option(new Character(OPTION_TEMPLATE_NAME).toString(), "holdingVMName", true,
            "The name of the virtual machine within which one this RMNode is to be started.");
    vmName.setRequired(true);
    vmName.setArgName("name");
    options.addOption(vmName);
    super.fillOptions(options);
}

From source file:com.judoscript.jamaica.MyUtils.java

public static Object number2object(long val, String typeHint) {
    if (typeHint != null) {
        if (typeHint.equals("int"))
            return new Integer((int) val);
        if (typeHint.equals("long"))
            return new Long(val);
        if (typeHint.equals("short"))
            return new Short((short) val);
        if (typeHint.equals("char"))
            return new Character((char) val);
        if (typeHint.equals("byte"))
            return new Byte((byte) val);
        if (typeHint.equals("double"))
            return new Double(val);
        if (typeHint.equals("float"))
            return new Float(val);
    }//from   www.  j  a  va  2 s  .c  o  m
    return new Long(val);
}

From source file:javadz.beanutils.converters.CharacterConverter.java

/**
 * <p>Convert the input object into a java.lang.Character.</p>
 *
 * @param type Data type to which this value should be converted.
 * @param value The input value to be converted.
 * @return The converted value./*  w  w w  .j  av a  2  s  .  co m*/
 * @throws Exception if conversion cannot be performed successfully
 * @since 1.8.0
 */
protected Object convertToType(Class type, Object value) throws Exception {
    return new Character(value.toString().charAt(0));
}

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

private static HashMap<Character, String> fetchReplaceAccents() {
    HashMap<Character, String> ret = null;
    String val;
    try {/*from  w w w . j  av a  2 s . c  o  m*/
        val = LocaleString.getUtilLocaleManager().locale.getString("accentReplacements");
    } catch (MissingResourceException e) {
        return null;
    }
    StringTokenizer toks = new StringTokenizer(val, "/");
    while (toks.hasMoreTokens()) {
        String tok = toks.nextToken().trim();
        char c = '\0';
        String s = null;
        if (tok.length() == 1) {
            c = tok.charAt(0);
            s = "";
        } else if (tok.length() >= 2 && tok.charAt(1) == ' ') {
            c = tok.charAt(0);
            s = tok.substring(2).trim();
        }
        if (s != null) {
            if (ret == null)
                ret = new HashMap<Character, String>();
            ret.put(new Character(c), s);
        }
    }
    return ret;
}

From source file:uk.ac.sanger.cgp.wwdocker.workflow.SangerWorkflow.java

@Override
public List filesToPush(File iniFile) {
    List files = new ArrayList();
    files.add(iniFile);//from  w  w  w. jav  a2 s.  c om
    logger.trace(iniFile);
    BaseConfiguration wkflConf = Config.loadConfig(iniFile.getAbsolutePath(), new Character(':'), false);
    if (wkflConf.getBoolean("testMode")) {
        logger.info(iniFile.getAbsolutePath() + " is set as testMode=true, no BAMs to transfer");
    } else {
        // Add construct the paths to the local files
        List analysisIds = wkflConf.getList("tumourAnalysisIds");
        analysisIds.add(wkflConf.getList("controlAnalysisId"));
        List bamFiles = wkflConf.getList("tumourBams");
        bamFiles.add(wkflConf.getList("controlBam"));
        if (analysisIds.size() != bamFiles.size()) {
            throw new RuntimeException(
                    "Number of *AnalysisId[s] is not equal to the number of *Bam[s] in workfile: "
                            + iniFile.getAbsolutePath());
        }
        for (int i = 0; i < analysisIds.size(); i++) {
            String analysisId = (String) analysisIds.get(i);
            String bamFile = (String) bamFiles.get(i);
            File bamPath = new File(
                    config.getString("data_root").concat("/").concat(analysisId).concat("/").concat(bamFile));
            if (!bamPath.exists()) {
                throw new RuntimeException("Unable to find BAM file (" + bamPath.getAbsolutePath()
                        + ") expected from worfile: " + iniFile.getAbsolutePath());
            }
            files.add(bamPath);
        }
    }
    return files;
}

From source file:org.floggy.synchronization.jme.core.impl.JSONSerializationManager.java

/**
* DOCUMENT ME!//  ww w  .  j ava2s. c  om
*
* @param name DOCUMENT ME!
* @param jsonObject DOCUMENT ME!
*
* @return DOCUMENT ME!
*
* @throws JSONException DOCUMENT ME!
*/
public static Character receiveChar(String name, JSONObject jsonObject) throws JSONException {
    String value = jsonObject.optString(name);

    if (value.length() != 0) {
        return new Character(value.charAt(0));
    }

    return null;
}

From source file:org.wings.template.DefaultPropertyValueConverter.java

/**
 * Describe <code>convertPropertyValue</code> method here.
 *
 * @param value       an <code>Object</code> value
 * @param targetClass a <code>Class</code> value
 * @return <description>/*from  w  ww . j  ava2s. co  m*/
 * @throws UnsupportedOperationException if an error occurs
 * @throws java.lang.UnsupportedOperationException
 *                                       <description>
 */
public Object convertPropertyValue(String value, Class targetClass) throws UnsupportedOperationException {
    if (value == null || "null".equals(value)) {
        return null;
    } // end of if ()

    if (targetClass == String.class) {
        return value;
    } // end of if ()

    if (targetClass == Boolean.TYPE || targetClass == Boolean.class) {
        return Boolean.valueOf(value);
    }

    if (targetClass == Integer.TYPE || targetClass == Integer.class) {
        return Integer.valueOf(value);
    }
    if (targetClass == Long.TYPE || targetClass == Long.class) {
        return Long.valueOf(value);
    }
    if (targetClass == Short.TYPE || targetClass == Short.class) {
        return Short.valueOf(value);
    }
    if (targetClass == Byte.TYPE || targetClass == Byte.class) {
        return Byte.valueOf(value);
    }
    if (targetClass == Float.TYPE || targetClass == Float.class) {
        return Float.valueOf(value);
    }
    if (targetClass == Double.TYPE || targetClass == Double.class) {
        return Double.valueOf(value);
    }
    if (targetClass == Character.TYPE || targetClass == Character.class) {
        return new Character(value.charAt(0));
    }

    if (targetClass == StringBuffer.class) {
        return new StringBuffer(value);
    } // end of if ()

    if (SIcon.class.isAssignableFrom(targetClass)) {
        return ResourceFactory.makeIcon(value);
    }

    if (targetClass == Color.class) {
        return ResourceFactory.makeColor(value);
    }

    if (targetClass == SDimension.class) {
        return ResourceFactory.makeDimension(value);
    }

    if (targetClass == SFont.class) {
        return TemplateUtil.parseFont(value);
    }

    if (Resource.class.isAssignableFrom(targetClass)) {
        return new ClassPathResource(value);
    }

    if (CSSAttributeSet.class.isAssignableFrom(targetClass)) {
        return ResourceFactory.makeAttributeSet(value);
    }

    if (StyleSheet.class.isAssignableFrom(targetClass)) {
        StyleSheet result;
        try {
            CSSStyleSheet styleSheet = new CSSStyleSheet();
            InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(value);
            styleSheet.read(in);
            in.close();
            result = styleSheet;
        } catch (Exception e) {
            log.warn("Exception", e);
            result = null;
        }
        return result;
    }

    if (ComponentCG.class.isAssignableFrom(targetClass)) {
        return ResourceFactory.makeComponentCG(value);
    }

    throw new UnsupportedOperationException("cannot create object of type " + targetClass.getName());
}