List of usage examples for java.lang Long MIN_VALUE
long MIN_VALUE
To view the source code for java.lang Long MIN_VALUE.
Click Source Link
From source file:io.warp10.continuum.gts.GTSHelper.java
/** * Return the tick at a given index in a Geo Time Serie. * //from w w w .j a va 2s. co m * @param gts * @param idx * @return */ public static long tickAtIndex(GeoTimeSerie gts, int idx) { if (idx >= gts.values) { return Long.MIN_VALUE; } else { return gts.ticks[idx]; } }
From source file:com.irccloud.android.activity.BaseActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_logout: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Logout"); builder.setMessage("Would you like to logout of IRCCloud?"); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override//from w ww . ja v a 2s.co m public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.setPositiveButton("Logout", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); conn.logout(); if (mGoogleApiClient.isConnected()) { Auth.CredentialsApi.disableAutoSignIn(mGoogleApiClient) .setResultCallback(new ResultCallback<Status>() { @Override public void onResult(Status status) { Intent i = new Intent(BaseActivity.this, LoginActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); finish(); } }); } else { Intent i = new Intent(BaseActivity.this, LoginActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); finish(); } } }); AlertDialog dialog = builder.create(); dialog.setOwnerActivity(this); dialog.show(); break; case R.id.menu_settings: Intent i = new Intent(this, PreferencesActivity.class); startActivity(i); break; case R.id.menu_feedback: try { String bugReport = "Briefly describe the issue below:\n\n\n\n\n" + "===========\n" + ((NetworkConnection.getInstance().getUserInfo() != null) ? ("UID: " + NetworkConnection.getInstance().getUserInfo().id + "\n") : "") + "App version: " + getPackageManager().getPackageInfo(getPackageName(), 0).versionName + " (" + getPackageManager().getPackageInfo(getPackageName(), 0).versionCode + ")\n" + "Device: " + Build.MODEL + "\n" + "Android version: " + Build.VERSION.RELEASE + "\n" + "Firmware fingerprint: " + Build.FINGERPRINT + "\n"; File logsDir = new File(getFilesDir(), ".Fabric/com.crashlytics.sdk.android.crashlytics-core/log-files/"); File log = null; File output = null; if (logsDir.exists()) { long max = Long.MIN_VALUE; for (File f : logsDir.listFiles()) { if (f.lastModified() > max) { max = f.lastModified(); log = f; } } if (log != null) { File f = new File(getFilesDir(), "logs"); f.mkdirs(); output = new File(f, LOG_FILENAME); byte[] b = new byte[1]; FileOutputStream out = new FileOutputStream(output); FileInputStream is = new FileInputStream(log); is.skip(5); while (is.available() > 0 && is.read(b, 0, 1) > 0) { if (b[0] == ' ') { while (is.available() > 0 && is.read(b, 0, 1) > 0) { out.write(b); if (b[0] == '\n') break; } } } is.close(); out.close(); } } Intent email = new Intent(Intent.ACTION_SEND); email.setData(Uri.parse("mailto:")); email.setType("message/rfc822"); email.putExtra(Intent.EXTRA_EMAIL, new String[] { "IRCCloud Team <team@irccloud.com>" }); email.putExtra(Intent.EXTRA_TEXT, bugReport); email.putExtra(Intent.EXTRA_SUBJECT, "IRCCloud for Android"); if (log != null) { email.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(this, getPackageName() + ".fileprovider", output)); } startActivityForResult(Intent.createChooser(email, "Send Feedback:"), 0); } catch (Exception e) { Toast.makeText(this, "Unable to generate email report: " + e.getMessage(), Toast.LENGTH_SHORT) .show(); Crashlytics.logException(e); NetworkConnection.printStackTraceToCrashlytics(e); } break; } return super.onOptionsItemSelected(item); }
From source file:org.ojai.json.impl.JsonDocumentBuilder.java
private boolean isWholeNumberInLongRange(double value) { return (value == Math.floor(value)) && !Double.isInfinite(value) && (value >= Long.MIN_VALUE && value <= Long.MAX_VALUE); }
From source file:co.cask.cdap.gateway.handlers.AppFabricHttpHandler.java
/** * Returns program run history.//w ww.j a v a 2 s .c o m */ @GET @Path("/apps/{app-id}/{runnable-type}/{runnable-id}/history") public void runnableHistory(HttpRequest request, HttpResponder responder, @PathParam("app-id") final String appId, @PathParam("runnable-type") final String runnableType, @PathParam("runnable-id") final String runnableId) { ProgramType type = RUNNABLE_TYPE_MAP.get(runnableType); if (type == null || type == ProgramType.WEBAPP) { responder.sendStatus(HttpResponseStatus.NOT_FOUND); return; } QueryStringDecoder decoder = new QueryStringDecoder(request.getUri()); String startTs = getQueryParameter(decoder.getParameters(), Constants.AppFabric.QUERY_PARAM_START_TIME); String endTs = getQueryParameter(decoder.getParameters(), Constants.AppFabric.QUERY_PARAM_END_TIME); String resultLimit = getQueryParameter(decoder.getParameters(), Constants.AppFabric.QUERY_PARAM_LIMIT); long start = startTs == null ? Long.MIN_VALUE : Long.parseLong(startTs); long end = endTs == null ? Long.MAX_VALUE : Long.parseLong(endTs); int limit = resultLimit == null ? Constants.AppFabric.DEFAULT_HISTORY_RESULTS_LIMIT : Integer.parseInt(resultLimit); getHistory(request, responder, appId, runnableId, start, end, limit); }
From source file:com.glaf.core.util.GetterUtils.java
private static long _parseLong(String value, long defaultValue) { int length = value.length(); if (length <= 0) { return defaultValue; }/*from w ww .j av a 2 s. c o m*/ int pos = 0; long limit = -Long.MAX_VALUE; boolean negative = false; char c = value.charAt(0); if (c < CharPool.NUMBER_0) { if (c == CharPool.MINUS) { limit = Long.MIN_VALUE; negative = true; } else if (c != CharPool.PLUS) { return defaultValue; } if (length == 1) { return defaultValue; } pos++; } long smallLimit = limit / 10; long result = 0; while (pos < length) { if (result < smallLimit) { return defaultValue; } c = value.charAt(pos++); if ((c < CharPool.NUMBER_0) || (c > CharPool.NUMBER_9)) { return defaultValue; } int number = c - CharPool.NUMBER_0; result *= 10; if (result < (limit + number)) { return defaultValue; } result -= number; } if (negative) { return result; } else { return -result; } }
From source file:com.sun.faces.util.Util.java
/** * @return true if and only if the argument * <code>attributeVal</code> is an instance of a wrapper for a * primitive type and its value is equal to the default value for * that type as given in the spec. */// w w w .j a va 2 s . co m private static boolean shouldRenderAttribute(Object attributeVal) { if (attributeVal instanceof Boolean && ((Boolean) attributeVal).booleanValue() == Boolean.FALSE.booleanValue()) { return false; } else if (attributeVal instanceof Integer && ((Integer) attributeVal).intValue() == Integer.MIN_VALUE) { return false; } else if (attributeVal instanceof Double && ((Double) attributeVal).doubleValue() == Double.MIN_VALUE) { return false; } else if (attributeVal instanceof Character && ((Character) attributeVal).charValue() == Character.MIN_VALUE) { return false; } else if (attributeVal instanceof Float && ((Float) attributeVal).floatValue() == Float.MIN_VALUE) { return false; } else if (attributeVal instanceof Short && ((Short) attributeVal).shortValue() == Short.MIN_VALUE) { return false; } else if (attributeVal instanceof Byte && ((Byte) attributeVal).byteValue() == Byte.MIN_VALUE) { return false; } else if (attributeVal instanceof Long && ((Long) attributeVal).longValue() == Long.MIN_VALUE) { return false; } return true; }
From source file:com.android.launcher3.ItemTouchHelper.java
/** * If user drags the view to the edge, trigger a scroll if necessary. *///from ww w . j a v a 2 s. c o m boolean scrollIfNecessary() { if (mSelected == null) { mDragScrollStartTimeInMs = Long.MIN_VALUE; return false; } final long now = System.currentTimeMillis(); final long scrollDuration = mDragScrollStartTimeInMs == Long.MIN_VALUE ? 0 : now - mDragScrollStartTimeInMs; android.support.v7.widget.RecyclerView.LayoutManager lm = mRecyclerView.getLayoutManager(); if (mTmpRect == null) { mTmpRect = new Rect(); } int scrollX = 0; int scrollY = 0; lm.calculateItemDecorationsForChild(mSelected.itemView, mTmpRect); if (lm.canScrollHorizontally()) { int curX = (int) (mSelectedStartX + mDx); final int leftDiff = curX - mTmpRect.left - mRecyclerView.getPaddingLeft(); if (mDx < 0 && leftDiff < 0) { scrollX = leftDiff; } else if (mDx > 0) { final int rightDiff = curX + mSelected.itemView.getWidth() + mTmpRect.right - (mRecyclerView.getWidth() - mRecyclerView.getPaddingRight()); if (rightDiff > 0) { scrollX = rightDiff; } } } if (lm.canScrollVertically()) { int curY = (int) (mSelectedStartY + mDy); final int topDiff = curY - mTmpRect.top - mRecyclerView.getPaddingTop(); if (mDy < 0 && topDiff < 0) { scrollY = topDiff; } else if (mDy > 0) { final int bottomDiff = curY + mSelected.itemView.getHeight() + mTmpRect.bottom - (mRecyclerView.getHeight() - mRecyclerView.getPaddingBottom()); if (bottomDiff > 0) { scrollY = bottomDiff; } } } if (scrollX != 0) { scrollX = mCallback.interpolateOutOfBoundsScroll(mRecyclerView, mSelected.itemView.getWidth(), scrollX, mRecyclerView.getWidth(), scrollDuration); } if (scrollY != 0) { scrollY = mCallback.interpolateOutOfBoundsScroll(mRecyclerView, mSelected.itemView.getHeight(), scrollY, mRecyclerView.getHeight(), scrollDuration); } if (scrollX != 0 || scrollY != 0) { if (mDragScrollStartTimeInMs == Long.MIN_VALUE) { mDragScrollStartTimeInMs = now; } mRecyclerView.scrollBy(scrollX, scrollY); return true; } mDragScrollStartTimeInMs = Long.MIN_VALUE; return false; }
From source file:org.apache.hadoop.chukwa.analysis.salsa.visualization.Heatmap.java
/** * Interfaces with database to get data and * populate data structures for rendering *//*w w w .j a v a2 s . com*/ public HeatmapData getData() { // preliminary setup OfflineTimeHandler time_offline; TimeHandler time_online; long start, end, min, max; if (offline_use) { time_offline = new OfflineTimeHandler(param_map, this.timezone); start = time_offline.getStartTime(); end = time_offline.getEndTime(); } else { time_online = new TimeHandler(this.request, this.timezone); start = time_online.getStartTime(); end = time_online.getEndTime(); } DatabaseWriter dbw = new DatabaseWriter(this.cluster); // setup query String query; if (this.query_state != null && this.query_state.equals("read")) { query = "select block_id,start_time,finish_time,start_time_millis,finish_time_millis,status,state_name,hostname,other_host,bytes from [" + table + "] where finish_time between '[start]' and '[end]' and (state_name like 'read_local' or state_name like 'read_remote')"; } else if (this.query_state != null && this.query_state.equals("write")) { query = "select block_id,start_time,finish_time,start_time_millis,finish_time_millis,status,state_name,hostname,other_host,bytes from [" + table + "] where finish_time between '[start]' and '[end]' and (state_name like 'write_local' or state_name like 'write_remote' or state_name like 'write_replicated')"; } else { query = "select block_id,start_time,finish_time,start_time_millis,finish_time_millis,status,state_name,hostname,other_host,bytes from [" + table + "] where finish_time between '[start]' and '[end]' and state_name like '" + query_state + "'"; } Macro mp = new Macro(start, end, query); query = mp.toString() + " order by start_time"; ArrayList<HashMap<String, Object>> events = new ArrayList<HashMap<String, Object>>(); ResultSet rs = null; log.debug("Query: " + query); // run query, extract results try { rs = dbw.query(query); ResultSetMetaData rmeta = rs.getMetaData(); int col = rmeta.getColumnCount(); while (rs.next()) { HashMap<String, Object> event = new HashMap<String, Object>(); long event_time = 0; for (int i = 1; i <= col; i++) { if (rmeta.getColumnType(i) == java.sql.Types.TIMESTAMP) { event.put(rmeta.getColumnName(i), rs.getTimestamp(i).getTime()); } else { event.put(rmeta.getColumnName(i), rs.getString(i)); } } events.add(event); } } catch (SQLException ex) { // handle any errors log.error("SQLException: " + ex.getMessage()); log.error("SQLState: " + ex.getSQLState()); log.error("VendorError: " + ex.getErrorCode()); } finally { dbw.close(); } SimpleDateFormat format = new SimpleDateFormat("MMM dd yyyy HH:mm:ss"); log.info(events.size() + " results returned."); HashSet<String> host_set = new HashSet<String>(); HashMap<String, Integer> host_indices = new HashMap<String, Integer>(); HashMap<Integer, String> host_rev_indices = new HashMap<Integer, String>(); // collect hosts, name unique hosts for (int i = 0; i < events.size(); i++) { HashMap<String, Object> event = events.get(i); String curr_host = (String) event.get("hostname"); String other_host = (String) event.get("other_host"); host_set.add(curr_host); host_set.add(other_host); } int num_hosts = host_set.size(); Iterator<String> host_iter = host_set.iterator(); for (int i = 0; i < num_hosts && host_iter.hasNext(); i++) { String curr_host = host_iter.next(); host_indices.put(curr_host, new Integer(i)); host_rev_indices.put(new Integer(i), curr_host); } System.out.println("Number of hosts: " + num_hosts); long stats[][] = new long[num_hosts][num_hosts]; long count[][] = new long[num_hosts][num_hosts]; // used for averaging int start_millis = 0, end_millis = 0; // deliberate design choice to duplicate code PER possible operation // otherwise we have to do the mode check N times, for N states returned // // compute aggregate statistics log.info("Query statistic type: " + this.query_stat_type); if (this.query_stat_type.equals("transaction_count")) { for (int i = 0; i < events.size(); i++) { HashMap<String, Object> event = events.get(i); start = (Long) event.get("start_time"); end = (Long) event.get("finish_time"); start_millis = Integer.parseInt(((String) event.get("start_time_millis"))); end_millis = Integer.parseInt(((String) event.get("finish_time_millis"))); String cell = (String) event.get("state_name"); String this_host = (String) event.get("hostname"); String other_host = (String) event.get("other_host"); int this_host_idx = host_indices.get(this_host).intValue(); int other_host_idx = host_indices.get(other_host).intValue(); // to, from stats[other_host_idx][this_host_idx] += 1; } } else if (this.query_stat_type.equals("avg_duration")) { for (int i = 0; i < events.size(); i++) { HashMap<String, Object> event = events.get(i); start = (Long) event.get("start_time"); end = (Long) event.get("finish_time"); start_millis = Integer.parseInt(((String) event.get("start_time_millis"))); end_millis = Integer.parseInt(((String) event.get("finish_time_millis"))); String cell = (String) event.get("state_name"); String this_host = (String) event.get("hostname"); String other_host = (String) event.get("other_host"); int this_host_idx = host_indices.get(this_host).intValue(); int other_host_idx = host_indices.get(other_host).intValue(); long curr_val = end_millis - start_millis + ((end - start) * 1000); // to, from stats[other_host_idx][this_host_idx] += curr_val; count[other_host_idx][this_host_idx] += 1; } for (int i = 0; i < num_hosts; i++) { for (int j = 0; j < num_hosts; j++) { if (count[i][j] > 0) stats[i][j] = stats[i][j] / count[i][j]; } } } else if (this.query_stat_type.equals("avg_volume")) { for (int i = 0; i < events.size(); i++) { HashMap<String, Object> event = events.get(i); start = (Long) event.get("start_time"); end = (Long) event.get("finish_time"); start_millis = Integer.parseInt(((String) event.get("start_time_millis"))); end_millis = Integer.parseInt(((String) event.get("finish_time_millis"))); String cell = (String) event.get("state_name"); String this_host = (String) event.get("hostname"); String other_host = (String) event.get("other_host"); int this_host_idx = host_indices.get(this_host).intValue(); int other_host_idx = host_indices.get(other_host).intValue(); long curr_val = Long.parseLong((String) event.get("bytes")); // to, from stats[other_host_idx][this_host_idx] += curr_val; count[other_host_idx][this_host_idx] += 1; } for (int i = 0; i < num_hosts; i++) { for (int j = 0; j < num_hosts; j++) { if (count[i][j] > 0) stats[i][j] = stats[i][j] / count[i][j]; } } } else if (this.query_stat_type.equals("total_duration")) { for (int i = 0; i < events.size(); i++) { HashMap<String, Object> event = events.get(i); start = (Long) event.get("start_time"); end = (Long) event.get("finish_time"); start_millis = Integer.parseInt(((String) event.get("start_time_millis"))); end_millis = Integer.parseInt(((String) event.get("finish_time_millis"))); String cell = (String) event.get("state_name"); String this_host = (String) event.get("hostname"); String other_host = (String) event.get("other_host"); int this_host_idx = host_indices.get(this_host).intValue(); int other_host_idx = host_indices.get(other_host).intValue(); double curr_val = end_millis - start_millis + ((end - start) * 1000); // to, from stats[other_host_idx][this_host_idx] += curr_val; } } else if (this.query_stat_type.equals("total_volume")) { for (int i = 0; i < events.size(); i++) { HashMap<String, Object> event = events.get(i); start = (Long) event.get("start_time"); end = (Long) event.get("finish_time"); start_millis = Integer.parseInt(((String) event.get("start_time_millis"))); end_millis = Integer.parseInt(((String) event.get("finish_time_millis"))); String cell = (String) event.get("state_name"); String this_host = (String) event.get("hostname"); String other_host = (String) event.get("other_host"); int this_host_idx = host_indices.get(this_host).intValue(); int other_host_idx = host_indices.get(other_host).intValue(); long curr_val = Long.parseLong((String) event.get("bytes")); // to, from stats[other_host_idx][this_host_idx] += curr_val; } } int[] permute = null; if (sort_nodes) { permute = hClust(stats); stats = doPermute(stats, permute); } Table agg_tab = new Table(); agg_tab.addColumn("stat", long.class); min = Long.MAX_VALUE; max = Long.MIN_VALUE; agg_tab.addRows(num_hosts * num_hosts); // row-wise placement (row1, followed by row2, etc.) for (int i = 0; i < num_hosts; i++) { for (int j = 0; j < num_hosts; j++) { agg_tab.setLong((i * num_hosts) + j, "stat", stats[i][j]); if (stats[i][j] > max) max = stats[i][j]; if (stats[i][j] > 0 && stats[i][j] < min) min = stats[i][j]; } } if (min == Long.MAX_VALUE) min = 0; log.info(agg_tab); // collate data HeatmapData hd = new HeatmapData(); hd.stats = new long[num_hosts][num_hosts]; hd.stats = stats; hd.min = min; hd.max = max; hd.num_hosts = num_hosts; hd.agg_tab = agg_tab; this.add_info_extra = new String("\nState: " + this.prettyStateNames.get(this.query_state) + " (" + events.size() + " " + this.query_state + "'s [" + this.query_stat_type + "])\n" + "Plotted value range: [" + hd.min + "," + hd.max + "] (Zeros in black)"); hd.hostnames = new String[num_hosts]; for (int i = 0; i < num_hosts; i++) { String curr_host = host_rev_indices.get(new Integer(permute[i])); if (sort_nodes) { hd.hostnames[i] = new String(curr_host); } else { hd.hostnames[i] = new String(curr_host); } } return hd; }
From source file:eu.tango.energymodeller.datastore.DefaultDatabaseConnector.java
@Override public Collection<HostEnergyUserLoadFraction> getHostVmHistoryLoadData(Host host, TimePeriod timePeriod) { HashMap<String, VmDeployed> vmCache = new HashMap<>(); List<HostEnergyUserLoadFraction> answer = new ArrayList<>(); connection = getConnection(connection); if (connection == null || host == null) { return answer; }//from www . j av a2s. c o m PreparedStatement preparedStatement = null; try { if (timePeriod != null) { long start = timePeriod.getStartTimeInSeconds(); long end = timePeriod.getEndTimeInSeconds(); preparedStatement = connection.prepareStatement( "SELECT host_id, vm_measurement.vm_id, vm_name, clock, cpu_load, power_overhead FROM vm_measurement, vm " + "WHERE vm_measurement.vm_id = vm.vm_id " + "and vm_measurement.host_id = ? " + " AND clock >= ? AND clock <= ?;"); preparedStatement.setLong(2, start); preparedStatement.setLong(3, end); } else { preparedStatement = connection.prepareStatement( "SELECT host_id, vm_measurement.vm_id, vm_name, clock, cpu_load, power_overhead FROM vm_measurement, vm " + "WHERE vm_measurement.vm_id = vm.vm_id " + "and vm_measurement.host_id = ?;"); } preparedStatement.setInt(1, host.getId()); try (ResultSet resultSet = preparedStatement.executeQuery()) { ArrayList<ArrayList<Object>> results = resultSetToArray(resultSet); long lastClock = Long.MIN_VALUE; long currentClock; HostEnergyUserLoadFraction currentHostLoadFraction = null; for (ArrayList<Object> measurement : results) { currentClock = (long) measurement.get(3); //clock is the 3rd item) if (currentClock != lastClock || currentHostLoadFraction == null) { currentHostLoadFraction = new HostEnergyUserLoadFraction(host, currentClock); VmDeployed vm = getVM((int) measurement.get(1), (String) measurement.get(2), host, vmCache); currentHostLoadFraction.addFraction(vm, (double) measurement.get(4)); //load is the fourth item currentHostLoadFraction.setHostPowerOffset((double) measurement.get(5)); //power overhead is fifth item answer.add(currentHostLoadFraction); } else { VmDeployed vm = getVM((int) measurement.get(1), (String) measurement.get(2), host, vmCache); currentHostLoadFraction.addFraction(vm, (double) measurement.get(4)); //load is the fourth item currentHostLoadFraction.setHostPowerOffset((double) measurement.get(5)); //overhead power is fifth item } lastClock = currentClock; } } } catch (SQLException ex) { Logger.getLogger(DefaultDatabaseConnector.class.getName()).log(Level.SEVERE, null, ex); return null; } finally { try { if (preparedStatement != null) { preparedStatement.close(); } } catch (SQLException ex) { Logger.getLogger(DefaultDatabaseConnector.class.getName()).log(Level.SEVERE, null, ex); } } return answer; }
From source file:com.alibaba.druid.sql.parser.Lexer.java
public Number integerValue() { long result = 0; boolean negative = false; int i = mark, max = mark + bufPos; long limit;//from ww w .ja va 2 s . c o m long multmin; int digit; if (charAt(mark) == '-') { negative = true; limit = Long.MIN_VALUE; i++; } else { limit = -Long.MAX_VALUE; } multmin = negative ? MULTMIN_RADIX_TEN : N_MULTMAX_RADIX_TEN; if (i < max) { digit = digits[charAt(i++)]; result = -digit; } while (i < max) { // Accumulating negatively avoids surprises near MAX_VALUE digit = digits[charAt(i++)]; if (result < multmin) { return new BigInteger(numberString()); } result *= 10; if (result < limit + digit) { return new BigInteger(numberString()); } result -= digit; } if (negative) { if (i > mark + 1) { if (result >= Integer.MIN_VALUE) { return (int) result; } return result; } else { /* Only got "-" */ throw new NumberFormatException(numberString()); } } else { result = -result; if (result <= Integer.MAX_VALUE) { return (int) result; } return result; } }