Example usage for java.lang Integer toString

List of usage examples for java.lang Integer toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a String object representing this Integer 's value.

Usage

From source file:Main.java

/**
 * Write an {@link Integer} value into XML output.
 *
 * @param value//from   ww  w. j  a v  a  2s .co m
 * value to write
 *
 * @param min
 * minimal value
 *
 * @param max
 * maximal value
 *
 * @return
 * XML string
 *
 * @throws IllegalArgumentException
 * if a validation error occured
 */
private static String printInteger(Integer value, Integer min, Integer max) {
    if (value == null) {
        throw new IllegalArgumentException("The provided integer value NULL is invalid!");
    }
    if (min != null && value < min) {
        throw new IllegalArgumentException(
                "The provided integer value " + value + " is too small (minimum is " + min + ")!");
    }
    if (max != null && value > max) {
        throw new IllegalArgumentException(
                "The provided integer value " + value + " is too high (maximum is " + max + ")!");
    }
    return value.toString();
}

From source file:com.cloudera.oryx.app.batch.mllib.als.ALSUpdate.java

private static void addIDsExtension(PMML pmml, String key, JavaPairRDD<Integer, ?> features,
        Map<Integer, String> reverseIDMapping) {
    List<Integer> hashedIDs = features.keys().collect();
    List<String> ids = new ArrayList<>(hashedIDs.size());
    for (Integer hashedID : hashedIDs) {
        String originalID = reverseIDMapping.get(hashedID);
        ids.add(originalID == null ? hashedID.toString() : originalID);
    }/*  w  ww .  ja  v  a 2 s  . co m*/
    AppPMMLUtils.addExtensionContent(pmml, key, ids);
}

From source file:com.kenai.redminenb.issue.JournalDisplay.java

private static String formatCategory(RedmineRepository repo, RedmineIssue issue, String value) {
    if (value == null) {
        return null;
    }//from  w w  w  .  j av a  2  s .  c o m
    try {
        Integer id = Integer.valueOf(value);
        for (IssueCategory ic : repo
                .getIssueCategories(ProjectFactory.create(issue.getIssue().getProjectId()))) {
            if (ic.getId().equals(id)) {
                return ic.getName() + " (ID: " + id.toString() + ")";
            }
        }
    } catch (NumberFormatException ex) {
    }
    return "(ID: " + value + ")";
}

From source file:com.kenai.redminenb.issue.JournalDisplay.java

private static String formatUser(RedmineRepository repo, RedmineIssue issue, String value) {
    if (value == null) {
        return null;
    }/* w  w  w .j  a v  a  2s  . c  om*/
    try {
        Integer id = Integer.valueOf(value);
        for (AssigneeWrapper ru : repo
                .getAssigneeWrappers(ProjectFactory.create(issue.getIssue().getProjectId()))) {
            if (ru.getId().equals(id)) {
                return ru.getName() + " (ID: " + id.toString() + ")";
            }
        }
    } catch (NumberFormatException ex) {
    }
    return "(ID: " + value + ")";
}

From source file:edu.ku.brc.helpers.XMLHelper.java

public static void xmlAttr(final StringBuilder sb, final String attr, final Integer val) {
    if (val != null || isEmptyAttrOK) {
        xmlAttr(sb, attr, val.toString());
    }//from   w  w w.  jav  a2  s .c  o  m
}

From source file:com.aurel.track.admin.server.dbbackup.DatabaseBackupBL.java

/**
 * A little routine that creates the day of the week for crontab
 * @param days/*from ww w  .  jav  a 2  s.c  om*/
 * @return
 */
private static String getCronDays(List<Integer> days) {
    if (days == null || days.isEmpty()) {
        return "1";
    } else {
        StringBuilder buf = new StringBuilder();
        Integer cur;
        Iterator<Integer> it = days.iterator();
        while (it.hasNext()) {
            cur = it.next();
            buf.append(cur.toString());
            if (it.hasNext()) {
                buf.append(",");
            }
        }
        return buf.toString();
    }
}

From source file:de.iteratec.iteraplan.businesslogic.exchange.legacyExcel.importer.ExcelImportUtilities.java

private static String getNumericCellContentAsString(Cell cell, ProcessingLog processingLog) {
    // for numeric cells / dates we have to look at the cell format to tell if it's a date cell
    // If so, we retrieve the value as a date and convert it to ISO String notation

    if (HSSFDateUtil.isCellDateFormatted(cell)) {
        // is it a date-formatted number? then return the ISO-formatted date instead of the number
        Date cellDate = contentAsDate(cell);
        final SimpleDateFormat dateformatter = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
        return dateformatter.format(cellDate);
    }//from   w  w  w.  j  a v  a  2  s  .  c  om

    Double d = null;
    try {
        d = contentAsDouble(cell);
    } catch (NumberFormatException ex) {
        processingLog.warn("Cell [{0}] {1}; ignoring the value", getCellRef(cell), ex.getMessage());
    } catch (IllegalStateException e) {
        processingLog.warn("Cell [{0}] {1}; ignoring the value", getCellRef(cell), e.getMessage());
    }

    if (d != null) {
        // cut off *.0
        double i = d.doubleValue() - d.intValue();

        if (i == 0) {
            Integer j = Integer.valueOf(d.intValue());
            return j.toString();
        } else {
            return d.toString();
        }
    }
    return "";
}

From source file:org.apache.manifoldcf.agents.output.opensearchserver.OpenSearchServerConnector.java

/**
 * Read the content of a resource, replace the variable ${PARAMNAME} with the
 * value and copy it to the out.//from  w w  w  .j av a  2  s . c  o  m
 * 
 * @param resName
 * @param out
 * @throws ManifoldCFException
 */
private static void outputResource(String resName, IHTTPOutput out, Locale locale, OpenSearchServerParam params,
        String tabName, Integer sequenceNumber, Integer actualSequenceNumber) throws ManifoldCFException {
    Map<String, String> paramMap = null;
    if (params != null) {
        paramMap = params.buildMap();
        if (tabName != null) {
            paramMap.put("TabName", tabName);
        }
        if (actualSequenceNumber != null)
            paramMap.put("SelectedNum", actualSequenceNumber.toString());
    } else {
        paramMap = new HashMap<String, String>();
    }
    if (sequenceNumber != null)
        paramMap.put("SeqNum", sequenceNumber.toString());

    Messages.outputResourceWithVelocity(out, locale, resName, paramMap, false);
}

From source file:org.hyperic.hq.hqapi1.tools.Shell.java

static void initConnectionProperties(final String[] args) throws Exception {
    final List<String> connectionArgs = new ArrayList<String>(5);
    for (int i = 0; i < args.length; i++) {
        final String arg = args[i];
        if (arg.trim().startsWith("--" + OptionParserFactory.OPT_HOST)
                || arg.trim().startsWith("--" + OptionParserFactory.OPT_PORT)
                || arg.trim().startsWith("--" + OptionParserFactory.OPT_PASS)
                || arg.trim().startsWith("--" + OptionParserFactory.OPT_USER)
                || arg.trim().startsWith("--" + OptionParserFactory.OPT_SECURE[1])
                || arg.trim().equals("-" + OptionParserFactory.OPT_SECURE[0])
                || arg.trim().startsWith("--" + OptionParserFactory.OPT_PROPERTIES)) {
            connectionArgs.add(arg);/*from w  ww  .  ja va2s  . c o m*/
            if (i != args.length - 1 && !(args[i + 1].startsWith("--"))) {
                connectionArgs.add(args[i + 1]);
            }
        }
    }
    final OptionParser optionParser = (OptionParser) new OptionParserFactory().getObject();
    final OptionSet options = optionParser.parse(connectionArgs.toArray(new String[connectionArgs.size()]));

    Properties clientProps = getClientProperties((String) options.valueOf(OptionParserFactory.OPT_PROPERTIES));

    String host = (String) options.valueOf(OptionParserFactory.OPT_HOST);
    if (host == null) {
        host = clientProps.getProperty(OptionParserFactory.OPT_HOST);
    }
    if (host != null) {
        System.setProperty(OptionParserFactory.SYSTEM_PROP_PREFIX + OptionParserFactory.OPT_HOST, host);
    }

    Integer port;
    if (options.hasArgument(OptionParserFactory.OPT_PORT)) {
        port = (Integer) options.valueOf(OptionParserFactory.OPT_PORT);
    } else {
        port = Integer.parseInt(clientProps.getProperty(OptionParserFactory.OPT_PORT, "7080"));
    }
    if (port != null) {
        System.setProperty(OptionParserFactory.SYSTEM_PROP_PREFIX + OptionParserFactory.OPT_PORT,
                port.toString());
    }

    String user = (String) options.valueOf(OptionParserFactory.OPT_USER);
    if (user == null) {
        user = clientProps.getProperty(OptionParserFactory.OPT_USER);
    }
    if (user != null) {
        System.setProperty(OptionParserFactory.SYSTEM_PROP_PREFIX + OptionParserFactory.OPT_USER, user);
    }

    String password = (String) options.valueOf(OptionParserFactory.OPT_PASS);
    if (password == null) {
        password = clientProps.getProperty(OptionParserFactory.OPT_PASS);
        // Check for encrypted password
        if (password == null || password.isEmpty()) {
            String encryptionKey = clientProps.getProperty(OptionParserFactory.OPT_ENCRYPTIONKEY);
            String encryptedPassword = clientProps.getProperty(OptionParserFactory.OPT_ENCRYPTEDPASSWORD);
            if (null != encryptionKey && null != encryptedPassword) {
                password = decryptPassword(encryptedPassword, encryptionKey);
            }
        }
    }

    if (host != null && port != null && user != null && password == null) {
        // Prompt for password, but only if other connection properties
        // have been specified.
        try {
            char[] passwordArray = PasswordField.getPassword(System.in, "Enter password: ");
            password = String.valueOf(passwordArray);
        } catch (IOException ioe) {
            System.err.println("Error reading password");
            System.exit(-1);
        }
    }
    if (password != null) {
        System.setProperty(OptionParserFactory.SYSTEM_PROP_PREFIX + OptionParserFactory.OPT_PASS, password);
    }

    Boolean secure = options.has(OptionParserFactory.OPT_SECURE[0])
            || options.has(OptionParserFactory.OPT_SECURE[1])
            || Boolean.valueOf(clientProps.getProperty(OptionParserFactory.OPT_SECURE[1], "false"));
    System.setProperty(OptionParserFactory.SYSTEM_PROP_PREFIX + OptionParserFactory.OPT_SECURE[1],
            secure.toString());
}

From source file:com.evolveum.polygon.test.scim.StandardScimTestUtils.java

protected static Set<Attribute> userMultiValUpdateBuilder(Integer testNumber) {

    StringBuilder buildUpdateEmailAdress = new StringBuilder(testNumber.toString())
            .append("testupdateuser@testdomain.com");

    Set<Attribute> attributeSet = new HashSet<Attribute>();

    attributeSet.add(AttributeBuilder.build(EMAILWORKVALUE, buildUpdateEmailAdress.toString()));
    attributeSet.add(AttributeBuilder.build(EMAILWORKPRIMARY, false));

    return attributeSet;
}