List of usage examples for java.lang Integer MAX_VALUE
int MAX_VALUE
To view the source code for java.lang Integer MAX_VALUE.
Click Source Link
From source file:com.espertech.esperio.db.core.DBUtil.java
private static byte[] getBlobValue(Blob blob) throws SQLException { if (blob == null) { return null; }//w w w. java2s . c o m if (blob.length() > Integer.MAX_VALUE) { log.warn("Blob truncated: value larger then Integer.MAX_VALUE bytes:" + blob.length()); return null; } int len = (int) blob.length(); return blob.getBytes(1, len); }
From source file:Main.java
/** * Copy bytes from an <code>InputStream</code> to an * <code>OutputStream</code>. * <p>/*from ww w.j ava2s. c om*/ * This method buffers the input internally, so there is no need to use a * <code>BufferedInputStream</code>. * <p> * Large streams (over 2GB) will return a bytes copied value of * <code>-1</code> after the copy has completed since the correct number of * bytes cannot be returned as an int. For large streams use the * <code>copyLarge(InputStream, OutputStream)</code> method. * * @param input * the <code>InputStream</code> to read from * @param output * the <code>OutputStream</code> to write to * @return the number of bytes copied * @throws NullPointerException * if the input or output is null * @throws IOException * if an I/O error occurs * @throws ArithmeticException * if the byte count is too large */ public static int copy(InputStream input, OutputStream output) throws IOException { long count = copyLarge(input, output); if (count > Integer.MAX_VALUE) { return -1; } return (int) count; }
From source file:de.nava.informa.utils.AtomParserUtils.java
/** * Looks for link sub-elements of type "link" and selects the most preferred. * * @param item item element.//w w w . j a v a 2 s . co m * @param defNS default namespace. * @return link in string or <code>null</code>. */ public static String getItemLink(Element item, Namespace defNS) { String currentHref = null; int currentOrder = Integer.MAX_VALUE; List links = item.getChildren("link", defNS); for (int i = 0; (currentOrder != 0) && (i < links.size()); i++) { Element link = (Element) links.get(i); // get type of the link String type = link.getAttributeValue("type"); String rel = link.getAttributeValue("rel"); if (type != null) { type = type.trim().toLowerCase(); } // if we prefer this type more than the one we already have then // replace current href with new one and update preference order // value. int preferenceOrder = getPreferenceOrderForItemLinkType(type, rel); LOGGER.info("Link " + link.getAttributeValue("href") + " with pref " + getPreferenceOrderForItemLinkType(type, rel) + " " + type + " " + rel); if (preferenceOrder < currentOrder) { String href = link.getAttributeValue("href"); if (href != null) { currentHref = href.trim(); currentOrder = preferenceOrder; } } } LOGGER.debug("url read : " + currentHref); return currentHref; }
From source file:ardufocuser.starfocusing.Utils.java
/** * Calcula valores de luz maximos y minimos de la regin de la matriz imagen delimitada por startX - endX y startY- endY .. *//*from w ww . j a v a 2 s .co m*/ public static int[] computeMinMax(int[][] pixels, int startX, int startY, int endX, int endY) { int min = Integer.MIN_VALUE; int max = Integer.MAX_VALUE; for (int x = startX; x < endX; x++) { for (int y = startY; y < endY; y++) { if (min > pixels[x][y]) { min = pixels[x][y]; } if (max < pixels[x][y]) { max = pixels[x][y]; } } } return new int[] { min, max }; }
From source file:Main.java
private static int findBestMajTickSpace(int sliderSize, int delta) { final int values[] = { 1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, 5000 }; // wanted a major tick each ~40 pixels final int wantedMajTickSpace = delta / (sliderSize / 40); int min = Integer.MAX_VALUE; int bestValue = 1; // try with our predefined values for (int value : values) { final int dx = Math.abs(value - wantedMajTickSpace); if (dx < min) { min = dx;// w w w .j av a 2 s. c o m bestValue = value; } } return bestValue; }
From source file:org.vaadin.peholmst.samples.dddwebinar.domain.doctors.LicenseService.java
public Optional<License> selectBestLicense(Collection<Procedure> procedures, Collection<License> licenses) { Set<License> availableLicenses = licenses.stream().filter( l -> procedures.stream().allMatch(p -> p.getCategory().getLicenseTypes().containsKey(l.getType()))) .collect(Collectors.toSet()); if (availableLicenses.isEmpty()) { return Optional.empty(); } else {// w w w .j a v a 2 s.co m License best = null; int bestRank = Integer.MAX_VALUE; for (License l : availableLicenses) { for (Procedure p : procedures) { int rank = p.getCategory().getLicenseTypes().get(l.getType()); if (rank < bestRank) { bestRank = rank; best = l; } } } return Optional.ofNullable(best); } }
From source file:com.repaskys.domain.ShortUrl.java
/** * Helper method.//from w w w .j a v a 2 s . c o m * * @see http://stackoverflow.com/questions/1590831/safely-casting-long-to-int-in-java */ private static int safeLongToInt(long l) { if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) { throw new IllegalArgumentException(l + " cannot be cast to int without changing its value."); } return (int) l; }
From source file:edu.umd.cs.buildServer.util.IO.java
/** * Copy all data from an input stream to an output stream. * * @param in/*from w w w . ja v a 2s . c om*/ * the InputStream * @param out * the OutputStream * @throws IOException * if an IO error occurs */ public static void copyStream(InputStream in, OutputStream out) throws IOException { copyStream(in, out, Integer.MAX_VALUE); }
From source file:com.shmsoft.dmass.services.Util.java
public static byte[] getBytesFromFile(File file) throws IOException { InputStream is = new FileInputStream(file); // Get the size of the file long length = file.length(); // You cannot create an array using a long type. // It needs to be an int type. // Before converting to an int type, check // to ensure that file is not larger than Integer.MAX_VALUE. if (length > Integer.MAX_VALUE) { throw new RuntimeException(file.getName() + " is too large"); }// ww w. j a v a 2 s . com // Create the byte array to hold the data byte[] bytes = new byte[(int) length]; // Read in the bytes int offset = 0; int numRead = 0; while (offset < bytes.length && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) { offset += numRead; } // Ensure all the bytes have been read in if (offset < bytes.length) { throw new IOException("Could not completely read file " + file.getName()); } // Close the input stream and return bytes is.close(); return bytes; }
From source file:com.evolveum.midpoint.model.common.stringpolicy.StringPolicyUtils.java
public static StringPolicyType normalize(StringPolicyType sp) { if (null == sp) { throw new IllegalArgumentException("Providide string policy cannot be null"); }/* ww w . j a va 2s . c o m*/ if (null == sp.getLimitations()) { LimitationsType sl = new LimitationsType(); sl.setCheckAgainstDictionary(false); sl.setCheckPattern(""); sl.setMaxLength(Integer.MAX_VALUE); sl.setMinLength(0); sl.setMinUniqueChars(0); sp.setLimitations(sl); } // Add default char class if (null == sp.getCharacterClass()) { CharacterClassType cct = new CharacterClassType(); cct.setValue(ASCII7_CHARS); sp.setCharacterClass(cct); } return sp; }