List of usage examples for java.lang Integer intValue
@HotSpotIntrinsicCandidate public int intValue()
From source file:com.liangc.hq.base.utils.MonitorUtils.java
private static Boolean isSubMiniTabSelected(Integer tabId, Integer selectedId) { return new Boolean(selectedId != null && selectedId.intValue() == tabId.intValue()); }
From source file:de.tor.tribes.util.PropertyHelper.java
public static void restoreTableProperties(JXTable pTable, Configuration pConfig, String pPrefix) { //set col width List<TableColumn> cols = ((TableColumnModelExt) pTable.getColumnModel()).getColumns(true); for (TableColumn c : cols) { TableColumnExt col = (TableColumnExt) c; String title = col.getTitle(); try {/* w ww . java 2 s .com*/ col.setPreferredWidth( pConfig.getInteger(pPrefix + ".table.col." + title + ".width", col.getWidth())); } catch (ConversionException ignored) { } try { col.setVisible(pConfig.getBoolean(pPrefix + ".table.col." + title + ".visible", true)); } catch (ConversionException ce) { col.setVisible(true); } } SortOrder sortOrder = SortOrder.UNSORTED; int iSortOrder = 0; try { iSortOrder = pConfig.getInteger(pPrefix + ".table.sort.order", 0); } catch (ConversionException ignored) { } switch (iSortOrder) { case 1: sortOrder = SortOrder.ASCENDING; break; case -1: sortOrder = SortOrder.DESCENDING; break; default: sortOrder = SortOrder.UNSORTED; } Boolean scroll = false; try { scroll = pConfig.getBoolean(pPrefix + ".table.horizontal.scroll", false); } catch (ConversionException ignored) { } pTable.setHorizontalScrollEnabled(scroll); Integer orderCol = 0; try { orderCol = pConfig.getInteger(pPrefix + ".table.sort.col", 0); } catch (ConversionException ignored) { } try { pTable.setSortOrder(orderCol.intValue(), sortOrder); } catch (IndexOutOfBoundsException ignored) { } }
From source file:com.lucid.touchstone.data.EnwikiDocMaker.java
/** * Returns the type of the element if defined, otherwise returns -1. This * method is useful in startElement and endElement, by not needing to compare * the element qualified name over and over. *//*from w w w .java2s. c om*/ private final static int getElementType(String elem) { Integer val = (Integer) ELEMENTS.get(elem); return val == null ? -1 : val.intValue(); }
From source file:de.pribluda.android.jsonmarshaller.JSONMarshaller.java
/** * recursively marshall to JSON/* ww w. jav a 2s. c o m*/ * * @param sink * @param object */ static void marshallRecursive(JSONObject sink, Object object) throws JSONException, InvocationTargetException, IllegalAccessException, NoSuchMethodException { // nothing to marshall if (object == null) return; // primitive object is a field and does not interes us here if (object.getClass().isPrimitive()) return; // object not null, and is not primitive - iterate through getters for (Method method : object.getClass().getMethods()) { // our getters are parameterless and start with "get" if ((method.getName().startsWith(GETTER_PREFIX) && method.getName().length() > BEGIN_INDEX || method.getName().startsWith(IS_PREFIX) && method.getName().length() > IS_LENGTH) && (method.getModifiers() & Modifier.PUBLIC) != 0 && method.getParameterTypes().length == 0 && method.getReturnType() != void.class) { // is return value primitive? Class<?> type = method.getReturnType(); if (type.isPrimitive() || String.class.equals(type)) { // it is, marshall it Object val = method.invoke(object); if (val != null) { sink.put(propertize(method.getName()), val); } continue; } else if (type.isArray()) { Object val = marshallArray(method.invoke(object)); if (val != null) { sink.put(propertize(method.getName()), val); } continue; } else if (type.isAssignableFrom(Date.class)) { Date date = (Date) method.invoke(object); if (date != null) { sink.put(propertize(method.getName()), date.getTime()); } continue; } else if (type.isAssignableFrom(Boolean.class)) { Boolean b = (Boolean) method.invoke(object); if (b != null) { sink.put(propertize(method.getName()), b.booleanValue()); } continue; } else if (type.isAssignableFrom(Integer.class)) { Integer i = (Integer) method.invoke(object); if (i != null) { sink.put(propertize(method.getName()), i.intValue()); } continue; } else if (type.isAssignableFrom(Long.class)) { Long l = (Long) method.invoke(object); if (l != null) { sink.put(propertize(method.getName()), l.longValue()); } continue; } else { // does it have default constructor? try { if (method.getReturnType().getConstructor() != null) { Object val = marshall(method.invoke(object)); if (val != null) { sink.put(propertize(method.getName()), val); } continue; } } catch (NoSuchMethodException ex) { // just ignore it here, it means no such constructor was found } } } } }
From source file:Main.java
/** * Returns a {@link Map} mapping each unique element in the given * {@link Iterable} to an {@link Integer} representing the number * of occurrences of that element in the {@link Iterable}. * <p/>// w ww.j a v a2 s . co m * Only those elements present in the Iterable will appear as * keys in the map. * * @param iterable the collection to get the cardinality map for, must not be null * @return the populated cardinality map */ public static <E> Map<E, java.lang.Integer> getCardinalityMap(final Iterable<E> iterable) { Map<E, Integer> count = new HashMap<E, Integer>(); for (Iterator<E> it = iterable.iterator(); it.hasNext();) { E obj = it.next(); Integer c = count.get(obj); if (c == null) { count.put(obj, INTEGER_ONE); } else { count.put(obj, new Integer(c.intValue() + 1)); } } return count; }
From source file:Main.java
/** * Returns a {@link Map} mapping each unique element in the given * {@link Collection} to an {@link Integer} representing the number * of occurrences of that element in the {@link Collection}. * <p>//from w w w . j av a2 s . c o m * Only those elements present in the collection will appear as * keys in the map. * * @param <O> the type of object in the returned {@link Map}. This is a super type of <I>. * @param coll the collection to get the cardinality map for, must not be null * @return the populated cardinality map */ public static <O> Map<O, Integer> getCardinalityMap(final Iterable<? extends O> coll) { final Map<O, Integer> count = new HashMap<O, Integer>(); for (final O obj : coll) { final Integer c = count.get(obj); if (c == null) { count.put(obj, Integer.valueOf(1)); } else { count.put(obj, Integer.valueOf(c.intValue() + 1)); } } return count; }
From source file:ConversionUtil.java
public static byte[] convertToByteArray(Object object) throws Exception { byte[] returnArray = null; Class clazz = object.getClass(); String clazzName = clazz.getName(); if (clazz.equals(Integer.class)) { Integer aValue = (Integer) object; int intValue = aValue.intValue(); returnArray = convertToByteArray(intValue); } else if (clazz.equals(String.class)) { String aValue = (String) object; returnArray = convertToByteArray(aValue); } else if (clazz.equals(Byte.class)) { Byte aValue = (Byte) object; byte byteValue = aValue.byteValue(); returnArray = convertToByteArray(byteValue); } else if (clazz.equals(Long.class)) { Long aValue = (Long) object; long longValue = aValue.longValue(); returnArray = convertToByteArray(longValue); } else if (clazz.equals(Short.class)) { Short aValue = (Short) object; short shortValue = aValue.shortValue(); returnArray = convertToByteArray(shortValue); } else if (clazz.equals(Boolean.class)) { Boolean aValue = (Boolean) object; boolean booleanValue = aValue.booleanValue(); returnArray = convertToByteArray(booleanValue); } else if (clazz.equals(Character.class)) { Character aValue = (Character) object; char charValue = aValue.charValue(); returnArray = convertToByteArray(charValue); } else if (clazz.equals(Float.class)) { Float aValue = (Float) object; float floatValue = aValue.floatValue(); returnArray = convertToByteArray(floatValue); } else if (clazz.equals(Double.class)) { Double aValue = (Double) object; double doubleValue = aValue.doubleValue(); returnArray = convertToByteArray(doubleValue); } else {// w w w .jav a 2 s . com throw new Exception("Cannot convert object of type " + clazzName); } return returnArray; }
From source file:com.twosigma.beaker.core.Main.java
private static int findPortBase(Integer start) { int width = 4; int tries = 0; int base = start.intValue(); while (!portRangeAvailable(base, width)) { System.out.println("Port range " + base + "-" + (base + width - 1) + " taken, searching..."); base += width;/*from w w w. ja v a 2 s . co m*/ if (tries++ > 10) { logger.error("can't find open port."); System.exit(1); } } return base; }
From source file:com.liangc.hq.base.utils.MonitorUtils.java
/** * Method findDefaultChildResourceId/*from www .ja va 2s. c om*/ * * Return the id of the first child resource type (according to * whatever order in which the BizApp lists them) for which the * parent resource has one or more defined child resources. * * @param resourceTypes a <code>List</code> of * <code>AppdefResourceTypeValue</code> objects * @param resourceCounts a <code>Map</code> of resource counts * keyed by resource type name * @return Integer */ public static Integer findDefaultChildResourceId(List resourceTypes, Map resourceCounts) { if (resourceTypes != null && resourceCounts != null) { Iterator i = resourceTypes.iterator(); while (i.hasNext()) { AppdefResourceTypeValue type = (AppdefResourceTypeValue) i.next(); Integer count = (Integer) resourceCounts.get(type.getName()); if (count != null && count.intValue() > 0) { return type.getId(); } } } return null; }
From source file:de.iteratec.iteraplan.businesslogic.exchange.common.informationflow.InformationFlowGeneralHelper.java
/** * Retrieves the label for a selected attribute * /* w ww . j ava2 s. co m*/ * @param connection * the edge (information system interface) * @param lineCaptionAttributeId * the id of the selected attribute * @return A textual description of the selected attribute to server as edge label (caption) */ public static List<String> getLabelDescrForAttribute(AttributeTypeService attributeTypeService, InformationSystemInterface connection, Integer lineCaptionAttributeId) { List<String> resultValues = new ArrayList<String>(); // exclude case that nothing has been selected (value of -1) if (GraphicalExportBaseOptions.NOTHING_SELECTED != lineCaptionAttributeId.intValue()) { AttributeType attrType = attributeTypeService.loadObjectById(lineCaptionAttributeId); HashBucketMap<AttributeType, AttributeValue> allAssignmentsMap = connection .getAttributeTypeToAttributeValues(); List<AttributeValue> allValues = allAssignmentsMap.get(attrType); if (allValues != null) { for (AttributeValue val : allValues) { resultValues.add(val.getLocalizedValueString(UserContext.getCurrentLocale())); } } } return resultValues; }