List of usage examples for java.lang Integer MIN_VALUE
int MIN_VALUE
To view the source code for java.lang Integer MIN_VALUE.
Click Source Link
From source file:com.github.rvesse.airline.restrictions.factories.RangeRestrictionFactory.java
protected RangeRestriction createIntegerRange(Annotation annotation) { IntegerRange iRange = (IntegerRange) annotation; return new RangeRestriction( iRange.min() != Integer.MIN_VALUE || !iRange.minInclusive() ? Integer.valueOf(iRange.min()) : null, iRange.minInclusive(),//w w w . j a v a 2 s . c om iRange.max() != Integer.MAX_VALUE || !iRange.maxInclusive() ? Integer.valueOf(iRange.max()) : null, iRange.maxInclusive(), INTEGER_COMPARATOR); }
From source file:com.milaboratory.core.alignment.KMapper.java
/** * Searches for the best offset (with highest number of occurrences) in the sorted array of votes. *//*w ww .ja v a2 s . c o m*/ static int getBestOffset(IntArrayList offsets, int except, int shift, int maxOffsetDelta) { if (offsets.size() == 1) return offsets.get(0) >> shift; int current, old = Integer.MAX_VALUE >> 2, maxOffset = Integer.MIN_VALUE, maxCount = 0, lastMaxIndex = offsets.size() - 1; int[] counters = new int[maxOffsetDelta + 1]; for (int i = offsets.size() - 1; i >= 0; --i) { current = offsets.get(i) >> shift; if (old - current > maxOffsetDelta) { if (maxCount < lastMaxIndex - i && old != except) { maxOffset = old - maxIndex(counters); maxCount = lastMaxIndex - i; } old = current; lastMaxIndex = i; Arrays.fill(counters, 0); } counters[old - current]++; } if (maxCount < lastMaxIndex + 1 && old != except) maxOffset = old - maxIndex(counters); assert maxOffset != Integer.MAX_VALUE >> 2 && maxOffset != Integer.MIN_VALUE; return maxOffset; }
From source file:edu.cornell.med.icb.optimization.OptimizeSubSet.java
/** * Creates a chromosome that encodes the optimization problem. * * @param set The set of values from which solutions will be chosen. * @return A valid JGAP chromosome./*from w ww.java 2s. c om*/ * @throws InvalidConfigurationException If any error occurs creating the chromosome. */ private IChromosome setupChromosome(final int[] set) throws InvalidConfigurationException { subsetGenes = new Gene[k]; int minElementValue = Integer.MAX_VALUE; int maxElementValue = Integer.MIN_VALUE; for (final int element : set) { minElementValue = Math.min(element, minElementValue); maxElementValue = Math.max(element, maxElementValue); } for (int g = 0; g < k; g++) { subsetGenes[g] = new IntegerGene(configuration, 0, numElementsInSet - 1); } final Gene[] genes = new Gene[1 + getNumberOfParameters()]; final AbstractSupergene constrainedGenes = new SubsetSuperGene(configuration, subsetGenes, this.allElements); genes[0] = constrainedGenes; for (int paramIndex = 0; paramIndex < getNumberOfParameters(); paramIndex++) { genes[1 + paramIndex] = new IntegerGene(configuration, 0, this.allPossibleParameterValues[paramIndex].length - 1); } subsetChromosome = new Chromosome(configuration, genes); return subsetChromosome; }
From source file:com.redhat.lightblue.ResponseTest.java
@Test public void testBuildResponse() { response.setStatus(OperationStatus.COMPLETE); response.setModifiedCount(Integer.MAX_VALUE); response.setMatchCount(Integer.MIN_VALUE); response.setTaskHandle("taskHandle"); response.setSessionInfo(null);/*from w w w. j a v a2 s . co m*/ response.setEntityData(null); response.getDataErrors().addAll(new ArrayList<DataError>()); response.getErrors().addAll(new ArrayList<Error>()); ResponseBuilder responseBuilder = new Response.ResponseBuilder(response); assertTrue(response.getStatus().equals(responseBuilder.buildResponse().getStatus())); }
From source file:gobblin.source.extractor.extract.jdbc.MysqlExtractor.java
@Override public List<Command> getDataMetadata(String schema, String entity, WorkUnit workUnit, List<Predicate> predicateList) throws DataRecordException { log.debug("Build query to extract data"); List<Command> commands = new ArrayList<>(); int fetchsize = Integer.MIN_VALUE; String watermarkFilter = this.concatPredicates(predicateList); String query = this.getExtractSql(); if (StringUtils.isBlank(watermarkFilter)) { watermarkFilter = "1=1"; }/*from w ww .j a v a 2s . co m*/ query = query.replace(ConfigurationKeys.DEFAULT_SOURCE_QUERYBASED_WATERMARK_PREDICATE_SYMBOL, watermarkFilter); String sampleFilter = this.constructSampleClause(); query = query + sampleFilter; commands.add(JdbcExtractor.getCommand(query, JdbcCommand.JdbcCommandType.QUERY)); commands.add(JdbcExtractor.getCommand(fetchsize, JdbcCommand.JdbcCommandType.FETCHSIZE)); return commands; }
From source file:com.github.veqryn.net.Cidr4.java
/** * Constructor that takes a integer value for address and the * number of mask bits for the cidr range * * @param address Low value of CIDR range * @param binary false if using a sortable packed integer, * where Integer.MIN_VALUE = 0.0.0.0 * and 0 = 128.0.0.0/*from w ww .j ava2s. c o m*/ * and Integer.MAX_VALUE = 255.255.255.255<br> * true if using a binary integer, * where Integer.MIN_VALUE = 128.0.0.0 * and 0 = 0.0.0.0 * and Integer.MAX_VALUE = 127.255.255.255 * and -1 = 255.255.255.255 * @param maskBits e.g. 32 */ protected Cidr4(int address, final boolean binary, final int maskBits) { address = binary ? address : address ^ Integer.MIN_VALUE; final int netmask = getNetMask(rangeCheck(maskBits, 0, NBITS)); final int network = getLowestBinaryWithNetmask(address, netmask); this.low = network ^ Integer.MIN_VALUE; this.high = getHighestBinaryWithNetmask(network, netmask) ^ Integer.MIN_VALUE; }
From source file:edu.ku.brc.specify.toycode.mexconabio.MakeGBIFProcessHash.java
@Override public void process(final int type, final int options) { final double HRS = 1000.0 * 60.0 * 60.0; final long PAGE_CNT = 1000000; totalRecs = BasicSQLUtils.getCount(dbGBIFConn, "SELECT COUNT(*) FROM raw"); int minIndex = BasicSQLUtils.getCount(dbGBIFConn, "SELECT MIN(id) FROM raw"); //int maxIndex = BasicSQLUtils.getCount(dbGBIFConn, "SELECT MAX(id) FROM raw"); int segs = (int) (totalRecs / PAGE_CNT) + 1; try {/*from ww w . j a va 2s . c om*/ pw = new PrintWriter("GroupHash.log"); } catch (FileNotFoundException e) { e.printStackTrace(); } long procRecs = 0; long startTime = System.currentTimeMillis(); int secsThreshold = 0; try { String idsInsert = "INSERT INTO group_hash_ids (GrpID, RawID) VALUES (?,?)"; insertIds = dbDstConn.prepareStatement(idsInsert); String gbifsnibInsert = "INSERT INTO group_hash (collnum, genus, year, mon, cnt) VALUES (?,?,?,?,?)"; insertStmt = dbDstConn.prepareStatement(gbifsnibInsert); String gbifsnibUpdate = "UPDATE group_hash SET cnt=? WHERE id = ?"; updateStmt = dbDstConn.prepareStatement(gbifsnibUpdate); String gbifsnibCheck = "SELECT id FROM group_hash WHERE collnum=? AND genus=? AND year=?"; checkStmt = dbDstConn.prepareStatement(gbifsnibCheck); } catch (SQLException ex) { ex.printStackTrace(); } for (int pc = 0; pc < segs; pc++) { try { String clause = String.format(" FROM raw WHERE id > %d AND id < %d", (pc * PAGE_CNT) + minIndex, ((pc + 1) * PAGE_CNT) + minIndex + 1); String gbifSQL = "SELECT id, collector_num, genus, year, month " + clause; System.out.println(gbifSQL); pw.println(gbifSQL); stmt = dbGBIFConn.createStatement(ResultSet.FETCH_FORWARD, ResultSet.CONCUR_READ_ONLY); stmt.setFetchSize(Integer.MIN_VALUE); String msg = "Starting Query... " + totalRecs; System.out.println(msg); pw.println(msg); ResultSet rs = stmt.executeQuery(gbifSQL); msg = String.format("Starting Processing... Total Records %d Max Score: %d Threshold: %d", totalRecs, maxScore, thresholdScore); System.out.println(msg); pw.println(msg); while (rs.next()) { procRecs++; String year = rs.getString(4); year = StringUtils.isNotEmpty(year) ? year.trim() : null; if (StringUtils.isNotEmpty(year) && !StringUtils.isNumeric(year)) { continue; } int rawId = rs.getInt(1); String collnum = rs.getString(2); String genus = rs.getString(3); String mon = rs.getString(5); collnum = StringUtils.isNotEmpty(collnum) ? collnum.trim() : null; genus = StringUtils.isNotEmpty(genus) ? genus.trim() : null; mon = StringUtils.isNotEmpty(mon) ? mon.trim() : null; int c = 0; if (collnum == null) c++; if (genus == null) c++; if (year == null) c++; if (c == 2) { continue; } collnum = collnum != null ? collnum : ""; genus = genus != null ? genus : ""; year = year != null ? year : ""; mon = mon != null ? mon : ""; if (collnum.length() > 64) { collnum = collnum.substring(0, 63); } if (genus.length() > 64) { genus = genus.substring(0, 63); } if (year.length() > 8) { year = year.substring(0, 8); } if (mon.length() > 8) { mon = year.substring(0, 8); } String name = String.format("%s_%s_%s", collnum, genus, year); DataEntry de = groupHash.get(name); if (de != null) { de.cnt++; } else { de = getDataEntry(collnum, genus, year, mon); groupHash.put(name, de); } de.ids.add(rawId); if (groupHash.size() > MAX_RECORDS_SEG) { writeHash(); } } rs.close(); if (groupHash.size() > 0) { writeHash(); } System.out.println("Done with seg " + pc); pw.println("Done with seg " + pc); } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (stmt != null) { stmt.close(); } } catch (Exception ex) { } } long endTime = System.currentTimeMillis(); long elapsedTime = endTime - startTime; double timePerRecord = (elapsedTime / procRecs); double hrsLeft = ((totalRecs - procRecs) * timePerRecord) / HRS; int seconds = (int) (elapsedTime / 60000.0); if (secsThreshold != seconds) { secsThreshold = seconds; String msg = String.format("Elapsed %8.2f hr.mn Percent: %6.3f Hours Left: %8.2f ", ((double) (elapsedTime)) / HRS, 100.0 * ((double) procRecs / (double) totalRecs), hrsLeft); System.out.println(msg); pw.println(msg); pw.flush(); } } try { if (insertStmt != null) { insertStmt.close(); } if (updateStmt != null) { updateStmt.close(); } if (checkStmt != null) { checkStmt.close(); } } catch (SQLException ex) { ex.printStackTrace(); } String msg = String.format("Done - Writes: %d Updates: %d", writeCnt, updateCnt); System.out.println(msg); pw.println(msg); pw.flush(); pw.close(); }
From source file:org.activiti.rest.util.ActivitiWebScript.java
/** * Gets a mandatory int parameter and throws an exception if its not present. * * @param req The webscript request/*from w ww . j a v a 2s . c o m*/ * @param param The name of the path parameter * @return The int parameter value * @throws WebScriptException if parameter isn't present */ protected int getMandatoryInt(WebScriptRequest req, String param) { String value = getMandatoryString(req, param); return value != null ? Integer.parseInt(value) : Integer.MIN_VALUE; }
From source file:com.linkedin.cubert.memory.CompactHashTableBase.java
private int getValidHashCode(DimensionKey key) { int h = key.hashCode(); if (h == Integer.MIN_VALUE) h = Integer.MAX_VALUE;/*from w w w.jav a 2 s. c om*/ return h < 0 ? -h : h; }
From source file:com.chiorichan.util.ObjectUtil.java
public static Integer castToIntWithException(Object value) { if (value == null) return null; switch (value.getClass().getName()) { case "java.lang.Long": if ((long) value < Integer.MIN_VALUE || (long) value > Integer.MAX_VALUE) return (Integer) value; else/*from w ww. j a va 2 s . co m*/ return null; case "java.lang.String": return Integer.parseInt((String) value); case "java.lang.Integer": return (Integer) value; case "java.lang.Double": return (Integer) value; case "java.lang.Boolean": return ((boolean) value) ? 1 : 0; case "java.math.BigDecimal": return ((BigDecimal) value).setScale(0, BigDecimal.ROUND_HALF_UP).intValue(); default: throw new ClassCastException("Uncaught Convertion to Integer of Type: " + value.getClass().getName()); } }