List of usage examples for java.lang Integer intValue
@HotSpotIntrinsicCandidate public int intValue()
From source file:org.envirocar.app.test.dao.TrackDecoderTest.java
public void testTotalTrackCount() throws TrackRetrievalException { BasicHttpResponse response = new BasicHttpResponse(createStatusLine()); response.setHeader("Link", "<https://envirocar.org/api/stable/users/matthes/tracks?limit=1&page=7>;rel=last;type=application/json, <https://envirocar.org/api/stable/users/matthes/tracks?limit=1&page=2>;rel=next;type=application/json"); Integer count = new TrackDecoder().resolveTrackCount(response); Assert.assertTrue(count.intValue() == 7); response = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 204, "")); response.setHeader("Link", "<https://envirocar.org/api/stable/users/matthes/tracks?page=6>;rel=last"); count = new TrackDecoder().resolveTrackCount(response); Assert.assertTrue(count.intValue() == 6); }
From source file:com.aurel.track.item.ItemDetailBL.java
private static boolean editableComment(HistoryValues comment, Integer personID, boolean isProjectActive, boolean isProjectAdmin) { return isProjectActive && (isProjectAdmin || comment.getChangedByID().intValue() == personID.intValue()); }
From source file:com.occamlab.te.parsers.ImageParser.java
private static void processBufferedImage(BufferedImage buffimage, String formatName, NodeList nodes) throws Exception { HashMap<Object, Object> bandMap = new HashMap<Object, Object>(); for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { if (node.getLocalName().equals("subimage")) { Element e = (Element) node; int x = Integer.parseInt(e.getAttribute("x")); int y = Integer.parseInt(e.getAttribute("y")); int w = Integer.parseInt(e.getAttribute("width")); int h = Integer.parseInt(e.getAttribute("height")); processBufferedImage(buffimage.getSubimage(x, y, w, h), formatName, e.getChildNodes()); } else if (node.getLocalName().equals("checksum")) { CRC32 checksum = new CRC32(); Raster raster = buffimage.getRaster(); DataBufferByte buffer; if (node.getParentNode().getLocalName().equals("subimage")) { WritableRaster outRaster = raster.createCompatibleWritableRaster(); buffimage.copyData(outRaster); buffer = (DataBufferByte) outRaster.getDataBuffer(); } else { buffer = (DataBufferByte) raster.getDataBuffer(); }//from ww w . j a va 2 s .co m int numbanks = buffer.getNumBanks(); for (int j = 0; j < numbanks; j++) { checksum.update(buffer.getData(j)); } Document doc = node.getOwnerDocument(); node.appendChild(doc.createTextNode(Long.toString(checksum.getValue()))); } else if (node.getLocalName().equals("count")) { String band = ((Element) node).getAttribute("bands"); String sample = ((Element) node).getAttribute("sample"); if (sample.equals("all")) { bandMap.put(band, null); } else { HashMap<Object, Object> sampleMap = (HashMap<Object, Object>) bandMap.get(band); if (sampleMap == null) { if (!bandMap.containsKey(band)) { sampleMap = new HashMap<Object, Object>(); bandMap.put(band, sampleMap); } } sampleMap.put(Integer.decode(sample), new Integer(0)); } } else if (node.getLocalName().equals("transparentNodata")) { // 2011-08-24 // PwD String transparentNodata = checkTransparentNodata(buffimage, node); node.setTextContent(transparentNodata); } } } Iterator bandIt = bandMap.keySet().iterator(); while (bandIt.hasNext()) { String band_str = (String) bandIt.next(); int band_indexes[]; if (buffimage.getType() == BufferedImage.TYPE_BYTE_BINARY || buffimage.getType() == BufferedImage.TYPE_BYTE_GRAY) { band_indexes = new int[1]; band_indexes[0] = 0; } else { band_indexes = new int[band_str.length()]; for (int i = 0; i < band_str.length(); i++) { if (band_str.charAt(i) == 'A') band_indexes[i] = 3; if (band_str.charAt(i) == 'B') band_indexes[i] = 2; if (band_str.charAt(i) == 'G') band_indexes[i] = 1; if (band_str.charAt(i) == 'R') band_indexes[i] = 0; } } Raster raster = buffimage.getRaster(); java.util.HashMap sampleMap = (java.util.HashMap) bandMap.get(band_str); boolean addall = (sampleMap == null); if (sampleMap == null) { sampleMap = new java.util.HashMap(); bandMap.put(band_str, sampleMap); } int minx = raster.getMinX(); int maxx = minx + raster.getWidth(); int miny = raster.getMinY(); int maxy = miny + raster.getHeight(); int bands[][] = new int[band_indexes.length][raster.getWidth()]; for (int y = miny; y < maxy; y++) { for (int i = 0; i < band_indexes.length; i++) { raster.getSamples(minx, y, maxx, 1, band_indexes[i], bands[i]); } for (int x = minx; x < maxx; x++) { int sample = 0; for (int i = 0; i < band_indexes.length; i++) { sample |= bands[i][x] << ((band_indexes.length - i - 1) * 8); } Integer sampleObj = new Integer(sample); boolean add = addall; if (!addall) { add = sampleMap.containsKey(sampleObj); } if (add) { Integer count = (Integer) sampleMap.get(sampleObj); if (count == null) { count = new Integer(0); } count = new Integer(count.intValue() + 1); sampleMap.put(sampleObj, count); } } } } Node node = nodes.item(0); while (node != null) { if (node.getNodeType() == Node.ELEMENT_NODE) { if (node.getLocalName().equals("count")) { String band = ((Element) node).getAttribute("bands"); String sample = ((Element) node).getAttribute("sample"); HashMap sampleMap = (HashMap) bandMap.get(band); Document doc = node.getOwnerDocument(); if (sample.equals("all")) { Node parent = node.getParentNode(); Node prevSibling = node.getPreviousSibling(); Iterator sampleIt = sampleMap.keySet().iterator(); Element countnode = null; int digits; String prefix; switch (buffimage.getType()) { case BufferedImage.TYPE_BYTE_BINARY: digits = 1; prefix = ""; break; case BufferedImage.TYPE_BYTE_GRAY: digits = 2; prefix = "0x"; break; default: prefix = "0x"; digits = band.length() * 2; } while (sampleIt.hasNext()) { countnode = doc.createElementNS(node.getNamespaceURI(), "count"); Integer sampleInt = (Integer) sampleIt.next(); Integer count = (Integer) sampleMap.get(sampleInt); if (band.length() > 0) { countnode.setAttribute("bands", band); } countnode.setAttribute("sample", prefix + HexString(sampleInt.intValue(), digits)); Node textnode = doc.createTextNode(count.toString()); countnode.appendChild(textnode); parent.insertBefore(countnode, node); if (sampleIt.hasNext()) { if (prevSibling != null && prevSibling.getNodeType() == Node.TEXT_NODE) { parent.insertBefore(prevSibling.cloneNode(false), node); } } } parent.removeChild(node); node = countnode; } else { Integer count = (Integer) sampleMap.get(Integer.decode(sample)); if (count == null) count = new Integer(0); Node textnode = doc.createTextNode(count.toString()); node.appendChild(textnode); } } } node = node.getNextSibling(); } }
From source file:Producer.java
synchronized int remove() { while (count == 0) { try {//from w ww. ja v a 2 s . c om wait(); } catch (InterruptedException ie) { ie.printStackTrace(); System.exit(0); } } Integer iobj = (Integer) queue.firstElement(); queue.removeElement(iobj); --count; notifyAll(); return iobj.intValue(); }
From source file:com.seabee.snapdragon.service.CustomUserDetailsService.java
public List<String> getRoles(Integer role) { List<String> roles = new ArrayList<String>(); if (role.intValue() == 1) { roles.add("POSTER"); roles.add("MODERATOR"); roles.add("ADMIN"); } else if (role.intValue() == 2) { roles.add("POSTER"); roles.add("MODERATOR"); } else if (role.intValue() == 3) { roles.add("POSTER"); }/*from w ww . jav a 2 s . c o m*/ return roles; }
From source file:fi.csc.kapaVirtaAS.VirtaClient.java
public VirtaClient(ASConfiguration conf) { cm = new PoolingHttpClientConnectionManager(); Integer poolSize = new Integer(conf.getAdapterServiceConnectionPoolSize()); cm.setMaxTotal(poolSize != null ? poolSize.intValue() : 10); client = HttpClients.custom().setConnectionManager(cm).build(); }
From source file:jp.co.acroquest.endosnipe.report.converter.util.calc.IntegerCalculator.java
public Object add(Object obj1, Object obj2) { Integer intData1 = (Integer) obj1; Integer intData2 = (Integer) obj2; return (Object) (new Integer((int) (intData1.intValue() + intData2.intValue()))); }
From source file:jp.co.acroquest.endosnipe.report.converter.util.calc.IntegerCalculator.java
public Object div(Object obj1, Object obj2) { Integer intData1 = (Integer) obj1; Integer intData2 = (Integer) obj2; return (Object) (new Integer((int) (intData1.intValue() / intData2.intValue()))); }
From source file:jp.co.acroquest.endosnipe.report.converter.util.calc.IntegerCalculator.java
public Object mul(Object obj1, Object obj2) { Integer intData1 = (Integer) obj1; Integer intData2 = (Integer) obj2; return (Object) (new Integer((int) (intData1.intValue() * intData2.intValue()))); }
From source file:jp.co.acroquest.endosnipe.report.converter.util.calc.IntegerCalculator.java
public Object sub(Object obj1, Object obj2) { Integer intData1 = (Integer) obj1; Integer intData2 = (Integer) obj2; return (Object) (new Integer((int) (intData1.intValue() - intData2.intValue()))); }