Java List Create createHTMLList(String list, String link, boolean APPEND, String title)

Here you can find the source of createHTMLList(String list, String link, boolean APPEND, String title)

Description

Convert a line separated list into an HTML list of links.

License

Open Source License

Parameter

Parameter Description
list the line separated list of items
link the URL base
APPEND true if list items should be appended to the end of link
title the title of the generated HTML page (can be null)

Return

an HTML version of the given list

Declaration

public static String createHTMLList(String list, String link,
        boolean APPEND, String title) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.*;

public class Main {
    /**//from w  w  w . ja  v a  2  s  .c  om
     * Convert a line separated list into an HTML list of links.
     * @param list the line separated list of items
     * @param link the URL base
     * @param APPEND true if list items should be appended to the end of link
     * @param title the title of the generated HTML page (can be null)
     * @return an HTML version of the given list
     */
    public static String createHTMLList(String list, String link,
            boolean APPEND, String title) {
        String buffer = "";
        Scanner scanner = new Scanner(list);
        String line, endpoint;
        int tmpi;

        if (title != null) {
            buffer += "<h1>" + title + "</h1>\n";
        }

        buffer += "<ul>\n";

        while (scanner.hasNextLine()) {
            line = scanner.nextLine().trim();
            endpoint = line;
            tmpi = endpoint.indexOf('(');

            if (tmpi >= 0) { //Remove full application name within parenthesis of software list
                endpoint = endpoint.substring(0, tmpi).trim();
            }

            buffer += "<li><a href=\"" + link;
            if (APPEND)
                buffer += endpoint;
            buffer += "\">" + line + "</a></li>\n";
        }

        buffer += "</ul>\n";
        scanner.close(); // added by Edgar Black
        return buffer;
    }
}

Related

  1. createEmptyListArray(int size)
  2. createEmptyListOfType(List original, boolean sameSize)
  3. createEntireInStatement(List values)
  4. createErrorStringFromList(List errorList)
  5. createGrantScript(List objectsToGrant, String grantee)
  6. createIfNull(List list)
  7. createIndicesOrderedList(final Collection order, final Collection values)
  8. createInString(List keys)
  9. createIntArray(List coll)