Example usage for java.lang Long decode

List of usage examples for java.lang Long decode

Introduction

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

Prototype

public static Long decode(String nm) throws NumberFormatException 

Source Link

Document

Decodes a String into a Long .

Usage

From source file:org.okinawaopenlabs.ofpm.utils.OFPMUtils.java

/**
 * transfer macAddresslong//from   www.  j  av  a 2s . c om
 * @param mac String ex.AA:BB:CC:DD:EE:FF
 * @return long transfered
 * @throws NullPointerException mac is null
 * @throws NumberFormatException if the String does not contain a parsable long
 */
public static long macAddressToLong(String mac) throws NullPointerException, NumberFormatException {
    //String macTmp = StringUtils.join(mac.split(":"));
    String hexMac = mac.replace(":", "");
    long longMac = Long.decode("0x" + hexMac);
    if (longMac < MIN_MACADDRESS_VALUE || MAX_MACADDRESS_VALUE < longMac) {
        String errMsg = String.format(PARSE_ERROR, mac);
        throw new NumberFormatException(errMsg);
    }
    return longMac;
}

From source file:org.patientview.patientview.splashpage.SplashPageEditAction.java

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    String id = BeanUtils.getProperty(form, "id");
    Long idLong = Long.decode(id);

    SplashPage splashpage = LegacySpringUtils.getSplashPageManager().get(idLong);

    request.setAttribute("splashPage", splashpage);

    SplashPageUtils.putSplashPageUnitsInRequest(request);

    return LogonUtils.logonChecks(mapping, request);
}

From source file:org.rockyroadshub.planner.loader.PropertyLoader.java

public Color getColor(Property property) {
    int c = Long.decode(plannerProperties.getString(property.toString())).intValue();
    return new Color(c, true);
}

From source file:org.sonar.java.model.LiteralUtils.java

@CheckForNull
public static Long longLiteralValue(ExpressionTree tree) {
    ExpressionTree expression = tree;/*w  ww  .jav  a 2  s.  c  o m*/

    int sign = tree.is(Kind.UNARY_MINUS) ? -1 : 1;
    if (tree.is(Kind.UNARY_MINUS, Kind.UNARY_PLUS)) {
        expression = ((UnaryExpressionTree) tree).expression();
    }

    if (expression.is(Kind.INT_LITERAL, Kind.LONG_LITERAL)) {
        String value = trimLongSuffix(((LiteralTree) expression).value());
        // long as hexadecimal can be written using underscore to separate groups
        value = value.replaceAll("\\_", "");
        try {
            return sign * Long.decode(value);
        } catch (NumberFormatException e) {
            // Long.decode() may fail in case of very large long number written in hexadecimal. In such situation, we ignore the number.
            // Note that Long.MAX_VALUE = "0x7FFF_FFFF_FFFF_FFFFL", but it is possible to write larger numbers in hexadecimal
            // to be used as mask in bitwise operation. For instance:
            // 0x8000_0000_0000_0000L (MAX_VALUE + 1),
            // 0xFFFF_FFFF_FFFF_FFFFL (only ones),
            // 0xFFFF_FFFF_FFFF_FFFEL (only ones except least significant bit), ...
        }
    }
    return null;
}

From source file:org.apache.tajo.validation.MaxValidator.java

@Override
protected <T> boolean validateInternal(T object) {
    boolean result = false;

    if (object != null) {
        if ((object instanceof Byte) || (object instanceof Short) || (object instanceof Integer)) {
            Integer objInteger = Integer.decode(object.toString());
            Integer maxInteger = Integer.decode(maxValue);
            result = objInteger.compareTo(maxInteger) <= 0;
        } else if (object instanceof Long) {
            Long objLong = Long.decode(object.toString());
            Long maxLong = Long.decode(maxValue);
            result = objLong.compareTo(maxLong) <= 0;
        } else if ((object instanceof Float) || (object instanceof Double)) {
            Double objDouble = Double.valueOf(object.toString());
            Double maxDouble = Double.valueOf(maxValue);
            result = objDouble.compareTo(maxDouble) <= 0;
        } else if (object instanceof BigInteger) {
            BigInteger objInteger = (BigInteger) object;
            BigInteger maxInteger = new BigInteger(maxValue);
            result = objInteger.compareTo(maxInteger) <= 0;
        } else if (object instanceof BigDecimal) {
            BigDecimal objDecimal = (BigDecimal) object;
            BigDecimal maxDecimal = new BigDecimal(maxValue);
            result = objDecimal.compareTo(maxDecimal) <= 0;
        }/*from   w w w .  jav  a2s .  co m*/
    } else {
        result = true;
    }

    return result;
}

From source file:org.patientview.patientview.splashpage.SplashPageUpdateAction.java

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    SplashPage splashPage;//from   w w  w  . ja v a  2  s .  com
    String idStr = BeanUtils.getProperty(form, "id");
    if (idStr != null && !idStr.equals("")) {
        splashPage = LegacySpringUtils.getSplashPageManager().get(Long.decode(idStr));
    } else {
        splashPage = new SplashPage();
    }

    BeanUtils.setProperty(splashPage, "name", BeanUtils.getProperty(form, "name"));
    BeanUtils.setProperty(splashPage, "headline", BeanUtils.getProperty(form, "headline"));
    BeanUtils.setProperty(splashPage, "bodytext", BeanUtils.getProperty(form, "bodytext"));
    BeanUtils.setProperty(splashPage, "unitcode", BeanUtils.getProperty(form, "unitcode"));
    String stringLive = BeanUtils.getProperty(form, "live");
    boolean isLive = "true".equals(stringLive);
    splashPage.setLive(isLive);

    LegacySpringUtils.getSplashPageManager().save(splashPage);

    request.setAttribute("splashPage", splashPage);

    List<SplashPage> splashpages = LegacySpringUtils.getSplashPageManager().getAll();
    request.setAttribute("splashpages", splashpages);

    return LogonUtils.logonChecks(mapping, request);
}

From source file:org.apache.tajo.validation.MinValidator.java

@Override
protected <T> boolean validateInternal(T object) {
    boolean result = false;

    if (object != null) {
        if ((object instanceof Byte) || (object instanceof Short) || (object instanceof Integer)) {
            Integer objInteger = Integer.decode(object.toString());
            Integer minInteger = Integer.decode(minValue);
            result = objInteger.compareTo(minInteger) >= 0;
        } else if (object instanceof Long) {
            Long objLong = Long.decode(object.toString());
            Long minLong = Long.decode(minValue);
            result = objLong.compareTo(minLong) >= 0;
        } else if ((object instanceof Float) || (object instanceof Double)) {
            Double objDouble = Double.valueOf(object.toString());
            Double minDouble = Double.valueOf(minValue);
            result = objDouble.compareTo(minDouble) >= 0;
        } else if (object instanceof BigInteger) {
            BigInteger objInteger = (BigInteger) object;
            BigInteger minInteger = new BigInteger(minValue);
            result = objInteger.compareTo(minInteger) >= 0;
        } else if (object instanceof BigDecimal) {
            BigDecimal objDecimal = (BigDecimal) object;
            BigDecimal minDecimal = new BigDecimal(minValue);
            result = objDecimal.compareTo(minDecimal) >= 0;
        } else if (object instanceof String) {
            BigDecimal objDecimal = new BigDecimal((String) object);
            BigDecimal minDecimal = new BigDecimal(minValue);
            result = objDecimal.compareTo(minDecimal) >= 0;
        }//from  w w  w . ja  va  2 s .co m
    } else {
        result = true;
    }

    return result;
}

From source file:org.patientview.patientview.patiententry.PatientResultDeleteAction.java

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    String patientResultKeyString = BeanUtils.getProperty(form, "patientResultKey");
    String patientResultName = BeanUtils.getProperty(form, "patientResultName");

    HttpSession session = request.getSession();
    Map<Long, PatientEnteredResult> patientResults = (Map<Long, PatientEnteredResult>) session
            .getAttribute(patientResultName);

    Long patientResultKey = Long.decode(patientResultKeyString);

    patientResults.remove(patientResultKey);

    return mapping.findForward("success");
}

From source file:org.lieuofs.canton.biz.dao.CantonOFSFichierTxtDao.java

/**************************************************/

@Override/*from w  ww.j  a  v  a  2 s .c  om*/
protected void traiterLigneFichier(String... tokens) throws ParseException {
    Canton canton = new Canton();
    canton.setId(Long.decode(tokens[0].trim()));
    canton.setCodeISO2(tokens[1].trim());
    canton.setNom(tokens[2].trim());
    canton.setDernierChangement(getDateFmt().parse(tokens[3].trim()));
    stockerCanton(canton);
}

From source file:org.jboss.dashboard.ui.components.WorkspacesHandler.java

protected void beforeInvokeAction(CommandRequest request, String action) {
    //Old commands depended on these parameters to affect navigation status
    String workspaceId = request.getRequestObject().getParameter("idWorkspace");
    String pageId = request.getRequestObject().getParameter("idSection");
    try {/*  ww  w.j ava2s .c  o  m*/
        if (!StringUtils.isEmpty(workspaceId) && !StringUtils.isEmpty(pageId)) {
            WorkspaceImpl workspace = (WorkspaceImpl) UIServices.lookup().getWorkspacesManager()
                    .getWorkspace(workspaceId);
            Section page = workspace.getSection(Long.decode(pageId));
            getNavigatorManager().setCurrentSection(page);
        }
    } catch (Exception e) {
        log.error("Error in beforeInvokeAction: ", e);
    }
}