List of usage examples for java.lang Integer intValue
@HotSpotIntrinsicCandidate public int intValue()
From source file:de.iteratec.iteraplan.presentation.tags.TagUtils.java
/** * Converts the scope name into its corresponding PageContext constant value. * //from w w w. j a v a 2 s .c o m * @param scopeName * Can be "page", "request", "session", or "application" in any case. * @return The constant representing the scope (ie. PageContext.REQUEST_SCOPE). * @throws JspException * if the scopeName is not a valid name. */ public static int getScope(String scopeName) throws JspException { Integer scope = SCOPES.get(scopeName.toLowerCase()); if (scope == null) { throw new JspException("An invalid scope identifier was encountered: " + scopeName); } return scope.intValue(); }
From source file:com.aurel.track.admin.customize.category.filter.execute.SavedFilterExecuteBL.java
/** * Execute a saved filter/* ww w . ja v a 2s. c om*/ * @return */ static IntegerStringBean encodedQueryContainsNotSpecifiedParameter(String query, TPersonBean personBean, Locale locale) { IntegerStringBean integerStringBean = new IntegerStringBean(null, Integer.valueOf(NO_PARAMETER)); if (query != null && query.length() > 0) { String linkReport = ReportQueryBL.b(query); Map<String, String> queryEncodedMap = ReportQueryBL.decodeMapFromUrl(linkReport); //keepMeLogged=keepMeLoggedStr!=null && keepMeLoggedStr.equalsIgnoreCase("true"); boolean clear = false; String queryIDStr = queryEncodedMap.get("queryID"); Integer filterID = null; if (queryIDStr != null) { filterID = Integer.decode(queryIDStr); if (filterID != null) { TQueryRepositoryBean queryRepositoryBean = (TQueryRepositoryBean) TreeFilterFacade.getInstance() .getByKey(filterID); if (queryRepositoryBean != null) { Integer queryType = queryRepositoryBean.getQueryType(); String filterExpression = FilterBL.getFilterExpression(queryRepositoryBean); if (queryType != null) { switch (queryType.intValue()) { case QUERY_PURPOSE.TREE_FILTER: HttpServletRequest request = null; QNode extendedRootNode = TreeFilterReader.getInstance() .readQueryTree(filterExpression); FilterUpperTO filterUpperTO = FilterUpperFromQNodeTransformer .getFilterSelectsFromTree(extendedRootNode, true, true, personBean, locale, true); QNode rootNode = TreeFilterLoaderBL.getOriginalTree(extendedRootNode); boolean hasListWithParameter = false; if (FilterSelectsParametersUtil.containsParameter(filterUpperTO)) { hasListWithParameter = true; //replace the corresponding query parameters with corresponding request parameters request = ServletActionContext.getRequest(); integerStringBean.setValue(Integer.valueOf(CONTAINS_PARAMETER_ORIGINAL)); try { //uncomment the "if" (and keepMeLogged initialization above) if we want to handle the case when //by executing a parameterized query the not all parameters are specified in as request parameters //and the user should be prompted to a new page to specify the parameters //this new page would mean a new tile (the track+ system menus should not be available) clear = true; FilterSelectsParametersUtil.replaceFilterSelectsParameters(filterUpperTO, request, personBean, locale, clear); } catch (NotExistingBeanException e) { LOGGER.warn(e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } if ((FilterSelectsParametersUtil.containsParameter(filterUpperTO) || QNodeParametersUtil.containsParameter(rootNode))) { //if there are parameters from an encoded query but with keepMeLogged //and not all parameters were set with request parameters //go to parameters specifying page integerStringBean .setValue(Integer.valueOf(CONTAINS_PARAMETER_AFTER_REQUEST_REPLACE)); } else { if (hasListWithParameter) { try { QNode extendedNode = TreeFilterSaverBL .createQNodeWithQueryListsTO(rootNode, filterUpperTO, locale); filterExpression = TreeFilterWriter.getInstance().toXML(extendedNode); } catch (Exception e) { String errorKey = e.getMessage(); String errorMessage = LocalizeUtil .getLocalizedTextFromApplicationResources(errorKey, locale); LOGGER.warn("Transforming the instant query to expression failed with " + errorMessage); } integerStringBean.setLabel(filterExpression); } } break; case QUERY_PURPOSE.TQLPLUS_FILTER: case QUERY_PURPOSE.TQL_FILTER: return integerStringBean; } } } } } } return integerStringBean; }
From source file:com.docd.purefm.utils.MimeTypes.java
@DrawableRes public static int getIconForExt(String ext) { final Integer res = EXT_ICONS.get(ext); //noinspection ResourceType,UnnecessaryUnboxing return res == null ? 0 : res.intValue(); }
From source file:com.aurel.track.fieldType.bulkSetters.SystemDateBulkSetter.java
/** * Gets the opposite field to set the value also * @param fieldID// ww w. j a va2 s .com * @return */ private static Integer getOppositeField(Integer fieldID) { Integer oppositeField = null; if (fieldID != null) { switch (fieldID.intValue()) { case SystemFields.STARTDATE: oppositeField = SystemFields.INTEGER_ENDDATE; break; case SystemFields.ENDDATE: oppositeField = SystemFields.INTEGER_STARTDATE; break; case SystemFields.TOP_DOWN_START_DATE: oppositeField = SystemFields.INTEGER_TOP_DOWN_END_DATE; break; case SystemFields.TOP_DOWN_END_DATE: oppositeField = SystemFields.INTEGER_TOP_DOWN_START_DATE; break; } } return oppositeField; }
From source file:HtmlEncoder.java
/** * Given a string containing entity escapes, returns a string containing the actual Unicode * characters corresponding to the escapes. Adapted from * http://www.purpletech.com/code/src/com/purpletech/util/Utils.java. * //from w w w . jav a 2s . c om * @param s1 * Description of the Parameter * @return Description of the Return Value */ public static String decode(String s1) { StringBuffer buf = new StringBuffer(); int i; for (i = 0; i < s1.length(); ++i) { char ch = s1.charAt(i); if (ch == '&') { int semi = s1.indexOf(';', i + 1); if (semi == -1) { buf.append(ch); continue; } String entity = s1.substring(i + 1, semi); Integer iso; if (entity.charAt(0) == '#') { iso = new Integer(entity.substring(1)); } else { iso = e2i.get(entity); } if (iso == null) { buf.append("&" + entity + ";"); } else { buf.append((char) (iso.intValue())); } i = semi; } else { buf.append(ch); } } return buf.toString(); }
From source file:com.todoroo.astrid.sync.SyncProviderPreferences.java
private static final String adjustErrorForDisplay(Resources r, String lastError, String service) { Set<String> exceptions = getExceptionMap().keySet(); Integer resource = null; for (String key : exceptions) { if (lastError.contains(key)) { resource = getExceptionMap().get(key); break; }/*from ww w .j a va 2 s .c o m*/ } if (resource == null) return lastError; return r.getString(resource.intValue(), service); }
From source file:com.aurel.track.exchange.excel.ExcelFieldMatchBL.java
/** * Get the localized TFieldConfigBeans/*w w w . j av a 2 s .c o m*/ * @param locale * @return */ static List<IntegerStringBean> getFieldConfigs(Integer personID, Locale locale) { List<TFieldConfigBean> fieldConfigsList = FieldRuntimeBL.getLocalizedDefaultFieldConfigs(locale); List<IntegerStringBean> matchableFieldsList = new LinkedList<IntegerStringBean>(); //null fieldID: by selecting the empty entry the field be ignored matchableFieldsList.add(new IntegerStringBean("-", 0)); for (TFieldConfigBean fieldConfigBean : fieldConfigsList) { Integer fieldID = fieldConfigBean.getField(); IFieldTypeRT fieldTypeRT = FieldTypeManager.getFieldTypeRT(fieldID); if (fieldTypeRT != null && fieldTypeRT.mightMatchExcelColumn()) { matchableFieldsList.add(new IntegerStringBean(fieldConfigBean.getLabel(), fieldID)); } } List<Integer> fieldIDs = new LinkedList<Integer>(); fieldIDs.add(FieldsRestrictionsToRoleBL.PSEUDO_COLUMNS.WATCHERS); Map<Integer, Integer> fieldRestrictions = AccessBeans.getFieldRestrictions(personID, null, null, fieldIDs, false); Integer watchersFlag = fieldRestrictions.get(FieldsRestrictionsToRoleBL.PSEUDO_COLUMNS.WATCHERS); if (watchersFlag == null || watchersFlag.intValue() == TRoleFieldBean.ACCESSFLAG.READ_WRITE) { matchableFieldsList.add(new IntegerStringBean( LocalizeUtil.getLocalizedTextFromApplicationResources( TReportLayoutBean.PSEUDO_COLUMN_LABELS.INFORMANT_LIST, locale), TReportLayoutBean.PSEUDO_COLUMNS.INFORMANT_LIST)); matchableFieldsList.add(new IntegerStringBean( LocalizeUtil.getLocalizedTextFromApplicationResources( TReportLayoutBean.PSEUDO_COLUMN_LABELS.CONSULTANT_LIST, locale), TReportLayoutBean.PSEUDO_COLUMNS.CONSULTANT_LIST)); } matchableFieldsList.add(new IntegerStringBean( LocalizeUtil.getLocalizedTextFromApplicationResources( "admin.actions.importExcel.fieldMatch.hierarchyColumn", locale), LOCAL_PARENT_PSEUDO_COLUMN)); Collections.sort(matchableFieldsList); return matchableFieldsList; }
From source file:com.github.jessemull.microflex.util.IntegerUtil.java
/** * Safely converts a number to an integer. Loss of precision may occur. Throws * an arithmetic exception upon overflow. * @param Object number to parse//from w w w .j a va 2 s. co m * @return parsed number * @throws ArithmeticException on overflow */ public static int toInteger(Object obj) { /* Switch on class and convert to an int */ String type = obj.getClass().getSimpleName(); int parsed; switch (type) { case "Byte": Byte by = (Byte) obj; parsed = by.intValue(); break; case "Short": Short sh = (Short) obj; parsed = sh.intValue(); break; case "Integer": Integer in = (Integer) obj; parsed = in.intValue(); break; case "Long": Long lo = (Long) obj; if (!OverFlowUtil.intOverflow(lo)) { throw new ArithmeticException("Overflow casting " + obj + " to an int."); } parsed = lo.intValue(); break; case "Float": Float fl = (Float) obj; if (!OverFlowUtil.intOverflow(fl)) { throw new ArithmeticException("Overflow casting " + obj + " to an int."); } parsed = fl.intValue(); break; case "BigInteger": BigInteger bi = (BigInteger) obj; if (!OverFlowUtil.intOverflow(bi)) { throw new ArithmeticException("Overflow casting " + obj + " to an int."); } parsed = bi.intValue(); break; case "BigDecimal": BigDecimal bd = (BigDecimal) obj; if (!OverFlowUtil.intOverflow(bd)) { throw new ArithmeticException("Overflow casting " + obj + " to an int."); } parsed = bd.intValue(); break; case "Double": Double db = (Double) obj; if (!OverFlowUtil.intOverflow(db)) { throw new ArithmeticException("Overflow casting " + obj + " to an int."); } parsed = db.intValue(); break; default: throw new IllegalArgumentException( "Invalid type: " + type + "\nData values " + "must extend the abstract Number class."); } return parsed; }
From source file:com.github.jessemull.microflex.util.IntegerUtil.java
/** * Safely converts a number to an integer. Loss of precision may occur. Throws * an arithmetic exception upon overflow. * @param Number number to parse//from www .jav a2s .c o m * @return parsed number * @throws ArithmeticException on overflow */ public static int toInteger(Number number) { /* Switch on class and convert to an int */ String type = number.getClass().getSimpleName(); int parsed; switch (type) { case "Byte": Byte by = (Byte) number; parsed = by.intValue(); break; case "Short": Short sh = (Short) number; parsed = sh.intValue(); break; case "Integer": Integer in = (Integer) number; parsed = in.intValue(); break; case "Long": Long lo = (Long) number; if (!OverFlowUtil.intOverflow(lo)) { throw new ArithmeticException("Overflow casting " + number + " to an int."); } parsed = lo.intValue(); break; case "Float": Float fl = (Float) number; if (!OverFlowUtil.intOverflow(fl)) { throw new ArithmeticException("Overflow casting " + number + " to an int."); } parsed = fl.intValue(); break; case "BigInteger": BigInteger bi = (BigInteger) number; if (!OverFlowUtil.intOverflow(bi)) { throw new ArithmeticException("Overflow casting " + number + " to an int."); } parsed = bi.intValue(); break; case "BigDecimal": BigDecimal bd = (BigDecimal) number; if (!OverFlowUtil.intOverflow(bd)) { throw new ArithmeticException("Overflow casting " + number + " to an int."); } parsed = bd.intValue(); break; case "Double": Double db = (Double) number; if (!OverFlowUtil.intOverflow(db)) { throw new ArithmeticException("Overflow casting " + number + " to an int."); } parsed = db.intValue(); break; default: throw new IllegalArgumentException( "Invalid type: " + type + "\nData values " + "must extend the abstract Number class."); } return parsed; }
From source file:com.wso2telco.core.dbutils.DbUtils.java
/** *Format./*from w w w . ja v a 2s . c o m*/ * * @param integerData * the integer data * @param finalLen * the final len * @return the string * @throws Exception * the exception */ public static String format(Integer integerData, int finalLen) throws Exception { int intData; String finalStr; intData = integerData.intValue(); finalStr = format(intData, finalLen); return (finalStr); }