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.jbpm.formModeler.core.processing.fieldHandlers.multipleSubform.SubFormSendHandler.java

public void previewItem(CommandRequest request, boolean doIt) throws Exception {
    String[] uids = request.getRequestObject().getParameterValues("child_uid_value");
    String uid = "";
    if (uids != null) {
        for (int i = 0; i < uids.length; i++) {
            if (uids[i] != null && !"".equals(uids[i]))
                uid = uids[i];//from ww w  . j  av a 2  s  .c o m
        }
    }
    String index = request.getParameter(uid + "_index");
    String parentFormId = request.getParameter(uid + "_parentFormId");
    String parentNamespace = request.getParameter(uid + "_parentNamespace");
    String inputName = request.getParameter(uid + "_inputName");

    Form form = subformFinderService.getFormById(Long.decode(parentFormId), parentNamespace);
    getFormProcessor().setValues(form, parentNamespace, request.getRequestObject().getParameterMap(),
            request.getFilesByParamName());

    if (doIt) {
        helper.setPreviewFieldPosition(inputName, Integer.decode(index));
    } else {
        helper.clearPreviewFieldPositions(inputName);
    }
    getFormProcessor().clearFieldErrors(form, parentNamespace);
}

From source file:org.soaplab.clients.CmdLineClient.java

static Long getLong(Object value) {
    if (value == null)
        return null;
    try {/*w ww  .ja  v  a2  s .com*/
        return Long.decode(value.toString());
    } catch (NumberFormatException e) {
        return null;
    }
}

From source file:com.yahoo.pulsar.common.naming.NamespaceBundlesTest.java

private void assertBundleDivideInTwo(NamespaceBundle bundle, List<NamespaceBundle> bundles, int numBundles) {
    assertTrue(bundles.size() == 2);/*from  ww w.  j  a  v  a 2 s . co m*/
    String[] range = bundle.getBundleRange().split("_");
    long lower = Long.decode(range[0]);
    long upper = Long.decode(range[1]);
    long middle = ((upper - lower) / 2) + lower;

    String lRange = String.format("0x%08x_0x%08x", lower, middle);
    String uRange = String.format("0x%08x_0x%08x", middle, upper);
    assertTrue(bundles.get(0).getBundleRange().equals(lRange));
    assertTrue(bundles.get(1).getBundleRange().equals(uRange));
    System.out.println(String.format("[%s,%s] => [%s,%s]", range[0], range[1], lRange, uRange));

}

From source file:com.dsi.ant.antplus.pluginsampler.geocache.Dialog_GeoDeviceDetails.java

/**
 * This function returns a PIN that should be static and persistent on the device running this phone.
 * The geocache profile states//from  w w  w  .j a v  a2s  . c o m
 * The ANDROID_ID is not perfect for a static identifier but does the job fine enough for a demo app.
 * (see {@link "http://android-developers.blogspot.ca/2011/03/identifying-app-installations.html"})
 * @param context The current context.
 * @return PIN for programming that is unique to and persistent on this device
 */
public static Long getDeviceBasedPIN(Context context) {
    String IdString = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
    if (IdString == null)
        return 336699L;
    else
        return Long.decode("0x" + IdString.substring(IdString.length() - 9)) % 4294967295L;
}

From source file:org.jboss.dashboard.workspace.export.WorkspaceBuilder.java

protected void createPanel(CreateResult result, Section section, XMLNode node, Map attributes,
        boolean onStartup) throws Exception {
    String id = node.getAttributes().getProperty(ExportVisitor.PANEL_ATTR_ID);
    String instanceId = node.getAttributes().getProperty(ExportVisitor.PANEL_ATTR_INSTANCE_ID);
    String regionId = node.getAttributes().getProperty(ExportVisitor.PANEL_ATTR_REGION_ID);
    String position = node.getAttributes().getProperty(ExportVisitor.PANEL_ATTR_POSITION);
    Panel panel = new Panel();
    panel.setSection(section);/*ww w . j  a v  a2 s. co m*/
    panel.setPosition(Integer.decode(position).intValue());
    panel.setPanelId(Long.decode(id));
    panel.setInstanceId(Long.decode(instanceId));
    if (regionId != null) {
        panel.getProvider().getDriver().fireBeforePanelPlacedInRegion(panel,
                section.getLayout().getRegion(regionId));
        panel.setLayoutRegionId(regionId);
    }
    UIServices.lookup().getPanelsManager().store(panel);
    // Add panel to section
    section.assignPanel(panel, regionId);
    UIServices.lookup().getSectionsManager().store(section);
    panel.getProvider().getDriver().fireAfterPanelPlacedInRegion(panel, null);
    for (int i = 0; i < node.getChildren().size(); i++) {
        XMLNode child = (XMLNode) node.getChildren().get(i);
        if (ExportVisitor.PERMISSION.equals(child.getObjectName())) {
            createPermission(result, panel.getWorkspace(), panel, child, attributes);
        }
    }
}

From source file:org.apache.pulsar.common.naming.NamespaceBundlesTest.java

private void assertBundleDivideInTwo(NamespaceBundle bundle, List<NamespaceBundle> bundles, int numBundles) {
    assertTrue(bundles.size() == 2);/* w  w  w . j a  v a2 s. c  o m*/
    String[] range = bundle.getBundleRange().split("_");
    long lower = Long.decode(range[0]);
    long upper = Long.decode(range[1]);
    long middle = ((upper - lower) / 2) + lower;

    String lRange = String.format("0x%08x_0x%08x", lower, middle);
    String uRange = String.format("0x%08x_0x%08x", middle, upper);
    assertTrue(bundles.get(0).getBundleRange().equals(lRange));
    assertTrue(bundles.get(1).getBundleRange().equals(uRange));
    log.info("[{},{}] => [{},{}]", range[0], range[1], lRange, uRange);
}

From source file:org.apache.cocoon.acting.DbXMLAuthenticatorAction.java

private HashMap propagateParameters(Configuration conf, ResourceSet resultSet, Session session) {

    Configuration table = conf.getChild("root");
    Configuration[] select = table.getChildren("select");
    String session_param, type;//from   ww w . j a  v a 2s .c o m
    HashMap map = new HashMap();

    XObject xo;
    Node originalnode = null;

    try {

        ResourceIterator results = resultSet.getIterator();

        // Create an XObject to be used in Xpath query
        xo = new XObject();

        // Retrieve the next node
        XMLResource resource = (XMLResource) results.nextResource();

        originalnode = resource.getContentAsDOM();

    } catch (Exception e) {
        getLogger().debug("DBXMLAUTH: error creating XObject ");
    }

    try {
        for (int i = 0; i < select.length; i++) {
            try {
                session_param = select[i].getAttribute("to-session");
                if (session_param != null && !session_param.trim().equals("")) {

                    String s = "";

                    try {
                        // Use Xalan xpath parser to extract data
                        xo = XPathAPI.eval(originalnode,
                                "/" + table.getAttribute("name") + "/" + select[i].getAttribute("element"));
                        s = xo.toString();
                    } catch (Exception e) {
                    }

                    /* propagate to session */
                    try {
                        type = select[i].getAttribute("type");
                    } catch (Exception e) {
                        type = null;
                    }

                    if (type == null || "".equals(type.trim())) {
                        type = "string";
                    }
                    Object o = null;

                    if ("string".equals(type)) {
                        o = s;
                    } else if ("long".equals(type)) {
                        Long l = Long.decode(s);
                        o = l;
                    } else if ("double".equals(type)) {
                        Double d = Double.valueOf(s);
                        o = d;
                    }

                    if (session != null) {
                        session.setAttribute(session_param, o);
                        getLogger().debug("DBXMLAUTH: propagating param " + session_param + "=" + s);
                    }
                    map.put(session_param, o);
                }
            } catch (Exception e) {
            }
        }
        return map;
    } catch (Exception e) {
        getLogger().debug("exception: ", e);
    }
    return null;
}

From source file:controllers.Service.java

public static void surveyHasImages(String surveyId) {
    Survey survey = Survey.findById(Long.decode(surveyId));

    boolean hasImages = false;

    for (Category category : survey.categoryCollection) {
        for (Question question : category.questionCollection) {
            if (question.questionType.typeName.equals(QuestionTypesConsts.IMAGE)) {
                hasImages = true;/*ww  w. j a  v a  2  s. co m*/
                break;
            }
        }
    }

    JSONSerializer surveyListSerializer = new JSONSerializer();
    surveyListSerializer.include("*").rootName("hasImages");
    renderJSON(surveyListSerializer.serialize(hasImages));
}

From source file:org.jbpm.formModeler.core.processing.fieldHandlers.multipleSubform.SubFormSendHandler.java

public void editItem(CommandRequest request, boolean doIt) throws Exception {
    String[] uids = request.getRequestObject().getParameterValues("child_uid_value");
    String uid = "";
    if (uids != null) {
        for (int i = 0; i < uids.length; i++) {
            if (uids[i] != null && !"".equals(uids[i]))
                uid = uids[i];/*from ww  w . j  a v a  2 s . c om*/
        }
    }
    String index = request.getParameter(uid + "_index");
    String parentFormId = request.getParameter(uid + "_parentFormId");
    String parentNamespace = request.getParameter(uid + "_parentNamespace");
    String fieldName = request.getParameter(uid + "_field");
    String inputName = request.getParameter(uid + "_inputName");

    Form form = subformFinderService.getFormById(Long.decode(parentFormId), parentNamespace);
    Field field = form.getField(fieldName);

    getFormProcessor().setValues(form, parentNamespace, request.getRequestObject().getParameterMap(),
            request.getFilesByParamName());

    if (doIt) {
        FormStatusData fsd = getFormProcessor().read(form, parentNamespace);
        Map[] previousValue = deepCloneOfMapArray((Map[]) fsd.getCurrentValue(fieldName), new HashMap());
        helper.setEditFieldPreviousValues(inputName, previousValue);
        CreateDynamicObjectFieldHandler fieldHandler = (CreateDynamicObjectFieldHandler) getFieldHandlersManager()
                .getHandler(field.getFieldType());

        Form formToEdit = fieldHandler.getEditForm(field, parentNamespace);

        getFormProcessor().clear(formToEdit,
                parentNamespace + FormProcessor.NAMESPACE_SEPARATOR + parentFormId
                        + FormProcessor.NAMESPACE_SEPARATOR + fieldName
                        + FormProcessor.CUSTOM_NAMESPACE_SEPARATOR + index);
        getFormProcessor().clear(formToEdit, parentNamespace + FormProcessor.NAMESPACE_SEPARATOR + parentFormId
                + FormProcessor.NAMESPACE_SEPARATOR + fieldName);
        helper.setEditFieldPosition(inputName, Integer.decode(index));
    } else {
        Object previousValue = helper.getEditFieldPreviousValues(inputName);
        getFormProcessor().modify(form, parentNamespace, fieldName, previousValue);
        helper.clearExpandedField(inputName);
        helper.clearEditFieldPositions(inputName);
        helper.clearEditFieldPreviousValues(inputName);
        helper.clearPreviewFieldPositions(inputName);
    }
    getFormProcessor().clearFieldErrors(form, parentNamespace);
}

From source file:org.apache.cocoon.acting.DatabaseCookieAuthenticatorAction.java

/**
 *  Description of the Method/*from   w ww .  ja va2  s .  c  o  m*/
 *
 * @param  conf     Description of Parameter
 * @param  rs       Description of Parameter
 * @param  session  Description of Parameter
 * @return          Description of the Returned Value
 */
private HashMap propagateParameters(Configuration conf, ResultSet rs, Session session) {
    Configuration table = conf.getChild("table");
    Configuration[] select = table.getChildren("select");
    String session_param;
    HashMap map = new HashMap();
    try {
        for (int i = 0; i < select.length; i++) {
            try {
                session_param = select[i].getAttribute("to-session");
                if (session_param != null && !session_param.trim().equals("")) {
                    String s = rs.getString(i + 1);
                    /*
                     *  propagate to session
                     */
                    Object o = null;
                    String type = select[i].getAttribute("type", "");
                    // "string" is the default type
                    if (StringUtils.isEmpty(type.trim()) || "string".equals(type)) {
                        o = s;
                    } else if ("long".equals(type)) {
                        Long l = Long.decode(s);
                        o = l;
                    } else if ("double".equals(type)) {
                        Double d = Double.valueOf(s);
                        o = d;
                    }
                    if (session != null) {
                        session.setAttribute(session_param, o);
                        if (getLogger().isDebugEnabled()) {
                            getLogger().debug("DBCOOKIEAUTH: propagating param " + session_param + "=" + s);
                        }
                    }
                    map.put(session_param, o);
                }
            } catch (Exception e) {
                // ignore
            }
        }
        return map;
    } catch (Exception e) {
        getLogger().error("Exception: ", e);
    }
    return null;
}