Example usage for java.lang Integer decode

List of usage examples for java.lang Integer decode

Introduction

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

Prototype

public static Integer decode(String nm) throws NumberFormatException 

Source Link

Document

Decodes a String into an Integer .

Usage

From source file:com.l2jfree.config.L2Properties.java

public int getInteger(String name, String deflt) {
    String val = getProperty(name, deflt);
    if (val == null)
        throw new IllegalArgumentException("Integer value required, but not specified");

    try {// www  .j  av  a2 s  .  c om
        return Integer.decode(val);
    } catch (Exception e) {
        throw new IllegalArgumentException("Integer value required, but found: " + val);
    }
}

From source file:org.apache.jackrabbit.core.persistence.mem.InMemBundlePersistenceManager.java

public void setMinBlobSize(String minBlobSize) {
    this.minBlobSize = Integer.decode(minBlobSize).intValue();
}

From source file:us.conxio.hl7.hl7message.HL7Designator.java

private void parse(String str) {
    argString = str;//from  w  w  w  .  ja v  a  2s.com
    if (hasColon())
        hasColon = true;
    if (hasBrackets())
        hasBracket = true;

    String[] elementDesignations = str.split("\\.");

    // The first designator componentIndex is the segment ID
    if (elementDesignations[0].length() < 3)
        return;

    segIndex = 0;
    componentIndex = UNSPECIFIED;
    sequence = UNSPECIFIED;
    subComponentIndex = UNSPECIFIED;

    if (elementDesignations[0].length() > 3) { // a segment index is specified
        segIndex = indexValueOf(elementDesignations[0]) - 1;
        if (segIndex < 0)
            segIndex = 0;
    } // if

    // Segment ID is the first three characters.
    segID = elementDesignations[0].substring(0, 3);
    level = new HL7ElementLevel(HL7ElementLevel.SEGMENT);

    if (elementDesignations.length > 1) { // a field sequence is specified.
        sequence = positionValueOf(elementDesignations[1]);
        if (hasIndexIndicator(elementDesignations[1]))
            repetitionIndex = indexValueOf(elementDesignations[1]);

        // Correct for MSH indexing idiosyncracy.
        if (segID.equals("MSH") && sequence >= 0)
            --sequence;
        level.set(level.next().get());
    } // if      

    if (elementDesignations.length > 2) { // A componentIndex is specified.
        int tempInt = Integer.parseInt(elementDesignations[2]);
        if (tempInt > 0)
            --tempInt; // correct for ordinal designations
        componentIndex = tempInt;
        level.set(level.next().get());
    } // if 

    if (elementDesignations.length > 3) {
        Integer tempInt = Integer.decode(elementDesignations[3]);
        if (tempInt > 0)
            --tempInt; // correct for ordinal designations
        subComponentIndex = tempInt;
        level.set(level.next().get());
    } // if
}

From source file:gov.nih.nci.cabig.caaers.dao.MedDRADao.java

/**
 * This method is to populate codeToIdMap and keep it ready before loading PT.
 * //  w w w. j  a v a2  s.c o m
 * @param version_id
 * @return
 */
public Map<String, Integer> populateCodeToIdMap(final String table_name, final int version_id) {
    Map<String, Integer> resultMap = new HashMap<String, Integer>();
    String sql = "select meddra_code, id from " + table_name + " where version_id = " + version_id;

    List<Map<String, Object>> preResult = jdbcTemplate.queryForList(sql);

    for (Map map : preResult) {
        String meddra_code = map.get("meddra_code").toString();
        String id = map.get("id").toString();
        if (!resultMap.containsKey(meddra_code)) {
            resultMap.put(meddra_code, Integer.decode(id));
        }
    }
    return resultMap;
}

From source file:com.github.jessemull.microflex.plate.Well.java

/**
 * Creates a new Well object from a string holding the column and row values.
 * The string must be in the format [a-ZA-Z]+[0-9]+
 * @param    int       the numerical data type
 * @param    String    the well index/*from   w ww  . j  a  va 2 s  .  c o m*/
 */
public Well(int type, String wellID) {

    this.type = type;
    String upper = wellID.toUpperCase().trim();

    Matcher digitsMatcher = digitsPattern.matcher(upper);
    Matcher lettersMatcher = lettersPattern.matcher(upper);
    Matcher alphasOnlyMatcher = alphaOnlyPattern.matcher(upper);

    /* Alphas matcher enforces the correct format for the well ID */

    if (alphasOnlyMatcher.find()) {

        lettersMatcher.find();
        digitsMatcher.find();

        this.row = parseRow(lettersMatcher.group(0).trim());

        try {
            this.column = Integer.decode(digitsMatcher.group(0));
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException("Invalid column ID: " + digitsMatcher.group(0).trim());
        }

    } else {
        throw new IllegalArgumentException("Invalid well index: " + wellID);
    }

    validateIndices(this.row, this.column);
}

From source file:com.github.jessemull.microflexbigdecimal.plate.WellPrecursor.java

/**
 * Creates a new Well object from a string holding the column and row values.
 * The string must be in the format [a-ZA-Z]+[0-9]+
 * @param    int       the numerical data type
 * @param    String    the well index//from   w  w w .  j av a  2  s. co  m
 */
public WellPrecursor(int type, String wellID) {

    this.type = type;
    String upper = wellID.toUpperCase().trim();

    Matcher digitsMatcher = digitsPattern.matcher(upper);
    Matcher lettersMatcher = lettersPattern.matcher(upper);
    Matcher alphasOnlyMatcher = alphaOnlyPattern.matcher(upper);

    /* Alphas matcher enforces the correct format for the well ID */

    if (alphasOnlyMatcher.find()) {

        lettersMatcher.find();
        digitsMatcher.find();

        this.row = parseRow(lettersMatcher.group(0).trim());

        try {
            this.column = Integer.decode(digitsMatcher.group(0));
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException("Invalid column ID: " + digitsMatcher.group(0).trim());
        }

    } else {
        throw new IllegalArgumentException("Invalid well index: " + wellID);
    }

    validateIndices(this.row, this.column);
}

From source file:syncthing.android.service.SyncthingUtils.java

public static long parseTime(String str) {
    String[] split = StringUtils.split(str, ":");
    int hour = Integer.decode(split[0]);
    int min = Integer.decode(split[1]);
    return hoursToMillis(hour) + minutesToMillis(min);
}

From source file:com.l2jfree.config.L2Properties.java

public int getInteger(String name, int deflt) {
    String val = getProperty(name);
    if (val == null)
        return deflt;

    try {/*ww w  .  ja v  a  2  s  .  c o  m*/
        return Integer.decode(val);
    } catch (Exception e) {
        throw new IllegalArgumentException("Integer value required, but found: " + val);
    }
}

From source file:org.fire.platform.util.DateUtil.java

/**
 * ?//w  w w . j  av  a 2  s .  c  o m
 * 
 * @return
 */
public static Map<String, Integer> getLastWeekUpAndDown() {
    Map<String, Integer> map = new HashMap<String, Integer>();
    Calendar c = Calendar.getInstance();
    int weekday = c.get(Calendar.DAY_OF_WEEK) + 5;
    c.add(Calendar.DAY_OF_MONTH, -weekday);
    map.put("up", Integer.decode(getTime("yyyyMMdd", c.getTime())));
    c.add(Calendar.DAY_OF_MONTH, 6);
    map.put("down", Integer.decode(getTime("yyyyMMdd", c.getTime())));
    return map;
}

From source file:com.l2jfree.gameserver.templates.StatsSet.java

/**
 * Returns the int associated to the key put in parameter ("name"). If the value associated to the key is null, this method returns the value of the parameter deflt.
 * //w  w  w . j  a  v a  2s .co m
 * @param name : String designating the key in the set
 * @param deflt : int designating the default value if value associated with the key is null
 * @return int : value associated to the key
 */
public final int getInteger(String name, int deflt) {
    Object val = get(name);
    if (val == null)
        return deflt;
    if (val instanceof Number)
        return ((Number) val).intValue();
    try {
        return Integer.decode((String) val);
    } catch (Exception e) {
        throw new IllegalArgumentException("Integer value required, but found: " + val);
    }
}