Example usage for java.lang Long Long

List of usage examples for java.lang Long Long

Introduction

In this page you can find the example usage for java.lang Long Long.

Prototype

@Deprecated(since = "9")
public Long(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Long object that represents the long value indicated by the String parameter.

Usage

From source file:de.msg.repository.driver.DefaultRouteRepositoryDriver.java

@PostConstruct
public void initRoutesList() {
    for (short i = 0; i < routeCount; i++) {
        String flightNumber = flightNumberList.get(i);
        String departure = departureList.get(i);
        String destination = destinationList.get(i);

        Route route = new Route(flightNumber, departure, destination);
        route.setId(new Long(i + 1));
        route.addScheduledDaily();/*w ww  .j av a 2 s  . co m*/
        route.setDepartureTime(LocalTime.of(9 + i, 30));
        route.setArrivalTime(LocalTime.of(14 + i, 0));
        routeList.add(route);
    }
}

From source file:org.lamop.riche.webservices.SourceRESTWS.java

@RequestMapping(method = RequestMethod.GET, headers = "Accept=application/json")
public @ResponseBody Source get(@PathParam("id") int id) {
    System.out.println("GET ID " + id);
    return serviceSource.getEntity(new Long(id));
}

From source file:com.mockey.ui.ScenarioServlet.java

public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    // A Service is needed to associate the
    // scenario to.
    Long serviceId = new Long(req.getParameter("serviceId"));
    Long scenarioId = null;//from  www.  j ava  2  s  . c  om
    try {
        scenarioId = new Long(req.getParameter("scenarioId"));
    } catch (Exception e) {
        // Do nothing. If the value doesn't exist,
        // then we'll create a new Scenario
        // for this service.
    }

    // Get the service.
    Service service = store.getServiceById(serviceId);

    // DELETE scenario logic
    if (req.getParameter("deleteScenario") != null && serviceId != null && scenarioId != null) {
        try {

            service.deleteScenario(scenarioId);
            store.saveOrUpdateService(service);
        } catch (Exception e) {
            // Just in case an invalid service ID
            // or scenario ID were past in.
        }
        resp.setContentType("application/json");
        PrintWriter out = resp.getWriter();
        JSONObject result = new JSONObject();
        JSONObject message = new JSONObject();
        try {
            result.put("result", message);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        out.println(result.toString());
        out.flush();
        out.close();
        return;
    }

    Scenario scenario = null;
    try {
        scenario = service.getScenario(new Long(req.getParameter("scenarioId")));
    } catch (Exception e) {
        //
    }

    // CREATE OR UPDATE OF SCENARIO
    // If scenario is null, that means we're creating,
    // not updating
    if (scenario == null) {
        scenario = new Scenario();
    }

    String scenarioName = req.getParameter("scenarioName");
    if (scenarioName == null || scenarioName.trim().length() == 0) {
        // Let's be nice and make up a name.
        scenarioName = "Scenario for " + service.getServiceName() + "(name auto-generated)";
    }
    scenario.setScenarioName(scenarioName);

    if (req.getParameter("responseMessage") != null) {
        scenario.setResponseMessage(req.getParameter("responseMessage"));
    }
    if (req.getParameter("matchStringArg") != null) {
        scenario.setMatchStringArg(req.getParameter("matchStringArg"));
    }

    // VALIDATION
    Map<String, String> errorMap = ScenarioValidator.validate(scenario);

    if ((errorMap != null) && (errorMap.size() == 0)) {

        // If creating a Scenario, then the returned scenario
        // will now have an id. If updating scenario, then
        // scenario ID remains the same.
        scenario = service.saveOrUpdateScenario(scenario);

        // Make this the default 'error response' scenario
        // for the service
        String v = req.getParameter("errorScenario");
        if (v != null && "true".equalsIgnoreCase(v.trim())) {
            service.setErrorScenarioId(scenario.getId());
        } else if (service.getErrorScenarioId() == scenario.getId()) {
            service.setErrorScenarioId(null);
        }

        // Make this the default universal 'error response',
        // for all services defined in Mockey.
        v = req.getParameter("universalErrorScenario");
        if (v != null && "true".equalsIgnoreCase(v.trim())) {
            store.setUniversalErrorScenarioId(scenario.getId());
            store.setUniversalErrorServiceId(serviceId);

        } else if (store.getUniversalErrorScenarioId() != null
                && store.getUniversalErrorScenarioId() == scenario.getId()) {
            store.setUniversalErrorScenarioId(null);
            store.setUniversalErrorServiceId(null);
        }

        store.saveOrUpdateService(service);
        resp.setContentType("application/json");
        PrintWriter out = resp.getWriter();

        JSONObject object = new JSONObject();
        JSONObject resultObject = new JSONObject();
        try {

            object.put("success", "Scenario updated");
            object.put("scenarioId", scenario.getId().toString());
            object.put("serviceId", service.getId().toString());
            resultObject.put("result", object);
        } catch (JSONException e1) {
            e1.printStackTrace();
        }
        out.println(resultObject);
        out.flush();
        out.close();
        return;

    } else {
        // ERROR STATE
        // Something is wrong with the input values.
        // Scenario is not created or updated.
        // Coaching messages are available in the
        // error dictionary/map.
        resp.setContentType("application/json");
        PrintWriter out = resp.getWriter();
        String resultingJSON = Util.getJSON(errorMap);
        out.println(resultingJSON);
        out.flush();
        out.close();
        return;
    }
}

From source file:org.openmrs.module.omodexport.util.OmodExportUtil.java

/**
 * Utility method for exporting a single module
 * /*from  w ww  . j av  a 2 s . co m*/
 * @param module -The module to export
 * @param response
 */
public static void exportSingleModule(Module module, HttpServletResponse response) {
    File file = module.getFile();
    response.setContentLength(new Long(file.length()).intValue());
    response.setContentType("application/zip");
    response.setHeader("Content-Disposition", "attachment; filename=\"" + file.getName() + "\"");
    try {
        FileCopyUtils.copy(new FileInputStream(file), response.getOutputStream());
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:com.mockey.ui.HistoryAjaxServlet.java

/**
 * /*from   w  ww . j  a  v a 2  s  .c  o m*/
 */
public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    Long fulfilledRequestId = null;
    JSONObject jsonObject = new JSONObject();
    try {

        fulfilledRequestId = new Long(req.getParameter("conversationRecordId"));
        FulfilledClientRequest fCRequest = store.getFulfilledClientRequestsById(fulfilledRequestId);

        jsonObject.put("conversationRecordId", "" + fulfilledRequestId);
        jsonObject.put("serviceId", "" + fCRequest.getServiceId());
        jsonObject.put("serviceName", fCRequest.getServiceName());
        jsonObject.put("requestUrl", "" + fCRequest.getRawRequest());
        jsonObject.put("requestHeaders", "" + fCRequest.getClientRequestHeaders());
        jsonObject.put("requestParameters", "" + fCRequest.getClientRequestParameters());
        jsonObject.put("requestBody", "" + fCRequest.getClientRequestBody());
        jsonObject.put("requestCookies", "" + fCRequest.getClientRequestCookies());
        jsonObject.put("responseCookies", "" + fCRequest.getClientResponseCookies());

        jsonObject.put("responseStatus", "" + fCRequest.getResponseMessage().getStatusLine());
        jsonObject.put("responseHeader", "" + fCRequest.getResponseMessage().getHeaderInfo());
        jsonObject.put("responseBody", "" + fCRequest.getResponseMessage().getBody());

    } catch (Exception e) {
        try {
            jsonObject.put("error", "" + "Sorry, history for this conversation (fulfilledRequestId="
                    + fulfilledRequestId + ") is not available.");
        } catch (JSONException e1) {
            logger.error("Unable to create JSON", e1);
        }
    }

    resp.setContentType("application/json");

    PrintStream out = new PrintStream(resp.getOutputStream());

    out.println(jsonObject.toString());
}

From source file:com.eudemon.taurus.app.service.ShiroDbRealm.java

@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken)
        throws AuthenticationException {
    UsernamePasswordToken token = (UsernamePasswordToken) authcToken;

    User user = userService.findUserByName(token.getUsername());
    if (null != user) {
        byte[] salt = Encodes.decodeHex(user.getSalt());
        return new SimpleAuthenticationInfo(
                new ShiroUser(new Long(user.getId()), user.getName(), user.getName()), user.getPassword(),
                ByteSource.Util.bytes(salt), getName());
    } else {//from   w  w w  . jav  a 2 s  . c om
        return null;
    }
}

From source file:com.bstek.dorado.data.type.DateDataTypeTest.java

public void testConvertFromObject() {
    Object value;// w ww  .  ja  va2  s  .c  o  m
    Date date;

    value = null;
    date = (Date) dateDataType.fromObject(value);
    assertNull(date);

    value = new Long(System.currentTimeMillis());
    date = (Date) dateDataType.fromObject(value);
    assertNotNull(date);
}

From source file:org.lamop.riche.webservices.WorkAuthorRESTWs.java

@RequestMapping(method = RequestMethod.GET, headers = "Accept=application/json")
public @ResponseBody WorkAuthor get(@PathParam("id") int id) {
    System.out.println("GET ID " + id);
    return workAuthorService.getEntity(new Long(id));
}

From source file:com.fileanalyzer.util.LineStatisticCalculator.java

public StringBuilder getSqlInsertFileStatistic() {
    Map<String, Object> params = new HashMap<>();
    StringBuilder sql = new StringBuilder("INSERT INTO " + FileStatistic.FileStatisticKey.TABLE + " ");
    params.put(FileStatisticKey.LENGTHLINE, new Long(line.length()));
    String strArr[] = line.split(regexp);
    TreeSet<Integer> maxWord = new TreeSet();
    TreeSet<Integer> minWord = new TreeSet();
    long sumWords = 0;
    for (int i = 0; i < strArr.length; ++i) {
        int strSize = strArr[i].length();
        sumWords += strSize;/* w w w .j  av  a2  s .  com*/
        if (i > 0 && i < strArr.length - 1)
            maxWord.add(strSize);
        minWord.add(strSize);
    }
    params.put(FileStatisticKey.LINE, HtmlUtils.htmlEscape(line));
    if (sumWords > 0) {
        params.put(FileStatisticKey.AVGWORD, new Double(sumWords / strArr.length));
        params.put(FileStatisticKey.MINWORD, new Long(minWord.first()));
    }
    if (maxWord.size() > 0)
        params.put(FileStatisticKey.MAXWORD, new Long(new Long(maxWord.last())));
    if (getIdFk() != null)
        params.put(FileStatisticKey.FILEID, getIdFk());
    genParamAndValues(sql, params);

    return sql;
}

From source file:com.googlecode.psiprobe.controllers.threads.ThreadStackController.java

protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    long threadID = ServletRequestUtils.getLongParameter(request, "id", -1);
    String threadName = ServletRequestUtils.getStringParameter(request, "name", null);

    List stack = null;/*from  w  w w  .j av  a  2  s  . c  o m*/
    MBeanServer mBeanServer = new Registry().getMBeanServer();
    ObjectName threadingOName = new ObjectName("java.lang:type=Threading");

    if (threadID == -1 && threadName != null) {
        // find thread by name
        long[] allIds = (long[]) mBeanServer.getAttribute(threadingOName, "AllThreadIds");
        for (int i = 0; i < allIds.length; i++) {
            CompositeData cd = (CompositeData) mBeanServer.invoke(threadingOName, "getThreadInfo",
                    new Object[] { new Long(allIds[i]) }, new String[] { "long" });
            String name = JmxTools.getStringAttr(cd, "threadName");
            if (threadName.equals(name)) {
                threadID = allIds[i];
                break;
            }
        }
    }

    if (mBeanServer.queryMBeans(threadingOName, null) != null && threadID != -1) {

        CompositeData cd = (CompositeData) mBeanServer.invoke(threadingOName, "getThreadInfo",
                new Object[] { new Long(threadID), new Integer(stackElementCount) },
                new String[] { "long", "int" });
        if (cd != null) {
            CompositeData[] elements = (CompositeData[]) cd.get("stackTrace");
            threadName = JmxTools.getStringAttr(cd, "threadName");

            stack = new ArrayList(elements.length);

            for (int i = 0; i < elements.length; i++) {
                CompositeData cd2 = elements[i];
                ThreadStackElement tse = new ThreadStackElement();
                tse.setClassName(JmxTools.getStringAttr(cd2, "className"));
                tse.setFileName(JmxTools.getStringAttr(cd2, "fileName"));
                tse.setMethodName(JmxTools.getStringAttr(cd2, "methodName"));
                tse.setLineNumber(JmxTools.getIntAttr(cd2, "lineNumber", -1));
                tse.setNativeMethod(JmxTools.getBooleanAttr(cd2, "nativeMethod"));
                stack.add(tse);
            }
        }
    }

    return new ModelAndView(getViewName(), "stack", stack).addObject("threadName", threadName);
}