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:fr.univrouen.poste.domain.PosteCandidatureFile.java

public static Long getSumFileSize() {
    String sql = "SELECT SUM(file_size) FROM poste_candidature_file";
    Query q = entityManager().createNativeQuery(sql);
    BigDecimal bigValue = (BigDecimal) q.getSingleResult();
    if (bigValue != null) {
        return bigValue.longValue();
    } else {//from   ww w. jav a 2s. c  o m
        return new Long(0);
    }
}

From source file:com.senseidb.test.bql.parsers.JsonComparator.java

/**
 * Compares two json objects./* www.  j ava2  s  .c o m*/
 *
 * @param a first element to compare
 * @param b second element to compare
 * @return true if the elements are equal as per the policy.
 */
public boolean isEquals(Object a, Object b) {
    if (a instanceof JSONObject) {
        if (b instanceof JSONObject) {
            return isEqualsJsonObject((JSONObject) a, (JSONObject) b);
        } else {
            return false;
        }
    }

    if (a instanceof JSONArray) {
        if (b instanceof JSONArray) {
            return isEqualsJsonArray((JSONArray) a, (JSONArray) b);
        } else {
            return false;
        }
    }

    if (a instanceof Long) {
        if (b instanceof Long) {
            return isEqualsLong((Long) a, (Long) b);
        } else if (b instanceof Integer) {
            return isEqualsLong((Long) a, new Long((long) ((Integer) b).intValue()));
        } else {
            return false;
        }
    }

    if (a instanceof Integer) {
        if (b instanceof Integer) {
            return isEqualsInteger((Integer) a, (Integer) b);
        } else if (b instanceof Long) {
            return isEqualsInteger((Integer) a, new Integer((int) ((Long) b).longValue()));
        } else {
            return false;
        }
    }

    if (a instanceof String) {
        if (b instanceof String) {
            return isEqualsString((String) a, (String) b);
        } else {
            return false;
        }
    }

    if (a instanceof Boolean) {
        if (b instanceof Boolean) {
            return isEqualsBoolean((Boolean) a, (Boolean) b);
        } else {
            return false;
        }
    }

    if (a instanceof Float || a instanceof Double) {
        double val1 = (a instanceof Float) ? ((Float) a).doubleValue() : ((Double) a).doubleValue();
        if (b instanceof Float || b instanceof Double) {
            double val2 = (b instanceof Float) ? ((Float) b).doubleValue() : ((Double) b).doubleValue();
            return (Math.abs(val1 - val2) < 0.001);
        } else {
            return false;
        }
    }

    if (a == null && b == null) {
        return true;
    }

    if (a != null && b != null) {
        return a.equals(b);
    }

    return false;
}

From source file:com.arindra.project.accounting.controllers.PurchaseOrderController.java

@RequestMapping(method = RequestMethod.GET, value = "/create_demo")
public void createDemoPurchaseOrder() {//@PathVariable("username") String username, @PathVariable("password") String password,@PathVariable("limit") Integer limit){
    PurchaseOrder purchaseOrder = new PurchaseOrder("1", new Timestamp(new Date().getTime()), null, null,
            new Long(0));
    PurchaseOrderDetail purchaseOrderDetail = new PurchaseOrderDetail(1, null, new Long(10), 1);

    purchaseOrderRepo.save(purchaseOrder);
    purchaseOrderDetailRepo.save(purchaseOrderDetail);
}

From source file:AIR.Common.Configuration.AppSettings.java

public static AppSetting<Long> getLong(String name) {
    return AppSettings.<Long>get(name, new Long(0), new AppSettingsHelperMethodWrapper<Long>() {
        @Override//w w w .j a va  2  s . co  m
        public Long getValue(String key, Long defaultValue) {
            return AppSettingsHelper.getInt64(key, defaultValue);
        }
    });
}

From source file:com.edgenius.wiki.security.acegi.TokenBasedRememberMeServices.java

public UserDetails processAutoLoginCookie(String[] cookieTokens, HttpServletRequest request,
        HttpServletResponse response) {//from www  . j av a  2s . c  o  m

    if (cookieTokens.length != 3) {
        throw new InvalidCookieException("Cookie token did not contain " + 2 + " tokens, but contained '"
                + Arrays.asList(cookieTokens) + "'");
    }

    long tokenExpiryTime;

    try {
        tokenExpiryTime = new Long(cookieTokens[1]).longValue();
    } catch (NumberFormatException nfe) {
        throw new InvalidCookieException(
                "Cookie token[1] did not contain a valid number (contained '" + cookieTokens[1] + "')");
    }

    if (isTokenExpired(tokenExpiryTime)) {
        throw new InvalidCookieException("Cookie token[1] has expired (expired on '" + new Date(tokenExpiryTime)
                + "'; current time is '" + new Date() + "')");
    }

    // Check the user exists.
    // Defer lookup until after expiry time checked, to possibly avoid
    // expensive database call.

    UserDetails userDetails = getUserDetailsService().loadUserByUsername(cookieTokens[0]);

    // Check signature of token matches remaining details.
    // Must do this after user lookup, as we need the DAO-derived password.
    // If efficiency was a major issue, just add in a UserCache
    // implementation,
    // but recall that this method is usually only called once per
    // HttpSession - if the token is valid,
    // it will cause SecurityContextHolder population, whilst if invalid,
    // will cause the cookie to be cancelled.
    String expectedTokenSignature = makeTokenSignature(tokenExpiryTime, userDetails.getUsername(),
            userDetails.getPassword());

    if (!expectedTokenSignature.equals(cookieTokens[2])) {
        // NDPDNP - this is part of different with original code
        if (Global.webServiceEnabled || Global.restServiceEnabled) {
            // this is compare different key: it could come from
            // com.edgenius.wiki.integration.client.Authentication.login();
            expectedTokenSignature = makeTokenSignature(tokenExpiryTime, userDetails.getUsername(),
                    userDetails.getPassword(), REMEMBERME_COOKIE_KEY);
            if (expectedTokenSignature.equals(cookieTokens[2])) {
                // Remove this login cookie immediately, so that
                // Authentication.login() won't be a "rememberMe" style login - we just implement login by this cookie but not rememberMe.
                cancelCookie(request, response);
                return userDetails;
            }
        }
        throw new InvalidCookieException("Cookie token[2] contained signature '" + cookieTokens[2]
                + "' but expected '" + expectedTokenSignature + "'");
    }

    return userDetails;
}

From source file:net.jofm.format.NumberFormat.java

private Object convert(Number result, Class<?> destinationClazz) {
    if (destinationClazz.equals(BigDecimal.class)) {
        return new BigDecimal(result.doubleValue());
    }//from  w ww. java2  s. c om
    if (destinationClazz.equals(Short.class) || destinationClazz.equals(short.class)) {
        return new Short(result.shortValue());
    }
    if (destinationClazz.equals(Integer.class) || destinationClazz.equals(int.class)) {
        return new Integer(result.intValue());
    }
    if (destinationClazz.equals(Long.class) || destinationClazz.equals(long.class)) {
        return new Long(result.longValue());
    }
    if (destinationClazz.equals(Float.class) || destinationClazz.equals(float.class)) {
        return new Float(result.floatValue());
    }
    if (destinationClazz.equals(Double.class) || destinationClazz.equals(double.class)) {
        return new Double(result.doubleValue());
    }

    throw new FixedMappingException("Unable to parse the data to type " + destinationClazz.getName() + " using "
            + this.getClass().getName());
}

From source file:net.mindengine.oculus.frontend.web.controllers.test.TestEditController.java

@Override
protected Object formBackingObject(HttpServletRequest request) throws Exception {
    Long id = new Long(request.getParameter("id"));
    Test test = testDAO.getTest(id);/*from   w  ww .j a v a  2s.  c o m*/
    test.setInputParameters(testDAO.getTestInputParameters(id));
    test.setOutputParameters(testDAO.getTestOutputParameters(id));
    return test;
}

From source file:com.multiimages.insertmultiimg.InsertMultiImg.java

@Transactional(value = "EmployeesDBTransactionManager")
public void uploadFile(Integer relativePath, MultipartFile[] files, HttpServletRequest httpServletRequest) {
    /* Note: relativePath here maps to the id of the related Object to be saved in the transaction */
    File outputFile = null;// w  ww .ja  va  2 s  .  c  om
    Session session = sessionFactory.getObject().openSession();

    for (MultipartFile file : files) {
        try {
            Image image = new Image();
            image.setEmployee(employeeService.findById(relativePath));

            byte[] byteArray = IOUtils.toByteArray(file.getInputStream());
            Blob blob = Hibernate.getLobCreator(session).createBlob(new ByteArrayInputStream(byteArray),
                    new Long(byteArray.length));

            image.setImgdate(blob);

            imageService.create(image);
        } catch (Exception e) {
        }
    }
}

From source file:com.anite.antelope.modules.screens.security.Groups.java

protected void doBuildTemplate(RunData data, Context context) throws Exception {

    // Retrieve the form tool that has validated the input
    FormTool form = (FormTool) context.get(FormTool.DEFAULT_TOOL_NAME);
    SecurityTool security = (SecurityTool) context.get(SecurityTool.DEFAULT_TOOL_NAME);

    GroupManager groupManager;// w  w w. j  av a2 s . com
    String groupId;

    groupManager = security.getGroupManager();

    // get the user name from the text box
    groupId = ((Field) (form.getFields().get("groupid"))).getValue();

    // righty o we need all the users
    context.put("groups", groupManager.getAllGroups());

    // if there has been a user chosen set up the group info
    if (!StringUtils.isEmpty(groupId)) {
        RoleManager roleManager;
        DynamicGroup group;

        roleManager = security.getRoleManager();
        group = (DynamicGroup) groupManager.getGroupById(new Long(groupId));
        context.put("selectedgroup", group);

        // put in the users groups
        context.put("allocatedroles", group.getRoles());

        // find the groups that are left
        context.put("availableroles", PermissionHelper.roleSetXOR(group.getRoles(), roleManager.getAllRoles()));
    }
}

From source file:com.uber.hoodie.cli.commands.StatsCommand.java

@CliCommand(value = "stats wa", help = "Write Amplification. Ratio of how many records were upserted to how many records were actually written")
public String writeAmplificationStats() throws IOException {
    long totalRecordsUpserted = 0;
    long totalRecordsWritten = 0;

    HoodieActiveTimeline activeTimeline = HoodieCLI.tableMetadata.getActiveTimeline();
    HoodieTimeline timeline = activeTimeline.getCommitTimeline().filterCompletedInstants();

    String[][] rows = new String[new Long(timeline.countInstants()).intValue() + 1][];
    int i = 0;/*  w ww  .j av a 2 s  .  co m*/
    DecimalFormat df = new DecimalFormat("#.00");
    for (HoodieInstant commitTime : timeline.getInstants().collect(Collectors.toList())) {
        String waf = "0";
        HoodieCommitMetadata commit = HoodieCommitMetadata
                .fromBytes(activeTimeline.getInstantDetails(commitTime).get());
        if (commit.fetchTotalUpdateRecordsWritten() > 0) {
            waf = df.format(
                    (float) commit.fetchTotalRecordsWritten() / commit.fetchTotalUpdateRecordsWritten());
        }
        rows[i++] = new String[] { commitTime.getTimestamp(),
                String.valueOf(commit.fetchTotalUpdateRecordsWritten()),
                String.valueOf(commit.fetchTotalRecordsWritten()), waf };
        totalRecordsUpserted += commit.fetchTotalUpdateRecordsWritten();
        totalRecordsWritten += commit.fetchTotalRecordsWritten();
    }
    String waf = "0";
    if (totalRecordsUpserted > 0) {
        waf = df.format((float) totalRecordsWritten / totalRecordsUpserted);
    }
    rows[i] = new String[] { "Total", String.valueOf(totalRecordsUpserted), String.valueOf(totalRecordsWritten),
            waf };
    return HoodiePrintHelper.print(
            new String[] { "CommitTime", "Total Upserted", "Total Written", "Write Amplifiation Factor" },
            rows);

}