Example usage for java.lang Integer intValue

List of usage examples for java.lang Integer intValue

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public int intValue() 

Source Link

Document

Returns the value of this Integer as an int .

Usage

From source file:org.dbmfs.DbmfsUtil.java

public static Object deserializeType(Integer value, String javaTypeName) {
    if (javaTypeName.equals("java.lang.Integer")) {
        return value;
    }/*from w  w w  . java2  s . co  m*/

    if (javaTypeName.equals("java.lang.Boolean")) {
        if (value.intValue() == 1) {
            return new Boolean("true");
        } else {
            return new Boolean("false");
        }
    }
    return value;
}

From source file:com.screenslicer.common.CommonUtil.java

public static int max(List<Integer> ints) {
    int max = Integer.MIN_VALUE;
    for (Integer curInt : ints) {
        if (curInt.intValue() > max) {
            max = curInt.intValue();/*from   w w  w.  ja va2 s.  c  o  m*/
        }
    }
    return max;
}

From source file:com.aurel.track.fieldType.runtime.custom.select.CustomDependentSelectRT.java

private static ILabelBean getPartialMatchEntry(IMatcherValue matcherValue, Locale locale) {
    try {/*from   w ww .jav  a2s .  c  o m*/
        FieldExpressionSimpleTO fieldExpressionSimpleTO = (FieldExpressionSimpleTO) matcherValue;
        Integer selectedMatcher = fieldExpressionSimpleTO.getSelectedMatcher();
        if (selectedMatcher != null) {
            if (selectedMatcher.intValue() == MatchRelations.PARTIAL_MATCH) {
                TOptionBean optionBean = new TOptionBean();
                optionBean.setObjectID(CompositeSelectMatcherRT.ANY_FROM_LEVEL);
                optionBean.setLabel(LocalizeUtil.getLocalizedTextFromApplicationResources(
                        "admin.customize.queryFilter.opt.partialMatch", locale));
                return optionBean;
            } else {
                if (selectedMatcher.intValue() == MatchRelations.PARTIAL_NOTMATCH) {
                    TOptionBean optionBean = new TOptionBean();
                    optionBean.setObjectID(CompositeSelectMatcherRT.NONE_FROM_LEVEL);
                    optionBean.setLabel(LocalizeUtil.getLocalizedTextFromApplicationResources(
                            "admin.customize.queryFilter.opt.partialNotmatch", locale));
                    return optionBean;
                }
            }
        }
    } catch (Exception e) {
        LOGGER.warn("Getting the partial match entry failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    return null;
}

From source file:net.sourceforge.fenixedu.presentationTier.validator.form.ValidateDate.java

public static boolean validate(Object bean, ValidatorAction va, Field field, ActionMessages errors,
        HttpServletRequest request, ServletContext application) {

    String valueString = ValidatorUtils.getValueAsString(bean, field.getProperty());

    String sProperty2 = ValidatorUtils.getValueAsString(bean, field.getVarValue("month"));
    String sProperty3 = ValidatorUtils.getValueAsString(bean, field.getVarValue("day"));

    if (((valueString == null) && (sProperty2 == null) && (sProperty3 == null))
            || ((valueString.length() == 0) && (sProperty2.length() == 0) && (sProperty3.length() == 0))) {
        // errors.add(field.getKey(),Resources.getActionError(request, va,
        // field));
        return true;
    }/* ww w . j  a va 2 s  .  c  om*/

    Integer year = null;
    Integer month = null;
    Integer day = null;

    try {
        year = new Integer(valueString);
        month = new Integer(sProperty2);
        day = new Integer(sProperty3);
    } catch (NumberFormatException e) {
        errors.add(field.getKey(), Resources.getActionMessage(request, va, field));
        return false;
    }

    if (!GenericValidator.isBlankOrNull(valueString)) {
        if (!Data.validDate(day, month, year) || year == null || month == null || day == null
                || year.intValue() < 1 || month.intValue() < 0 || day.intValue() < 1) {
            errors.add(field.getKey(), Resources.getActionMessage(request, va, field));
        }

        return false;
    }

    return true;
}

From source file:com.aurel.track.admin.customize.localize.LocalizeBL.java

/**
 * Gets the field names for system fields
 * @param type/* ww w .j  a v  a  2s  .  co m*/
 * @return
 */
public static String getSystemListFieldName(Integer type) {
    switch (type.intValue()) {
    case RESOURCE_TYPES.ISSUETYPE:
        return new TListTypeBean().getKeyPrefix();
    case RESOURCE_TYPES.STATUS:
        return new TStateBean().getKeyPrefix();
    case RESOURCE_TYPES.PRIORITY:
        return new TPriorityBean().getKeyPrefix();
    case RESOURCE_TYPES.SEVERITY:
        return new TSeverityBean().getKeyPrefix();
    case RESOURCE_TYPES.PROJECT_STATUS:
        return new TSystemStateBean().getKeyPrefix() + TSystemStateBean.ENTITYFLAGS.PROJECTSTATE + DOT;
    case RESOURCE_TYPES.RELEASE_STATUS:
        return new TSystemStateBean().getKeyPrefix() + TSystemStateBean.ENTITYFLAGS.RELEASESTATE + DOT;
    case RESOURCE_TYPES.ACCOUNT_STATUS:
        return new TSystemStateBean().getKeyPrefix() + TSystemStateBean.ENTITYFLAGS.ACCOUNTSTATE + DOT;
    default:
        return "";
    }
}

From source file:io.uploader.drive.drive.DriveUtils.java

/**
 * Find files./*www .ja  va  2 s  .  c om*/
 * 
 * @param service
 *            Drive API service instance.
 * @param title
 *            Title of the file, including the extension.
 * @param parentId
 *            Optional parent folder's ID.
 * @param mimeType
 *            Optional MIME type of the file.
 * @param maxResults
 *            Optional maximum number of files in the returned list.
 * @return List of file metadatas.
 * @throws IOException
 */
public static FileList findFilesWithTitleAndMineType(Drive service, String title, HasId parentId,
        HasMimeType mineType, Integer maxResults) throws IOException {

    Files.List request = service.files().list();
    if (maxResults != null && maxResults.intValue() > 0) {
        request = request.setMaxResults(maxResults);
    }
    StringBuilder query = new StringBuilder();
    query.append("title = '");
    query.append(escape(title));
    query.append("'");
    if (mineType != null && org.apache.commons.lang3.StringUtils.isNotEmpty(mineType.getMimeType())) {
        query.append(" and mimeType='");
        query.append(mineType.getMimeType());
        query.append("'");
    }
    query.append(" and trashed=false");
    if (parentId != null && org.apache.commons.lang3.StringUtils.isNotEmpty(parentId.getId())) {
        query.append(" and '");
        query.append(escape(parentId.getId()));
        query.append("' in parents");
    } else {
        query.append(" and '");
        query.append("root");
        query.append("' in parents");
    }

    logger.info("findFilesWithTitleAndMineType: " + query.toString());

    request = request.setQ(query.toString());
    FileList files = request.execute();
    return files;
}

From source file:io.uploader.drive.drive.DriveUtils.java

/**
 * Find folders.//from  w ww .  j a  v a2s. c o m
 * 
 * @param service
 *            Drive API service instance.
 * @param title
 *            Optional title of the folder.
 * @param parentId
 *            Optional parent folder's ID.
 * @param maxResults
 *            Optional maximum number of folders in the returned list.
 * @return List of file metadatas.
 * @throws IOException
 */
public static FileList findDirectoriesWithTitle(Drive service, String title, HasId parentId, Integer maxResults)
        throws IOException {

    Files.List request = service.files().list();
    if (maxResults != null && maxResults.intValue() > 0) {
        request = request.setMaxResults(maxResults);
    }
    StringBuilder query = new StringBuilder();
    if (org.apache.commons.lang3.StringUtils.isNotEmpty(title)) {
        query.append("title = '");
        query.append(escape(title));
        query.append("' and  ");
    }
    query.append("mimeType='");
    query.append(mimeTypeDirectory);
    query.append("' and trashed=false");
    if (parentId != null && org.apache.commons.lang3.StringUtils.isNotEmpty(parentId.getId())) {
        query.append(" and '");
        query.append(escape(parentId.getId()));
        query.append("' in parents");
    } else {
        query.append(" and '");
        query.append("root");
        query.append("' in parents");
    }

    logger.info("findDirectoriesWithTitle: " + query.toString());

    request = request.setQ(query.toString());
    FileList files = request.execute();
    return files;
}

From source file:de.innovationgate.utils.URLBuilder.java

/**
 * Tests if the given port is the default port for the given protocol.
 * This is true if browsers implicitly assume the given port for an URL with the given protocol and do not need it explicitly in the URL.
 * @param port Tested port/*from ww w  . j  av a2s  .  c  om*/
 * @param protocol Tested protocol
 * @return true if it is the default port
 */
public static boolean isDefaultPortForProtocol(int port, String protocol) {

    Integer defaultPort = _defaultProtocolPorts.get(protocol);
    if (defaultPort != null && defaultPort.intValue() == port) {
        return true;
    }

    return false;

}

From source file:com.ms.commons.test.tool.ExportDatabaseData.java

private static String getSqlTableName(String sql, final Map<String, Integer> tableMap,
        final MutableObject refTableName) {
    CCJSqlParserManager sqlPaerserManager = new CCJSqlParserManager();
    try {//from  www.  j  a  v  a2  s.c  om
        Statement statement = sqlPaerserManager.parse(new StringReader(sql));
        final MutableObject refTable = new MutableObject(null);

        statement.accept(new StatementVisitor() {

            public void visit(CreateTable createTable) {
                throw new MessageException("Cannot parser sql for: " + createTable.getClass().getSimpleName());
            }

            public void visit(Truncate truncate) {
                throw new MessageException("Cannot parser sql for: " + truncate.getClass().getSimpleName());
            }

            public void visit(Drop drop) {
                throw new MessageException("Cannot parser sql for: " + drop.getClass().getSimpleName());
            }

            public void visit(Replace replace) {
                throw new MessageException("Cannot parser sql for: " + replace.getClass().getSimpleName());
            }

            public void visit(Insert insert) {
                throw new MessageException("Cannot parser sql for: " + insert.getClass().getSimpleName());
            }

            public void visit(Update update) {
                throw new MessageException("Cannot parser sql for: " + update.getClass().getSimpleName());
            }

            public void visit(Delete delete) {
                throw new MessageException("Cannot parser sql for: " + delete.getClass().getSimpleName());
            }

            public void visit(Select select) {
                select.getSelectBody().accept(new SelectVisitor() {

                    public void visit(Union union) {
                        refTable.setValue("table_" + GLOBAL_COUNT.getAndIncrement());
                    }

                    public void visit(PlainSelect plainSelect) {
                        plainSelect.getFromItem().accept(new FromItemVisitor() {

                            public void visit(SubJoin subjoin) {
                                refTable.setValue("table_" + GLOBAL_COUNT.getAndIncrement());
                            }

                            public void visit(SubSelect subSelect) {
                                refTable.setValue("table_" + GLOBAL_COUNT.getAndIncrement());
                            }

                            public void visit(Table tableName) {
                                String tn = tableName.getName().trim().toLowerCase();
                                refTableName.setValue(tn);
                                Integer tnCount = tableMap.get(tn);
                                if (tnCount == null) {
                                    tableMap.put(tn, Integer.valueOf(1));
                                    refTable.setValue(tn);
                                } else {
                                    tnCount = Integer.valueOf(tnCount.intValue() + 1);
                                    tableMap.put(tn, tnCount);
                                    refTable.setValue(tn + "_" + tnCount.intValue());
                                }
                            }
                        });
                    }
                });
            }
        });

        if (refTable.getValue() == null) {
            throw new MessageException("Canot parser sql and get table name.");
        }
        return (String) refTable.getValue();
    } catch (Exception e) {
        throw ExceptionUtil.wrapToRuntimeException(e);
    }
}

From source file:it.univpm.deit.semedia.musicuri.core.Toolset.java

/**
 * Removes the first occurence of an integer within a String. It is used to 
 * remove the integer test case identifier from filenames that are used for 
 * testing and evaluation purposes in this project
 * @param filename the filename to remove the identifier from
 * @return a string containing the filename without an identifier
 *///ww w  .ja  v  a  2 s .  co m
public static String removeTestCaseIdentifier(String filename) {
    String filenameWithoutIdentifier;
    StringTokenizer tok = new StringTokenizer(filename, " `~!@#$%^&*()_-+={}[]|\\:;\"'<>,.?/\t\n\r");
    int numOfTokensInString = tok.countTokens();
    String[] tokens = new String[numOfTokensInString];
    int i = 0;
    while (tok.hasMoreTokens()) {
        String token = tok.nextToken();
        tokens[i] = token;
        i++;
    }

    try {
        Integer tmp = new Integer(tokens[0]);
        int testCaseId = tmp.intValue();
        String identifier = "";
        if (testCaseId >= 1) {
            // add zero padding
            if (testCaseId >= 0 && testCaseId < 10)
                identifier = "000" + testCaseId + " ";
            if (testCaseId >= 10 && testCaseId < 100)
                identifier = "00" + testCaseId + " ";
            if (testCaseId >= 100 && testCaseId < 1000)
                identifier = "0" + testCaseId + " ";
            if (testCaseId > 1000)
                identifier = testCaseId + " ";
        }
        filenameWithoutIdentifier = filename.replaceFirst(identifier, "");
    } catch (NumberFormatException e) {
        // if the first token was not an integer identifier, return what you got as input
        filenameWithoutIdentifier = filename;
    }
    return filenameWithoutIdentifier;
}