List of usage examples for java.lang Long longValue
@HotSpotIntrinsicCandidate public long longValue()
From source file:com.ery.ertc.estorm.util.JVM.java
/** * Get the number of the maximum file descriptors the system can use. If Oracle java, it will use the com.sun.management interfaces. * Otherwise, this methods implements it (linux only). * //w w w . j a v a2s . c o m * @return max number of file descriptors the operating system can use. */ public long getMaxFileDescriptorCount() { Long mfdc; if (!ibmvendor) { mfdc = runUnixMXBeanMethod("getMaxFileDescriptorCount"); return (mfdc != null ? mfdc.longValue() : -1); } InputStream in = null; BufferedReader output = null; try { // using linux bash commands to retrieve info Process p = Runtime.getRuntime().exec(new String[] { "bash", "-c", "ulimit -n" }); in = p.getInputStream(); output = new BufferedReader(new InputStreamReader(in)); String maxFileDesCount; if ((maxFileDesCount = output.readLine()) != null) return Long.parseLong(maxFileDesCount); } catch (IOException ie) { LOG.warn("Not able to get the max number of file descriptors", ie); } finally { if (output != null) { try { output.close(); } catch (IOException e) { LOG.warn("Not able to close the reader", e); } } if (in != null) { try { in.close(); } catch (IOException e) { LOG.warn("Not able to close the InputStream", e); } } } return -1; }
From source file:jp.co.opentone.bsol.linkbinder.dto.AbstractDto.java
/** * Long?clone????.//from w w w. j av a 2 s .co m * @param value ? * @return ???clone. value?null???null. */ protected Long cloneField(Long value) { Long clone = null; if (null != value) { clone = new Long(value.longValue()); } return clone; }
From source file:com.beyond.common.base.AbstractBaseDao.java
@SuppressWarnings("unchecked") protected PageInfo<T> getObjectPage(PageInfo<T> pageInfo, String countListStatementName, String getListStatementName, int pageNum, int pageSize, Map<String, Object> paramObject) { Long total = (Long) getSqlMapClientTemplate().queryForObject(countListStatementName, paramObject); pageNum = PageInfoUtil.getInstance().dealOutofMaxPageNum(total.intValue(), pageSize, pageNum); List<T> result = null;/*from w ww . ja v a 2s . c o m*/ if (total != null && total.longValue() > 0) { paramObject.put(PAGE_FROM, (pageNum - 1) * pageSize); paramObject.put(PAGE_TO, pageNum * pageSize); result = getSqlMapClientTemplate().queryForList(getListStatementName, paramObject); } pageInfo.setResult(result); pageInfo.setTotalRowSize(total); pageInfo.setCurrentPage(pageNum); pageInfo.setPerPageSize(pageSize); return pageInfo; }
From source file:com.google.sampling.experiential.server.MigrationBackendServlet.java
private void convertScheduleTimeLongsToSignalTimeObjects() { long t1 = System.currentTimeMillis(); log.info("Starting convertScheduleTimes from Long to SignalTime objects"); PersistenceManager pm = null;// w w w .j a v a 2s . c o m try { pm = PMF.get().getPersistenceManager(); javax.jdo.Query newQuery = pm.newQuery(Experiment.class); List<Experiment> updatedExperiments = Lists.newArrayList(); List<Experiment> experiments = (List<Experiment>) newQuery.execute(); for (Experiment experiment : experiments) { SignalSchedule schedule = experiment.getSchedule(); if (schedule != null && schedule.getSignalTimes().isEmpty()) { if (schedule.getScheduleType() != SignalScheduleDAO.SELF_REPORT && schedule.getScheduleType() != SignalScheduleDAO.ESM) { log.info("Converting for experiment: " + experiment.getTitle()); List<SignalTime> signalTimes = Lists.newArrayList(); List<Long> times = schedule.getTimes(); for (Long long1 : times) { signalTimes.add(new SignalTime(null, SignalTimeDAO.FIXED_TIME, SignalTimeDAO.OFFSET_BASIS_SCHEDULED_TIME, (int) long1.longValue(), SignalTimeDAO.MISSED_BEHAVIOR_USE_SCHEDULED_TIME, 0, "")); } schedule.setSignalTimes(signalTimes); experiment.setSchedule(schedule); updatedExperiments.add(experiment); } } } pm.makePersistentAll(updatedExperiments); } finally { pm.close(); } long t2 = System.currentTimeMillis(); long seconds = new Duration(t1, t2).getStandardSeconds(); log.info("Done converting signal times. " + seconds + "seconds to complete"); }
From source file:cherry.example.web.applied.ex20.AppliedEx20ControllerImpl.java
@Override public ModelAndView execute(AppliedEx20Form form, BindingResult binding, Authentication auth, Locale locale, SitePreference sitePref, NativeWebRequest request, SessionStatus status, RedirectAttributes redirAttr) { if (hasErrors(form, binding)) { return withViewname(viewnameOfStart).build(); }//from w w w.ja v a 2 s. c o m if (!oneTimeTokenValidator.isValid(request.getNativeRequest(HttpServletRequest.class))) { LogicalErrorUtil.rejectOnOneTimeTokenError(binding); return withViewname(viewnameOfStart).build(); } Long id = service.create(form); checkState(id != null, "failed to create: form=%s", form); status.setComplete(); redirAttr.addFlashAttribute(FLASH_CREATED, Boolean.TRUE); return redirect(redirectOnExecute(id.longValue())).build(); }
From source file:com.icesoft.faces.async.common.PushServerAdaptingServlet.java
public PushServerAdaptingServlet(final HttpSession httpSession, final String iceFacesId, final Collection synchronouslyUpdatedViews, final ViewQueue allUpdatedViews, final Configuration configuration, final CoreMessageService coreMessageService) throws MessageServiceException { blockingRequestHandlerContext = configuration.getAttribute("blockingRequestHandlerContext", "push-server"); allUpdatedViews.onPut(new Runnable() { public void run() { allUpdatedViews.removeAll(synchronouslyUpdatedViews); synchronouslyUpdatedViews.clear(); Set _viewIdentifierSet = new HashSet(allUpdatedViews); if (!_viewIdentifierSet.isEmpty()) { Long _sequenceNumber; synchronized (lock) { _sequenceNumber = (Long) httpSession.getAttribute(SEQUENCE_NUMBER_KEY); if (_sequenceNumber != null) { _sequenceNumber = new Long(_sequenceNumber.longValue() + 1); } else { _sequenceNumber = new Long(1); }//from ww w .ja va2 s .c om httpSession.setAttribute(SEQUENCE_NUMBER_KEY, _sequenceNumber); } String[] _viewIdentifiers = (String[]) _viewIdentifierSet .toArray(new String[_viewIdentifierSet.size()]); StringWriter _stringWriter = new StringWriter(); for (int i = 0; i < _viewIdentifiers.length; i++) { if (i != 0) { _stringWriter.write(','); } _stringWriter.write(_viewIdentifiers[i]); } Properties _messageProperties = new Properties(); _messageProperties.setStringProperty(Message.DESTINATION_SERVLET_CONTEXT_PATH, blockingRequestHandlerContext); coreMessageService.publish(iceFacesId + ";" + // ICEfaces ID _sequenceNumber + ";" + // Sequence Number _stringWriter.toString(), // Message Body _messageProperties, UPDATED_VIEWS_MESSAGE_TYPE, MessageServiceClient.PUSH_TOPIC_NAME); } } }); }
From source file:com.ery.ertc.estorm.util.JVM.java
/** * Get the number of opened filed descriptor for the runtime jvm. If Oracle java, it will use the com.sun.management interfaces. * Otherwise, this methods implements it (linux only). * //w w w . ja va 2s. com * @return number of open file descriptors for the jvm */ public long getOpenFileDescriptorCount() { Long ofdc; if (!ibmvendor) { ofdc = runUnixMXBeanMethod("getOpenFileDescriptorCount"); return (ofdc != null ? ofdc.longValue() : -1); } InputStream in = null; BufferedReader output = null; try { // need to get the PID number of the process first RuntimeMXBean rtmbean = ManagementFactory.getRuntimeMXBean(); String rtname = rtmbean.getName(); String[] pidhost = rtname.split("@"); // using linux bash commands to retrieve info Process p = Runtime.getRuntime() .exec(new String[] { "bash", "-c", "ls /proc/" + pidhost[0] + "/fdinfo | wc -l" }); in = p.getInputStream(); output = new BufferedReader(new InputStreamReader(in)); String openFileDesCount; if ((openFileDesCount = output.readLine()) != null) return Long.parseLong(openFileDesCount); } catch (IOException ie) { LOG.warn("Not able to get the number of open file descriptors", ie); } finally { if (output != null) { try { output.close(); } catch (IOException e) { LOG.warn("Not able to close the InputStream", e); } } if (in != null) { try { in.close(); } catch (IOException e) { LOG.warn("Not able to close the InputStream", e); } } } return -1; }
From source file:com.redhat.rhn.frontend.action.monitoring.notification.BaseFilterEditAction.java
private String getRecurringDigits(Long durationIn, int durationTypeIn) { long duration = durationIn.longValue(); if (durationTypeIn == Calendar.MINUTE) { // durationType == 12 // NOOP since minutes is the base type. } else if (durationTypeIn == Calendar.HOUR_OF_DAY) { // durationType == 11 duration = duration / 60;// w w w .j av a 2 s .co m } else if (durationTypeIn == Calendar.DAY_OF_MONTH) { // durationType == 5 duration = duration / 60 / 24; } else if (durationTypeIn == Calendar.WEEK_OF_YEAR) { // durationType == 3 duration = duration / 60 / 24 / 7; } else if (durationTypeIn == Calendar.YEAR) { // durationType == 1 duration = duration / 60 / 24 / 7 / 365; } else { throw new IllegalArgumentException("Durration for recurring " + "should be either Calendar.MINUTE, HOURS_OF_DAY, " + "DAY_OF_MONTH, WEEK_OF_YEAR, YEAR"); } return new Long(duration).toString(); }
From source file:org.nekorp.workflow.backend.controller.imp.ReporteClienteControllerImp.java
/**{@inheritDoc}*/ @Override// ww w. j a v a 2 s.co m @RequestMapping(value = "/{idServicio}", method = RequestMethod.GET) @ResponseBody public ReporteCliente getDatosReporte(@PathVariable Long idCliente, @PathVariable Long idServicio, HttpServletResponse response) { Servicio servicio = servicioDao.consultar(idServicio); if (servicio == null) { response.setStatus(HttpStatus.NOT_FOUND.value()); return null; } if (servicio.getIdCliente().longValue() != idCliente.longValue()) { response.setStatus(HttpStatus.NOT_FOUND.value()); return null; } response.setHeader("Content-Type", "application/json;charset=UTF-8"); return dataFactory.getData(servicio); }
From source file:com.redhat.rhn.domain.kickstart.KickstartFactory.java
/** * Verfies that a given kickstart tree can be used based on a channel id * and org id// w w w. j a va 2 s. com * @param channelId base channel * @param orgId org * @param treeId kickstart tree * @return true if it can, false otherwise */ public static boolean verifyTreeAssignment(Long channelId, Long orgId, Long treeId) { Session session = null; boolean retval = false; if (channelId != null && orgId != null && treeId != null) { session = HibernateFactory.getSession(); Query query = session.getNamedQuery("KickstartableTree.verifyTreeAssignment"); query.setLong("channel_id", channelId.longValue()); query.setLong("org_id", orgId.longValue()); query.setLong("tree_id", treeId.longValue()); Object tree = query.uniqueResult(); retval = (tree != null); } return retval; }