List of usage examples for java.lang Integer intValue
@HotSpotIntrinsicCandidate public int intValue()
From source file:be.roots.taconic.pricingguide.service.PDFServiceTest.java
public static void saveAndTestByteArray(byte[] fileAsByteArray, Integer numberOfPagesExpected) throws IOException, DocumentException { try {//from w w w. ja v a 2 s . c o m final byte[] clone = fileAsByteArray.clone(); assertNotNull(clone); File file = File.createTempFile( "result-" + Thread.currentThread().getStackTrace()[2].getMethodName() + "-", ".pdf"); IOUtils.write(fileAsByteArray, new FileOutputStream(file)); if (MANUAL_MODE) { LOGGER.info("Wrote test file to " + file.getAbsolutePath()); } else { assertTrue(file.exists()); assertTrue(file.length() > 0); file.delete(); } if (numberOfPagesExpected != null) { PdfReader reader = new PdfReader(clone); assertEquals(numberOfPagesExpected.intValue(), reader.getNumberOfPages()); } } catch (IOException e) { e.printStackTrace(); assertTrue(false); } }
From source file:com.aurel.track.admin.customize.category.CategoryBL.java
/** * Gets the replacement string for delete * @param node/*from w w w .j a v a 2 s . c om*/ * @param errorMessage * @param locale * @return */ static String getReplacementString(String node, String errorMessage, TPersonBean personBean, Locale locale) { CategoryTokens categoryTokens = CategoryTokens.decodeNode(node); String categoryType = categoryTokens.getCategoryType(); Integer repository = categoryTokens.getRepository(); boolean excludePrivate = false; if (repository != null && repository.intValue() != REPOSITORY_TYPE.PRIVATE) { //replacing a non-private only with a non-private: mostly correct although by user specific automail assignments the privat notification filters should not be excluded excludePrivate = true; } Integer type = categoryTokens.getType(); Integer objectID = categoryTokens.getObjectID(); String filterName = null; String replacementWarningLabel = null; String replacementFieldLabel = LocalizeUtil .getLocalizedTextFromApplicationResources("admin.customize.automail.filter.lblReplace", locale); CategoryBaseFacade categoryBaseFacade; if (type.equals(Integer.valueOf(TYPE.LEAF))) { categoryBaseFacade = CategoryFacadeFactory.getInstance().getLeafFacade(categoryType); replacementWarningLabel = replacementFieldLabel; } else { categoryBaseFacade = CategoryFacadeFactory.getInstance().getCategoryFacade(categoryType); replacementWarningLabel = LocalizeUtil.getParametrizedString("common.lbl.below", new Object[] { replacementFieldLabel, LocalizeUtil.getLocalizedTextFromApplicationResources( "admin.customize.queryFilter.lbl.category", locale), }, locale); } ILabelBean labelBean = categoryBaseFacade.getByKey(objectID); Integer projectID = null; if (repository != null && repository.intValue() == REPOSITORY_TYPE.PROJECT) { projectID = categoryBaseFacade.getProjectID(labelBean); } if (labelBean != null) { filterName = labelBean.getLabel(); } List<TreeNode> categoryTree = CategoryPickerBL.getPickerNodesEager(personBean, excludePrivate, false, null, true, projectID, objectID, locale, categoryType); return JSONUtility.createReplacementTreeJSON(true, filterName, replacementWarningLabel, replacementFieldLabel, JSONUtility.getTreeHierarchyJSON(categoryTree, false, true), errorMessage, locale); }
From source file:com.aurel.track.admin.customize.category.CategoryBL.java
/** * Get the projectID for a node by edit/* ww w . j av a 2s. c o m*/ * @param categoryType * @param repository * @param objectID * @return */ public static Integer getProjectID(String categoryType, Integer repository, Integer type, Integer objectID) { //edit: a categoryID or a leafID depending on leaf if (repository != null && repository.intValue() == REPOSITORY_TYPE.PROJECT) { ILabelBean labelBean = null; if (type != null) { switch (type.intValue()) { case TYPE.PROJECT: return objectID; case TYPE.LEAF: LeafFacade leafFacade = CategoryFacadeFactory.getInstance().getLeafFacade(categoryType); labelBean = leafFacade.getByKey(objectID); if (labelBean != null) { return leafFacade.getProjectID(labelBean); } break; case TYPE.CATEGORY: if (type.intValue() == TYPE.CATEGORY) { CategoryFacade categoryFacade = CategoryFacadeFactory.getInstance() .getCategoryFacade(categoryType); labelBean = categoryFacade.getByKey(objectID); if (labelBean != null) { return categoryFacade.getProjectID(labelBean); } } break; } } } return null; }
From source file:net.mozq.picto.core.ProcessCore.java
private static boolean setField(Calendar cal, int field, Integer amount) { if (amount == null) { return false; }/*from ww w. ja va 2s . com*/ cal.set(field, amount.intValue()); return true; }
From source file:com.github.gekoh.yagen.api.DefaultNamingStrategy.java
public static String generateShortName(String name, Integer maxLength, Integer charsPerGroup) { StringBuilder b = new StringBuilder(); int charsPg = charsPerGroup != null ? charsPerGroup : 1; int idx = 0, prevIdx = 0; while ((idx = name.indexOf('_', idx + 1)) > 0 && name.length() > idx) { b.append(name.substring(prevIdx, Math.min(Math.min(prevIdx + charsPg, name.length()), idx))); prevIdx = idx + 1;// w ww.j a va2s . com if (charsPg > 1) { b.append("_"); } } if (prevIdx > 0 && name.length() >= prevIdx) { b.append(name.substring(prevIdx, Math.min(prevIdx + charsPg, name.length()))); } if (b.length() < 1) { b.append(name); } if (maxLength != null && b.length() > maxLength) { b.delete(maxLength.intValue(), b.length()); } return b.toString(); }
From source file:edu.ku.brc.specify.dbsupport.TaskSemaphoreMgr.java
/** * @param title/*from w w w . j av a 2 s .c o m*/ * @param name * @param scope * @param increment * @return true if usage count is successfully incremented. * * Adds increment (can be a negative number) to specified semaphore. * */ private static boolean updateUsageCount(final String title, final String name, final SCOPE scope, final Integer increment) { if (isLocked(title, name, scope)) { return false; } boolean result = false; boolean inTransaction = false; DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession(); try { Timestamp now = new Timestamp(System.currentTimeMillis()); SpecifyUser user = AppContextMgr.getInstance().getClassObject(SpecifyUser.class); Discipline discipline = scope == SCOPE.Discipline ? AppContextMgr.getInstance().getClassObject(Discipline.class) : null; Collection collection = scope == SCOPE.Collection ? AppContextMgr.getInstance().getClassObject(Collection.class) : null; // Get our own copies of the Global Objects. user = user != null ? session.getData(SpecifyUser.class, "id", user.getId(), DataProviderSessionIFace.CompareType.Equals) : null; discipline = discipline != null ? session.getData(Discipline.class, "id", discipline.getId(), DataProviderSessionIFace.CompareType.Equals) : null; collection = collection != null ? session.getData(Collection.class, "id", collection.getId(), DataProviderSessionIFace.CompareType.Equals) : null; session.beginTransaction(); inTransaction = true; SpTaskSemaphore semaphore = getSemaphore(session, name, scope, discipline, collection); if (semaphore == null) { semaphore = new SpTaskSemaphore(); semaphore = new SpTaskSemaphore(); semaphore.initialize(); semaphore.setTaskName(name); semaphore.setTimestampCreated(now); semaphore.setOwner(user); semaphore.setScope((byte) scope.ordinal()); semaphore.setDiscipline(discipline); semaphore.setCollection(collection); } Integer count = semaphore.getUsageCount() == null ? 0 : semaphore.getUsageCount(); if (increment == null) { semaphore.setUsageCount(null); } else { Integer newCount = new Integer(count + increment); if (newCount.intValue() < 0) { log.error("attempt to set usage count for " + name + "to " + newCount); newCount = 0; } semaphore.setUsageCount(newCount); } session.saveOrUpdate(semaphore); session.commit(); result = true; } catch (Exception ex) { if (inTransaction) { session.rollback(); } edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(TaskSemaphoreMgr.class, ex); ex.printStackTrace(); } finally { session.close(); } return result; }
From source file:com.linkedin.pinot.tools.data.generator.StringGenerator.java
public StringGenerator(Integer cardinality) { this.cardinality = cardinality.intValue(); rand = new Random(System.currentTimeMillis()); }
From source file:ThreadIDMain.java
public int getThreadID() { Integer id = (Integer) get(); return id.intValue(); }
From source file:com.aurel.track.itemNavigator.ItemNavigatorFilterBL.java
private static MenuItem createMenuItemProjectRelease(TreeNode treeNode, boolean allowDrop, String type) { MenuItem mit = new MenuItem(); Integer objectID = Integer.parseInt(treeNode.getId()); mit.setId(ItemNavigatorBL.QUERY_TYPE.PROJECT_RELEASE + NODE_TYPE_SEPARATOR + objectID); mit.setType(type);/*from www . j ava2 s . co m*/ mit.setObjectID(objectID); mit.setName(treeNode.getLabel()); mit.setAllowDrop(allowDrop && objectID.intValue() > 0); mit.setUseFilter(true); mit.setLazyChildren(false); mit.setIconCls(treeNode.getIcon()); List<TreeNode> children = treeNode.getChildren(); if (children != null && !children.isEmpty()) { List<MenuItem> mnuChildren = createMenuItemsFromProjectNodes(children, type); mit.setChildren(mnuChildren); } return mit; }
From source file:net.mozq.picto.core.ProcessCore.java
private static boolean addField(Calendar cal, int field, Integer amount, int signum) { if (amount == null) { return false; }/*from w w w .j a v a 2 s . c o m*/ cal.add(field, signum * amount.intValue()); return true; }