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.jboss.dashboard.ui.config.components.sections.SectionCopyFormatter.java

public void service(HttpServletRequest request, HttpServletResponse response) throws FormatterException {

    try {//  ww w .  j  av a  2 s  . com
        WorkspaceImpl workspace = (WorkspaceImpl) getSectionsPropertiesHandler().getWorkspace();
        setAttribute("sectionTitle", getLocalizedValue(workspace
                .getSection(Long.decode(getSectionsPropertiesHandler().getSelectedSectionId())).getTitle()));
        renderFragment("outputStart");

        WorkspacePermission sectionPerm = WorkspacePermission.newInstance(workspace,
                WorkspacePermission.ACTION_CREATE_PAGE);
        if (UserStatus.lookup().hasPermission(sectionPerm)) {
            Panel[] panels = workspace
                    .getSection(Long.decode(getSectionsPropertiesHandler().getSelectedSectionId()))
                    .getAllPanels();
            TreeSet panelInstances = new TreeSet();
            for (int i = 0; i < panels.length; i++) {
                Panel panel = panels[i];
                panelInstances.add(panel.getInstanceId());
            }
            if (!panelInstances.isEmpty()) {
                setAttribute("sectionTitle",
                        LocaleManager.lookup().localize(workspace
                                .getSection(Long.decode(getSectionsPropertiesHandler().getSelectedSectionId()))
                                .getTitle()));
                renderFragment("outputMode");

                renderFragment("outputHeaders");
                Iterator it = panelInstances.iterator();
                int counter = 0;
                while (it.hasNext()) {
                    String instanceId = it.next().toString();
                    PanelInstance instance = workspace.getPanelInstance(instanceId);
                    setAttribute("instanceId", instanceId);
                    setAttribute("group", instance.getResource(instance.getProvider().getGroup(), getLocale()));
                    setAttribute("description",
                            instance.getResource(instance.getProvider().getDescription(), getLocale()));
                    setAttribute("title", getLocalizedValue(instance.getTitle()));
                    setAttribute("counter", counter);
                    counter++;
                    renderFragment("outputOpt");
                }
                renderFragment("outputOptEnd");
                renderFragment("outputHeadersEnd");
            } else {
                renderFragment("outputEmpty");
                getSectionsPropertiesHandler().setDuplicateSection(Boolean.FALSE);
            }
        }
        renderFragment("outputEnd");
    } catch (Exception e) {
        log.error("Error rendering section copy form: ", e);
    }
}

From source file:org.patientview.patientview.news.NewsPreviewAction.java

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    ActionForward actionForward;/*w ww  . j a va 2  s . c  o  m*/
    String unitcode = BeanUtils.getProperty(form, "unitcode");
    boolean patient = "true".equals(BeanUtils.getProperty(form, "patient"));
    boolean admin = "true".equals(BeanUtils.getProperty(form, "admin"));
    boolean everyone = "true".equals(BeanUtils.getProperty(form, "everyone"));
    String headline = BeanUtils.getProperty(form, "headline");
    String body = BeanUtils.getProperty(form, "body");
    News news = new News(unitcode, admin, patient, everyone, headline, body);
    String id = BeanUtils.getProperty(form, "id");
    if (!"".equals(id)) {
        news.setId(Long.decode(id));
    }
    if ("Preview".equals(BeanUtils.getProperty(form, "submission"))) {
        request.setAttribute("news", news);
        actionForward = mapping.findForward("preview");
    } else {
        LegacySpringUtils.getNewsManager().save(news);
        NewsUtils.putAppropriateNewsForEditInRequest(request);
        actionForward = mapping.findForward("add");
    }
    return actionForward;
}

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

public CommandResponse actionDownload(CommandRequest request) throws Exception {
    final String dbid = request.getParameter("dbid");
    final GraphicElement[] element = new GraphicElement[] { null };
    if (dbid != null) {
        new HibernateTxFragment() {
            protected void txFragment(Session session) throws Exception {
                element[0] = (GraphicElement) session.get(GraphicElement.class, Long.decode(dbid));
            }//from   w w w  . j  a  v a 2  s  .c om
        }.execute();
        if (element[0] != null) {
            return new SendStreamResponse(new ByteArrayInputStream(element[0].getZipFile()),
                    "inline; filename=" + URLEncoder.encode(element[0].getId()) + ".zip;");
        }
    }
    return null;
}

From source file:org.patientview.patientview.aboutme.AboutmeUpdate.java

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

    User user = UserUtils.retrieveUser(request);

    String id = BeanUtils.getProperty(form, "id");
    String aboutme = BeanUtils.getProperty(form, "aboutme");
    String talkabout = BeanUtils.getProperty(form, "talkabout");
    String nhsno = BeanUtils.getProperty(form, "nhsno");

    Aboutme aboutMe = null;/* w  w  w  .  ja  v  a2s  . c  o m*/

    if (id == null || "".equals(id)) {
        UserMapping userMapping = UserUtils.retrieveUserMappingsPatientEntered(user);
        nhsno = userMapping.getNhsno();

        aboutMe = new Aboutme(nhsno, aboutme, talkabout);
    } else {
        Long idLong = Long.decode(id);

        aboutMe = new Aboutme(idLong, nhsno, aboutme, talkabout);
    }

    LegacySpringUtils.getAboutmeManager().save(aboutMe);

    request.setAttribute("user", user);
    request.setAttribute("aboutme", aboutMe);

    return LogonUtils.logonChecks(mapping, request, "success");
}

From source file:net.openhft.chronicle.queue.ChronicleReaderMain.java

private static void configureReader(final ChronicleReader chronicleReader, final CommandLine commandLine) {
    if (commandLine.hasOption('i')) {
        stream(commandLine.getOptionValues('i')).forEach(chronicleReader::withInclusionRegex);
    }// w w w .j av  a  2s  . com
    if (commandLine.hasOption('e')) {
        stream(commandLine.getOptionValues('e')).forEach(chronicleReader::withExclusionRegex);
    }
    if (commandLine.hasOption('f')) {
        chronicleReader.tail();
    }
    if (commandLine.hasOption('m')) {
        chronicleReader.historyRecords(Long.parseLong(commandLine.getOptionValue('m')));
    }
    if (commandLine.hasOption('n')) {
        chronicleReader.withStartIndex(Long.decode(commandLine.getOptionValue('n')));
    }
    if (commandLine.hasOption('r')) {
        chronicleReader.asMethodReader();
    }
    if (commandLine.hasOption('w')) {
        chronicleReader.withWireType(WireType.valueOf(commandLine.getOptionValue('w')));
    }
    if (commandLine.hasOption('s')) {
        chronicleReader.suppressDisplayIndex();
    }
}

From source file:UUID.java

/**
 * DOCUMENT ME!/* w  w  w . j av  a 2 s .c  o  m*/
 *
 * @param s DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 */
public static UUID fromString(String s) {
    String[] as = s.split("-");

    if (as.length != 5) {
        throw new IllegalArgumentException(
                (new StringBuffer()).append("Invalid UUID string: ").append(s).toString());
    }

    for (int i = 0; i < 5; i++)
        as[i] = (new StringBuffer()).append("0x").append(as[i]).toString();

    long l = Long.decode(as[0]).longValue();
    l <<= 16;
    l |= Long.decode(as[1]).longValue();
    l <<= 16;
    l |= Long.decode(as[2]).longValue();

    long l1 = Long.decode(as[3]).longValue();
    l1 <<= 48;
    l1 |= Long.decode(as[4]).longValue();

    return new UUID(l, l1);
}

From source file:com.milaboratory.mitcr.cli.Main.java

public static void main(String[] args) {
    int o = 0;// www. j a v a 2s .  com

    BuildInformation buildInformation = BuildInformationProvider.get();

    final boolean isProduction = "default".equals(buildInformation.scmBranch); // buildInformation.version != null && buildInformation.version.lastIndexOf("SNAPSHOT") < 0;

    orderingMap.put(PARAMETERS_SET_OPTION, o++);
    orderingMap.put(SPECIES_OPTION, o++);
    orderingMap.put(GENE_OPTION, o++);
    orderingMap.put(ERROR_CORECTION_LEVEL_OPTION, o++);
    orderingMap.put(QUALITY_THRESHOLD_OPTION, o++);
    orderingMap.put(AVERAGE_QUALITY_OPTION, o++);
    orderingMap.put(LQ_OPTION, o++);
    orderingMap.put(CLUSTERIZATION_OPTION, o++);
    orderingMap.put(INCLUDE_CYS_PHE_OPTION, o++);
    orderingMap.put(LIMIT_OPTION, o++);
    orderingMap.put(EXPORT_OPTION, o++);
    orderingMap.put(REPORT_OPTION, o++);
    orderingMap.put(REPORTING_LEVEL_OPTION, o++);
    orderingMap.put(PHRED33_OPTION, o++);
    orderingMap.put(PHRED64_OPTION, o++);
    orderingMap.put(THREADS_OPTION, o++);
    orderingMap.put(COMPRESSED_OPTION, o++);
    orderingMap.put(PRINT_HELP_OPTION, o++);
    orderingMap.put(PRINT_VERSION_OPTION, o++);
    orderingMap.put(PRINT_DEBUG_OPTION, o++);

    options.addOption(OptionBuilder.withArgName("preset name").hasArg()
            .withDescription("preset of pipeline parameters to use").create(PARAMETERS_SET_OPTION));

    options.addOption(OptionBuilder.withArgName("species").hasArg()
            .withDescription("overrides species ['hs' for Homo sapiens, 'mm' for us Mus musculus] "
                    + "(default for built-in presets is 'hs')")
            .create(SPECIES_OPTION));

    options.addOption(OptionBuilder.withArgName("gene").hasArg()
            .withDescription("overrides gene: TRB or TRA (default value for built-in parameter sets is TRB)")
            .create(GENE_OPTION));

    options.addOption(OptionBuilder.withArgName("0|1|2").hasArg()
            .withDescription(
                    "overrides error correction level (0 = don't correct errors, 1 = correct sequenecing "
                            + "errors only (see -" + QUALITY_THRESHOLD_OPTION + " and -" + LQ_OPTION
                            + " options for details), " + "2 = also correct PCR errors (see -"
                            + CLUSTERIZATION_OPTION + " option)")
            .create(ERROR_CORECTION_LEVEL_OPTION));

    options.addOption(OptionBuilder.withArgName("value").hasArg().withDescription(
            "overrides quality threshold value for segment alignment and bad quality sequences "
                    + "correction algorithms. 0 tells the program not to process quality information. (default is 25)")
            .create(QUALITY_THRESHOLD_OPTION));

    if (!isProduction)
        options.addOption(OptionBuilder.hasArg(false)
                .withDescription("use this option to output average instead of "
                        + "maximal, quality for CDR3 nucleotide sequences. (Experimental option, use with caution.)")
                .create(AVERAGE_QUALITY_OPTION));

    options.addOption(OptionBuilder.withArgName("map | drop").hasArg()
            .withDescription("overrides low quality CDR3s processing strategy (drop = filter off, "
                    + "map = map onto clonotypes created from the high quality CDR3s). This option makes no difference if "
                    + "quality threshold (-" + QUALITY_THRESHOLD_OPTION
                    + " option) is set to 0, or error correction " + "level (-" + ERROR_CORECTION_LEVEL_OPTION
                    + ") is 0.")
            .create(LQ_OPTION));

    options.addOption(OptionBuilder.withArgName("smd | ete").hasArg()
            .withDescription("overrides the PCR error correction algorithm: smd = \"save my diversity\", "
                    + "ete = \"eliminate these errors\". Default value for built-in parameters is ete.")
            .create(CLUSTERIZATION_OPTION));

    options.addOption(OptionBuilder.withArgName("0|1").hasArg()
            .withDescription("overrides weather include bounding Cys & Phe into CDR3 sequence")
            .create(INCLUDE_CYS_PHE_OPTION));

    options.addOption(
            OptionBuilder.withArgName("# of reads").hasArg()
                    .withDescription("limits the number of input sequencing reads, use this parameter to "
                            + "normalize several datasets or to have a glance at the data")
                    .create(LIMIT_OPTION));

    options.addOption(OptionBuilder.withArgName("new name").hasArg()
            .withDescription("use this option to export presets to a local xml files").create(EXPORT_OPTION));

    options.addOption(OptionBuilder.withArgName("file name").hasArg()
            .withDescription("use this option to write analysis report (summary) to file")
            .create(REPORT_OPTION));

    options.addOption(OptionBuilder.withArgName("1|2|3").hasArg(true)
            .withDescription("output detalization level (1 = simple, 2 = medium, 3 = full, this format "
                    + "could be deserialized using mitcr API). Affects only tab-delimited output. Default value is 3.")
            .create(REPORTING_LEVEL_OPTION));

    options.addOption(OptionBuilder.hasArg(false).withDescription(
            "add this option if input file is in old illumina format with 64 byte offset for quality "
                    + "string (MiTCR will try to automatically detect file format if one of the \"-phredXX\" options is not provided)")
            .create(PHRED64_OPTION));

    options.addOption(OptionBuilder.hasArg(false)
            .withDescription("add this option if input file is in Phred+33 format for quality values "
                    + "(MiTCR will try to automatically detect file format if one of the \"-phredXX\" options is not provided)")
            .create(PHRED33_OPTION));

    options.addOption(OptionBuilder.withArgName("threads").hasArg()
            .withDescription(
                    "specifies the number of CDR3 extraction threads (default = number of available CPU cores)")
            .create(THREADS_OPTION));

    if (!isProduction)
        options.addOption(OptionBuilder.hasArg(false)
                .withDescription("use compressed data structures for storing individual "
                        + "clone segments statistics (from which arises the clone segment information). This option reduces required "
                        + "amount of memory, but introduces small stochastic errors into the algorithm which determines clone "
                        + "segments. (Experimental option, use with caution.)")
                .create(COMPRESSED_OPTION));

    options.addOption(
            OptionBuilder.hasArg(false).withDescription("print this message").create(PRINT_HELP_OPTION));

    options.addOption(OptionBuilder.hasArg(false).withDescription("print version information")
            .create(PRINT_VERSION_OPTION));

    options.addOption(OptionBuilder.hasArg(false)
            .withDescription("print additional information about analysis process").create(PRINT_DEBUG_OPTION));

    PosixParser parser = new PosixParser();

    try {
        long input_limit = -1;
        int threads = Runtime.getRuntime().availableProcessors();
        int reporting_level = 3;
        int ec_level = 2;

        CommandLine cl = parser.parse(options, args, true);
        if (cl.hasOption(PRINT_HELP_OPTION)) {
            printHelp();
            return;
        }

        boolean averageQuality = cl.hasOption(AVERAGE_QUALITY_OPTION),
                compressedAggregators = cl.hasOption(COMPRESSED_OPTION);

        if (cl.hasOption(PRINT_VERSION_OPTION)) {
            System.out.println("MiTCR by MiLaboratory, version: " + buildInformation.version);
            System.out.println("Branch: " + buildInformation.scmBranch);
            System.out.println("Built: " + buildInformation.buildDate + ", " + buildInformation.jdk + " JDK, "
                    + "build machine: " + buildInformation.builtBy);
            System.out.println("SCM changeset: " + buildInformation.scmChangeset + " ("
                    + buildInformation.scmDate.replace("\"", "") + ")");
            return;
        }

        //Normal execution

        String paramName = cl.getOptionValue(PARAMETERS_SET_OPTION);

        if (paramName == null) {
            err.println("No parameters set is specified.");
            return;
        }

        Parameters params = ParametersIO.getParameters(paramName);

        if (params == null) {
            err.println("No parameters set found with name '" + paramName + "'.");
            return;
        }

        String value;

        if ((value = cl.getOptionValue(THREADS_OPTION)) != null)
            threads = Integer.decode(value);

        if ((value = cl.getOptionValue(REPORTING_LEVEL_OPTION)) != null)
            reporting_level = Integer.decode(value);

        if ((value = cl.getOptionValue(LIMIT_OPTION)) != null)
            input_limit = Long.decode(value);

        if ((value = cl.getOptionValue(GENE_OPTION)) != null)
            params.setGene(Gene.fromXML(value));

        if ((value = cl.getOptionValue(SPECIES_OPTION)) != null)
            params.setSpecies(Species.getFromShortName(value));

        if ((value = cl.getOptionValue(INCLUDE_CYS_PHE_OPTION)) != null) {
            if (value.equals("1"))
                params.getCDR3ExtractorParameters().setIncludeCysPhe(true);
            else if (value.equals("0"))
                params.getCDR3ExtractorParameters().setIncludeCysPhe(false);
            else {
                err.println("Illegal value for -" + INCLUDE_CYS_PHE_OPTION + " parameter.");
                return;
            }
        }

        if ((value = cl.getOptionValue(ERROR_CORECTION_LEVEL_OPTION)) != null) {
            int v = Integer.decode(value);
            ec_level = v;
            if (v == 0) {
                params.setCloneGeneratorParameters(new BasicCloneGeneratorParameters());
                params.setClusterizationType(CloneClusterizationType.None);
            } else if (v == 1) {
                params.setCloneGeneratorParameters(new LQMappingCloneGeneratorParameters());
                params.setClusterizationType(CloneClusterizationType.None);
            } else if (v == 2) {
                params.setCloneGeneratorParameters(new LQMappingCloneGeneratorParameters());
                params.setClusterizationType(CloneClusterizationType.OneMismatch, .1f);
            } else
                throw new RuntimeException("This (" + v + ") error correction level is not supported.");
        }

        if ((value = cl.getOptionValue(QUALITY_THRESHOLD_OPTION)) != null) {
            int v = Integer.decode(value);
            if (v == 0)
                params.setQualityInterpretationStrategy(new DummyQualityInterpretationStrategy());
            else
                params.setQualityInterpretationStrategy(new IlluminaQualityInterpretationStrategy((byte) v));
        }

        if ((value = cl.getOptionValue(LQ_OPTION)) != null)
            if (ec_level > 0)
                switch (value) {
                case "map":
                    params.setCloneGeneratorParameters(new LQMappingCloneGeneratorParameters(
                            ((BasicCloneGeneratorParameters) params.getCloneGeneratorParameters())
                                    .getSegmentInformationAggregationFactor(),
                            3, true));
                    break;
                case "drop":
                    params.setCloneGeneratorParameters(new LQFilteringOffCloneGeneratorParameters(
                            ((BasicCloneGeneratorParameters) params.getCloneGeneratorParameters())
                                    .getSegmentInformationAggregationFactor()));
                    break;
                default:
                    throw new RuntimeException("Wrong value for -" + LQ_OPTION + " option.");
                }

        if ((value = cl.getOptionValue(CLUSTERIZATION_OPTION)) != null)
            if (ec_level > 1) // == 2
                switch (value) {
                case "smd":
                    params.setClusterizationType(CloneClusterizationType.V2D1J2T3Explicit);
                    break;
                case "ete":
                    params.setClusterizationType(CloneClusterizationType.OneMismatch);
                    break;
                default:
                    throw new RuntimeException("Wrong value for -" + CLUSTERIZATION_OPTION + " option.");
                }

        ((BasicCloneGeneratorParameters) params.getCloneGeneratorParameters())
                .setAccumulatorType(AccumulatorType.get(compressedAggregators, averageQuality));

        if ((value = cl.getOptionValue(EXPORT_OPTION)) != null) {
            //Exporting parameters
            ParametersIO.exportParameters(params, value);
            return;
        }

        String[] offArgs = cl.getArgs();

        if (offArgs.length == 0) {
            err.println("Input file not specified.");
            return;
        } else if (offArgs.length == 1) {
            err.println("Output file not specified.");
            return;
        } else if (offArgs.length > 2) {
            err.println("Unrecognized argument.");
            return;
        }

        String inputFileName = offArgs[0];
        String outputFileName = offArgs[1];

        File input = new File(inputFileName);

        if (!input.exists()) {
            err.println("Input file not found.");
            return;
        }

        //TODO This also done inside SFastqReader constructor
        CompressionType compressionType = CompressionType.None;
        if (inputFileName.endsWith(".gz"))
            compressionType = CompressionType.GZIP;

        QualityFormat format = null; // If variable remains null file format will be detected automatically
        if (cl.hasOption(PHRED33_OPTION))
            format = QualityFormat.Phred33;
        if (cl.hasOption(PHRED64_OPTION))
            if (format == null)
                format = QualityFormat.Phred64;
            else {
                err.println(
                        "Options: -" + PHRED33_OPTION + " and -" + PHRED64_OPTION + " are mutually exclusive");
                return;
            }

        SFastqReader reads = format == null ? new SFastqReader(input, compressionType)
                : new SFastqReader(input, format, compressionType);

        OutputPort<SSequencingRead> inputToPipeline = reads;
        if (input_limit >= 0)
            inputToPipeline = new CountLimitingOutputPort<>(inputToPipeline, input_limit);

        SegmentLibrary library = DefaultSegmentLibrary.load();

        AnalysisStatisticsAggregator statisticsAggregator = new AnalysisStatisticsAggregator();

        FullPipeline pipeline = new FullPipeline(inputToPipeline, params, false, library);
        pipeline.setThreads(threads);
        pipeline.setAnalysisListener(statisticsAggregator);

        new Thread(new SmartProgressReporter(pipeline, err)).start(); // Printing status to the standard error stream

        pipeline.run();

        if (cl.hasOption(PRINT_DEBUG_OPTION)) {
            err.println("Memory = " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()));
            err.println("Clusterization: " + pipeline.getQC().getReadsClusterized() + "% of reads, "
                    + pipeline.getQC().getClonesClusterized() + " % clones");
        }

        CloneSetClustered cloneSet = pipeline.getResult();

        if ((value = cl.getOptionValue(REPORT_OPTION)) != null) {
            File file = new File(value);
            TablePrintStreamAdapter table;
            if (file.exists())
                table = new TablePrintStreamAdapter(new FileOutputStream(file, true));
            else {
                table = new TablePrintStreamAdapter(file);
                ReportExporter.printHeader(table);
            }
            //CloneSetQualityControl qc = new CloneSetQualityControl(library, params.getSpecies(), params.getGene(), cloneSet);
            ReportExporter.printRow(table, inputFileName, outputFileName, pipeline.getQC(),
                    statisticsAggregator);
            table.close();
        }

        if (outputFileName.endsWith(".cls"))
            ClsExporter.export(pipeline, outputFileName.replace(".cls", "") + " " + new Date().toString(),
                    input.getName(), outputFileName);
        else {
            //Dry run
            if (outputFileName.startsWith("-"))
                return;

            ExportDetalizationLevel detalization = ExportDetalizationLevel.fromLevel(reporting_level);

            CompressionType compressionType1 = CompressionType.None;
            if (outputFileName.endsWith(".gz"))
                compressionType1 = CompressionType.GZIP;
            CloneSetIO.exportCloneSet(outputFileName, cloneSet, detalization, params, input.getAbsolutePath(),
                    compressionType1);
        }
    } catch (ParseException | RuntimeException | IOException e) {
        err.println("Error occurred in the analysis pipeline.");
        err.println();
        e.printStackTrace();
        //printHelp();
    }
}

From source file:org.opendaylight.groupbasedpolicy.neutron.ovsdb.util.InventoryHelper.java

/**
 * Convert an OpenFlow Datapath ID to a Long
 *
 * @param dpid The OpenFlow Datapath ID//from  ww w .j a v a  2  s . c om
 * @return The Long representation of the DPID
 */
public static Long getLongFromDpid(String dpid) {
    String[] addressInBytes = dpid.split(":");
    Long address = (Long.decode(HEX + addressInBytes[2]) << 40) | (Long.decode(HEX + addressInBytes[3]) << 32)
            | (Long.decode(HEX + addressInBytes[4]) << 24) | (Long.decode(HEX + addressInBytes[5]) << 16)
            | (Long.decode(HEX + addressInBytes[6]) << 8) | (Long.decode(HEX + addressInBytes[7]));
    return address;
}

From source file:org.jboss.dashboard.ui.formatters.RenderNestedSectionsFormatter.java

public void service(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
        throws FormatterException {
    List visibleIds = (List) getParameter("visibleIds");
    List checkedIds = (List) getParameter("checkedIds");
    List selectableIds = (List) getParameter("selectableIds");
    String workspaceId = (String) getParameter("workspaceId");
    String rootSectionId = (String) getParameter("rootSectionId");

    boolean showHiddenPages = (!(getParameter("showHiddenPages") != null
            && !"".equals(getParameter("showHiddenPages"))))
            || Boolean.valueOf((String) getParameter("showHiddenPages")).booleanValue();
    Boolean checkPermissions = Boolean.valueOf((String) getParameter("checkPermissions"));
    try {//from  w  ww  . j  av a  2s.c  o m
        WorkspaceImpl currentWorkspace = (WorkspaceImpl) (workspaceId != null && !"".equals(workspaceId)
                ? UIServices.lookup().getWorkspacesManager().getWorkspace(workspaceId)
                : NavigationManager.lookup().getCurrentWorkspace());
        Section[] rootSections;
        if (StringUtils.isEmpty(rootSectionId)) {
            rootSections = currentWorkspace.getAllRootSections();
        } else {
            Section parentSection = currentWorkspace.getSection(Long.decode(rootSectionId));
            List<Section> children = parentSection.getChildren();
            rootSections = children.toArray(new Section[children.size()]);
        }
        renderFragment("outputStart");
        for (Section rootSection : rootSections) {
            renderSection(httpServletRequest, httpServletResponse, rootSection, visibleIds, checkedIds,
                    selectableIds, Boolean.TRUE.equals(checkPermissions), showHiddenPages);
        }
        renderFragment("outputEnd");
    } catch (Exception e) {
        log.error("Error rendering sections: ", e);
    }
}

From source file:pl.nask.hsn2.normalizers.URLNormalizerUtils.java

public static String numToIPv4(StringBuilder sb, int start, int endInd) {
    int end = findFirstMatch(sb, ":/?", start, endInd);
    if (end < 0) {
        end = endInd;/*from   w  w w  . j a  va  2 s . co  m*/
    }
    long ip;
    try {
        ip = Long.decode(sb.substring(start, end));
        if (ip <= 0xffffff) { //disallow 0.x.x.x format
            return null;
        }
    } catch (NumberFormatException e) {
        return null;
    }
    StringBuilder tmp = new StringBuilder();
    for (int i = 0; i < 3; i++) {
        tmp.insert(0, ip & 0xff);
        tmp.insert(0, '.');
        ip = ip >> 8;
    }
    tmp.insert(0, ip & 0xff);
    sb.replace(start, end, tmp.toString());
    return tmp.toString();

}