List of usage examples for java.lang Integer intValue
@HotSpotIntrinsicCandidate public int intValue()
From source file:de.crowdcode.bitemporal.example.PersonTest.java
@Test public void testEmptyAddresses() { // Some address objects because we don't make a rollback Integer amountOfAddress = addressService.getAmountOfAddress(); assertEquals(4, amountOfAddress.intValue()); }
From source file:org.horizontaldb.shard.hibernate.advise.TenantContextEnricherAspect.java
private void increaseFrameCount() { Integer count = frameCounter.get(); if (count == null) { count = new Integer(0); } else {//from w ww . j av a 2 s . c o m count = count.intValue() + 1; } frameCounter.set(count); }
From source file:com.prowidesoftware.swift.model.SwiftBlock5.java
/** * Sets the block number. Will cause an exception unless setting block number to 5. * @param blockNumber the block number to set * @throws IllegalArgumentException if parameter blockName is not the integer 5 * @since 5.0// w w w.ja v a2s.co m */ protected void setBlockNumber(final Integer blockNumber) { // sanity check Validate.notNull(blockNumber, "parameter 'blockNumber' cannot be null"); Validate.isTrue(blockNumber.intValue() == 5, "blockNumber must be 5"); }
From source file:org.olat.modules.tu.TunnelController.java
/** * Constructor for a tunnel component wrapper controller * @param ureq/*from w ww .j a va 2 s . co m*/ * @param config the module configuration */ public TunnelController(UserRequest ureq, WindowControl wControl, ModuleConfiguration config) { super(wControl); this.config = config; Translator trans = Util.createPackageTranslator(TunnelController.class, ureq.getLocale()); main = new VelocityContainer("tucMain", VELOCITY_ROOT + "/index.html", trans, null); String user = (String) config.get(TUConfigForm.CONFIGKEY_USER); String pass = (String) config.get(TUConfigForm.CONFIGKEY_PASS); String host = (String) config.get(TUConfigForm.CONFIGKEY_HOST); Integer port = (Integer) config.get(TUConfigForm.CONFIGKEY_PORT); httpClientInstance = HttpClientFactory.getHttpClientInstance(host, port.intValue(), user, pass, true); tuc = new TunnelComponent("tuc", config, httpClientInstance, ureq); main.put("tuc", tuc); setInitialComponent(main); }
From source file:com.aurel.track.item.PrintItemDetailsBL.java
/** * The big difference relative to other FlatHistoryBean of RENDER_TYPE=ACTUAL_VALUES is that * some of HistoryEntries of FlatHistoryBean have oldValue set which means special handling in jsp: * either rendering a image or create a link for attachment * @param attachmentBeans//from w ww. j a va2s . co m * @param locale * @return */ private static List<FlatHistoryBean> loadAttachmentFlatHistoryBeans(List<TAttachmentBean> attachmentBeans, Map<Integer, TWorkItemBean> workItemBeansMap, Locale locale, boolean withChildren) { List<FlatHistoryBean> flatValueList = new ArrayList<FlatHistoryBean>(); Integer stretchPercent = null; Integer maxWidth = null; Integer maxHeight = null; Properties properties = loadConfigFromFile(); stretchPercent = getConfigByName(properties, "stretchPercent", 100); maxWidth = getConfigByName(properties, "maxWidth", 500); maxHeight = getConfigByName(properties, "maxHeight", 500); if (attachmentBeans != null) { for (TAttachmentBean attachmentBean : attachmentBeans) { FlatHistoryBean flatHistoryBean = new FlatHistoryBean(); List<HistoryEntry> historyEntries = new ArrayList<HistoryEntry>(); flatHistoryBean.setHistoryEntries(historyEntries); flatHistoryBean.setChangedByName(attachmentBean.getChangedByName()); flatHistoryBean.setPersonID(attachmentBean.getChangedBy()); flatHistoryBean.setLastEdit(attachmentBean.getLastEdit()); flatHistoryBean.setType(HistoryBean.HISTORY_TYPE.ATTACHMENT); flatHistoryBean.setIconName("attachment.png"); HistoryLoaderBL.addWorkItemToFlatHistoryBean(flatHistoryBean, workItemBeansMap, attachmentBean.getWorkItem(), FlatHistoryBean.RENDER_TYPE.ACTUAL_VALUES); flatHistoryBean.setWorkItemID(attachmentBean.getWorkItem()); HistoryEntry historyEntry = new HistoryEntry(); /*render the attachmnet download: historyEntry.fieldLabel -> Name historyEntry.newValue -> the fileName historyEntry.oldValue -> attachmentID: the value is used in the URL */ historyEntry.setFieldLabel( LocalizeUtil.getLocalizedTextFromApplicationResources("common.lbl.name", locale)); historyEntry.setNewValue(attachmentBean.getFileName()); historyEntry.setOldValue(attachmentBean.getObjectID().toString()); historyEntries.add(historyEntry); if (!withChildren) { historyEntry = new HistoryEntry(); historyEntry.setFieldLabel( LocalizeUtil.getLocalizedTextFromApplicationResources("common.lbl.size", locale)); historyEntry.setNewValue(TAttachmentBean.getFileSizeString(attachmentBean.getSize())); historyEntries.add(historyEntry); String description = attachmentBean.getDescription(); if (description != null && !"".equals(description)) { historyEntry = new HistoryEntry(); historyEntry.setFieldLabel(LocalizeUtil .getLocalizedTextFromApplicationResources("common.lbl.description", locale)); historyEntry.setNewValue(description); historyEntries.add(historyEntry); } } boolean isImage = AttachBL.isImage(attachmentBean); if (isImage) { /*render the image: historyEntry.fieldLabel -> null historyEntry.newValue -> image width (in pixels) historyEntry.oldValue -> attachmentID: used in the URL */ TAttachmentBean attachmentBeanPopulated = AttachBL.loadAttachment(attachmentBean.getObjectID(), attachmentBean.getWorkItem(), true); String fileNameOnDisk = attachmentBeanPopulated.getFullFileNameOnDisk(); File f = new File(fileNameOnDisk); BufferedImage image; Integer originalWidth = null; Integer originalHeight = null; try { image = ImageIO.read(f); originalWidth = image.getWidth(); originalHeight = image.getHeight(); } catch (IOException e) { LOGGER.warn("Reading the image failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } if (fileNameOnDisk != null && !"".equals(fileNameOnDisk)) { historyEntry = new HistoryEntry(); if (originalWidth != null && originalHeight != null) { Integer calculatedWidth = Integer .valueOf(originalWidth.intValue() * stretchPercent / 100); Integer calculatedHeight = Integer .valueOf(originalHeight.intValue() * stretchPercent / 100); if (calculatedWidth.intValue() > maxWidth.intValue() && calculatedHeight.intValue() > maxHeight.intValue()) { double widthScale = calculatedWidth.doubleValue() / maxWidth.doubleValue(); double heightScale = calculatedHeight.doubleValue() / maxHeight.doubleValue(); if (widthScale > heightScale) { calculatedWidth = maxWidth; } else { calculatedWidth = Integer.valueOf((int) (calculatedWidth.doubleValue() * maxHeight.doubleValue() / calculatedHeight.doubleValue())); } } else { if (calculatedWidth.intValue() > maxWidth.intValue()) { calculatedWidth = maxWidth; } else { if (calculatedHeight.intValue() > maxHeight.intValue()) { calculatedWidth = Integer.valueOf((int) (calculatedWidth.doubleValue() * maxHeight.doubleValue() / calculatedHeight.doubleValue())); } } } historyEntry.setNewValue(calculatedWidth.toString()); } historyEntry.setOldValue(attachmentBean.getObjectID().toString()); historyEntries.add(historyEntry); } } flatValueList.add(flatHistoryBean); } } return flatValueList; }
From source file:com.diffeo.dossier.fc.StringCounter.java
/** * Add some value to the count for a key. * * If the key is not already contained in the collection, add * it as though its count was previously 0. This can raise an * exception of the collection is read-only. * * @param key String key to update//from ww w.j a v a2s .c o m * @param n Amount to add to the count */ public void add(String key, int n) { Map<String, Integer> s = getStrings(); int count = 0; Integer oldCount = s.get(key); if (oldCount != null) { count = oldCount.intValue(); } count += n; s.put(key, new Integer(count)); }
From source file:com.agiletec.plugins.jpblog.aps.tags.util.BlogPagerTagHelper.java
private int getCurrentFrame(RequestContext reqCtx) { Integer frame = (Integer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME); int currentFrame = frame.intValue(); return currentFrame; }
From source file:com.prowidesoftware.swift.model.SwiftBlock3.java
/** * Sets the block number. Will cause an exception unless setting block number to 3. * @param blockNumber the block number to set * @throws IllegalArgumentException if parameter blockName is not the integer 3 * @since 5.0//w w w . jav a2s . co m */ protected void setBlockNumber(final Integer blockNumber) { // sanity check Validate.notNull(blockNumber, "parameter 'blockNumber' cannot be null"); Validate.isTrue(blockNumber.intValue() == 3, "blockNumber must be 3"); }
From source file:com.microsoft.tfs.core.clients.workitem.internal.link.RelatedLinkDescriptionUpdater.java
@Override public void run() { if (idsToLinks.size() == 0) { /*//from www. ja v a 2 s.c o m * nothing to do */ return; } final BatchReadParameterCollection batchReadParams = new BatchReadParameterCollection(); for (final Iterator it = idsToLinks.keySet().iterator(); it.hasNext();) { final Integer id = (Integer) it.next(); batchReadParams.add(new BatchReadParameter(id.intValue())); } try { final StringBuffer sb = new StringBuffer(); sb.append("SELECT "); //$NON-NLS-1$ for (int i = 0; i < fieldReferenceNames.length; i++) { if (i > 0) { sb.append(", "); //$NON-NLS-1$ } sb.append("["); //$NON-NLS-1$ sb.append(fieldReferenceNames[i]); sb.append("]"); //$NON-NLS-1$ } sb.append(" FROM WorkItems"); //$NON-NLS-1$ final WorkItemCollection queryResults = witContext.getClient().query(sb.toString(), batchReadParams); for (int i = 0; i < queryResults.size(); i++) { final WorkItem workItem = queryResults.getWorkItem(i); final Integer id = new Integer(workItem.getFields().getID()); final String description = WorkItemLinkUtils.buildDescriptionFromWorkItem(workItem); final ArrayList links = (ArrayList) idsToLinks.get(id); for (int linkIndex = 0; linkIndex < links.size(); linkIndex++) { final RelatedLinkImpl relatedLink = (RelatedLinkImpl) links.get(linkIndex); relatedLink.setDescription(description); relatedLink.setWorkItem(workItem); // Touch each required field to ensure computed fields are // properly setup. // For example, a query for AREA_PATH returns only the // AreaId field. A call // to getValue causes the actual area path field to be // created. for (int j = 0; j < fieldReferenceNames.length; j++) { workItem.getFields().getField(fieldReferenceNames[j]).getValue(); } } } } catch (final Throwable t) { if (errorCallback != null) { errorCallback.onDescriptionUpdateError(t); } else { log.error(t); } } }
From source file:net.sourceforge.fenixedu.domain.SchoolClass.java
@Override public void setAnoCurricular(Integer anoCurricular) { if (anoCurricular == null || anoCurricular.intValue() < 1) { throw new DomainException("error.SchoolClass.invalid.curricularYear"); }// w w w .j a v a 2 s. c om super.setAnoCurricular(anoCurricular); }