List of usage examples for java.lang Integer intValue
@HotSpotIntrinsicCandidate public int intValue()
From source file:net.rim.ejde.internal.util.VMUtils.java
/** * Convert key to preference label.//from w w w .j a v a 2s . co m * * @param keyId * the key id * @param keyCache * the key cache * * @return the string */ public static String convertKeyToPreferenceLabel(Integer keyId, BBSigningKeys keyCache) { String id = null; if ((keyId != null) && (keyCache != null)) { id = ((keyCache.getKeyName(keyId) != null) ? keyCache.getKeyName(keyId).trim() : "") + " (0x" //$NON-NLS-1$//$NON-NLS-2$ + Integer.toHexString(keyId.intValue()) + ")";//$NON-NLS-1$ } return id; }
From source file:TypeConversionHelper.java
/** * Convert a string into an integer./*from w w w . ja va2 s .c om*/ * Returns the default value if not convertable. * @param str The string * @param dflt The default value * @return The converted int value */ public static int intFromString(String str, int dflt) { try { Integer val = new Integer(str); return val.intValue(); } catch (NumberFormatException nfe) { return dflt; } }
From source file:io.fabric8.maven.core.util.kubernetes.KubernetesResourceUtil.java
public static boolean addPort(List<ContainerPort> ports, String portNumberText, String portName, Logger log) { if (StringUtils.isBlank(portNumberText)) { return false; }// w w w . j a v a2s. c o m int portValue; try { portValue = Integer.parseInt(portNumberText); } catch (NumberFormatException e) { log.warn("Could not parse remote debugging port %s as an integer: %s", portNumberText, e); return false; } for (ContainerPort port : ports) { String name = port.getName(); Integer containerPort = port.getContainerPort(); if (containerPort != null && containerPort.intValue() == portValue) { return false; } } ports.add(new ContainerPortBuilder().withName(portName).withContainerPort(portValue).build()); return true; }
From source file:com.microsoft.tfs.client.common.ui.framework.helper.ColorUtils.java
/** * Gets the windows system color id identified by name, which will be * resolved to the SWT Win32 specific color names (mostly a mirror of the * constants used by GetSysColor, but not necessarily. See * org.eclipse.swt.internal.win32.OS for color names.) * * @param colorName//from w w w .ja va 2s .co m * The name of the color to resolve. * @throws IllegalArgumentException * if the current platform is not win32 * @return The color id identified by this name, or -1 if it could not be * looked up. */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static int getWin32SystemColorID(final String colorName) { Check.notNull(colorName, "colorName"); //$NON-NLS-1$ Check.isTrue(WindowSystem.isCurrentWindowSystem(WindowSystem.WIN32), "WindowSystem.WIN32"); //$NON-NLS-1$ try { final Class osClass = Class.forName("org.eclipse.swt.internal.win32.OS"); //$NON-NLS-1$ if (osClass == null) { log.warn("Could not load win32 constants class"); //$NON-NLS-1$ } else { final Field swtColorIdField = osClass.getField(colorName); if (swtColorIdField == null) { log.warn(MessageFormat.format("Could not load swt win32 color constant {0}", colorName)); //$NON-NLS-1$ } else { /* * Get the SWT constant id for this color (this is not the * windows color id) */ final Integer swtColorIdValue = swtColorIdField.getInt(osClass); if (swtColorIdValue == null) { log.warn(MessageFormat.format("Could not load swt win32 color constant {0}", colorName)); //$NON-NLS-1$ } else { /* Now look up the windows color ID */ final Method sysColorMethod = osClass.getMethod("GetSysColor", new Class[] { //$NON-NLS-1$ int.class }); if (sysColorMethod == null) { log.warn("Could not load win32 GetSysColor method"); //$NON-NLS-1$ } else { final Object winColorId = sysColorMethod.invoke(osClass, new Object[] { swtColorIdValue.intValue() }); if (winColorId == null) { log.warn(MessageFormat.format("Could not query win32 color constant {0}", //$NON-NLS-1$ colorName)); } else if (!(winColorId instanceof Integer)) { log.warn(MessageFormat.format("Received non-integer win32 color constant for {0}", //$NON-NLS-1$ colorName)); } else { return ((Integer) winColorId).intValue(); } } } } } } catch (final Throwable t) { log.warn("Could not load win32 constants", t); //$NON-NLS-1$ } return -1; }
From source file:GrayModel.java
public int getIntValue() { Integer myValue = (Integer) getValue(); return myValue.intValue(); }
From source file:com.aurel.track.exchange.msProject.exchange.MsProjectExchangeBL.java
public static double getHoursDiff(Map<String, Integer> fromTime, Map<String, Integer> toTime) { Integer fromHours = fromTime.get(MSPROJECT_TIME_UNITS.HOUR); Integer fromMinutes = fromTime.get(MSPROJECT_TIME_UNITS.MINUTE); Integer toHours = toTime.get(MSPROJECT_TIME_UNITS.HOUR); Integer toMinutes = toTime.get(MSPROJECT_TIME_UNITS.MINUTE); double hoursDiff = 0; if (toHours != null && fromHours != null) { hoursDiff = (double) (toHours.intValue()) - fromHours.intValue(); }//from ww w .ja va 2 s .com int minutesDiff = 0; if (toMinutes != null && fromMinutes != null) { minutesDiff = toMinutes.intValue() - fromMinutes.intValue(); if (minutesDiff < 0) { minutesDiff += 60; hoursDiff = hoursDiff - 1; } } if (fromMinutes != null) { hoursDiff += minutesDiff / (double) 60; } return AccountingBL.roundToDecimalDigits(hoursDiff, true); }
From source file:com.nzion.util.UtilMisc.java
/** Converts an <code>Object</code> to an <code>int</code>. Returns * zero if conversion is not possible./* w w w.j a v a 2 s . c o m*/ * @param obj Object to convert * @return int value */ public static int toInteger(Object obj) { Integer result = toIntegerObject(obj); return result == null ? 0 : result.intValue(); }
From source file:sample.service.ItemService.java
public boolean isItemInStock(String itemId) { Integer i = itemDao.selectInventoryQuantity(itemId); return (i != null && i.intValue() > 0); }
From source file:com.aurel.track.admin.customize.category.filter.tree.design.TreeFilterSaverBL.java
/** * Transform a list of QueryExpressions with parenthesis into a tree * @param expressionList/*ww w . j a va 2 s. co m*/ * @param node * @param operationStack */ public static QNode transformExpressionListToTree(List<FieldExpressionInTreeTO> expressionList, Stack<QNode> operationStack) throws Exception { if (expressionList == null || expressionList.isEmpty()) { return null; } QNode root = new QNode(); root.setType(QNode.AND); operationStack.push(root); if (expressionList != null) { Iterator<FieldExpressionInTreeTO> iterator = expressionList.iterator(); boolean first = true; while (iterator.hasNext()) { FieldExpressionInTreeTO fieldExpressionInTree = iterator.next(); if (operationStack.isEmpty()) { throw new Exception("admin.customize.queryFilter.err.closedGtOpened"); } QNode peekNode = operationStack.peek(); if (!first) { //the first operation (the hidden one) is not significant Integer operation = fieldExpressionInTree.getSelectedOperation(); if (operation != null) { if (peekNode.isTypeAlreadySet()) { if (!equalOperation(peekNode, operation)) { throw new Exception( "admin.customize.queryFilter.err.differentOperationsInParenthesis"); } } else { //in the outermost level the second filter expression sets the operation, //inside internal parenthesis the first one setOperation(peekNode, operation.intValue()); peekNode.setTypeAlreadySet(true); } } } else { first = false; if (!iterator.hasNext()) { //it can be also AND, it doesn't have importance because it is a single expression peekNode.setType(QNode.OR); } } int leftParenthesis = fieldExpressionInTree.getParenthesisOpen(); for (int i = 0; i < leftParenthesis; i++) { //unknown node type (AND or OR) QNode qNode = new QNode(); peekNode.addChild(qNode); operationStack.push(qNode); peekNode = operationStack.peek(); } peekNode.addChild(new QNodeExpression(fieldExpressionInTree)); int rightParenthesis = fieldExpressionInTree.getParenthesisClosed(); if (rightParenthesis > 0) { for (int i = 0; i < rightParenthesis; i++) { if (operationStack.isEmpty()) { throw new Exception("admin.customize.queryFilter.err.closedGtOpened"); } operationStack.pop(); } } } //pop the root if (operationStack.isEmpty()) { throw new Exception("admin.customize.queryFilter.err.closedGtOpened"); } operationStack.pop(); if (!operationStack.isEmpty()) { throw new Exception("admin.customize.queryFilter.err.closedLtOpened"); } } return root; }
From source file:com.gst.infrastructure.codes.domain.CodeValue.java
public static CodeValue fromJson(final Code code, final JsonCommand command) { final String label = command.stringValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue()); Integer position = command .integerValueSansLocaleOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue()); String description = command/*from w w w . j av a2s .c o m*/ .stringValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.DESCRIPTION.getValue()); Boolean isActiveObj = command .booleanObjectValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.IS_ACTIVE.getValue()); boolean isActive = true; if (isActiveObj != null) { isActive = isActiveObj; } if (position == null) { position = new Integer(0); } Boolean mandatory = command .booleanPrimitiveValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.IS_MANDATORY.getValue()); // if the "mandatory" Boolean object is null, then set it to false by default if (mandatory == null) { mandatory = false; } return new CodeValue(code, label, position.intValue(), description, isActive, mandatory); }