Java Utililty Methods String Extract

List of utility methods to do String Extract

Description

The list of methods to do String Extract are organized into topic(s).

Method

ListextractGenericTypeNames(String sig)
extract Generic Type Names
List<String> types = new ArrayList<String>();
boolean nameDetected = false;
int currentStart = -1;
for (int i = 0; i < sig.length(); i++) {
    char c = sig.charAt(i);
    switch (c) {
    case '<':
    case ';':
...
StringextractHorizontalTabs(String line, int tabSize)
extract Horizontal Tabs
assert line != null;
StringBuilder buf = new StringBuilder();
int column = 0;
for (int i = 0, n = line.length(); i < n; i++) {
    char c = line.charAt(i);
    if (c == '\t') {
        int count = tabSize - column % tabSize;
        for (int j = 0; j < count; j++) {
...
ListextractItems(String items)
splits a string of type {("A","B","C")} into ["A", "B", "C"]
List<String> itemList = new ArrayList<String>();
if (items == null)
    return itemList;
items = items.replace(" ", ""); 
if (items.split("\"(.)*\"").length == 1)
    return itemList;
String[] arrayItems = items.split("\",");
for (int i = 0; i < arrayItems.length; i++) {
...
StringextractJobId(String line)
extract Job Id
if (line.contains("job_201")) {
    int start = line.indexOf("job_201");
    int end = start;
    for (int i = start + 7; i < line.length(); i++) {
        if (jobIdChars.contains(line.charAt(i))) {
            end = i;
        } else {
            break;
...
ListextractKeyCodes(String codes)
Converts a String representation of a list of codes into a list of integers
if (codes == null)
    throw new RuntimeException("The codes cannot be null");
int index;
int last = 0;
List<Integer> result = new ArrayList<Integer>();
while ((index = codes.indexOf(',', last)) != -1) {
    String code = codes.substring(last, index).trim();
    result.add(Integer.parseInt(code));
...
ArrayListextractLines(String data, int tabWidth)
Extracts lines of text from the specified data.
int length = data.length();
StringBuilder buffer = new StringBuilder(length);
char ignoreCh = 0;
ArrayList<String> lines = new ArrayList<>();
int column = 0;
for (int i = 0; i < length; i++) {
    char ch = data.charAt(i);
    if (ch == ignoreCh) {
...
intextractNoPublicDomains(String domains)
extract No Public Domains
if (domains == null)
    return 0;
return extractNoItems(domains) - extractNoPrivateDomains(domains);
ArrayListextractNumberFromInput(String command)
Returns ArrayList which contains not repeated input numbers
String[] splittedStringIndexes = command.trim().replace(" ", "").split(",");
ArrayList<Integer> intIndexList = new ArrayList<Integer>();
for (String index : splittedStringIndexes) {
    if (index.contains("to")) {
        String[] range = index.split("to");
        int start = Integer.parseInt(range[0]);
        int end = Integer.parseInt(range[1]);
        for (int i = start; i <= end; i++) {
...
String[]extractNumbers(String text)
extract Numbers
if (isEmpty(text))
    return new String[] {};
String[] tmp = text.split("\\D");
List<String> list = new ArrayList<String>();
for (String s : tmp) {
    if (s.length() > 0) {
        list.add(s);
return list.toArray(new String[0]);
ArrayListextractPacket(String serverPacket)
Extracts the valuable information from a packet and cuts out the initial hashtag identifier
ArrayList<String> extractedPacket = new ArrayList<String>();
String[] tmp = serverPacket.split("#");
for (int i = 2; i < tmp.length; i++) {
    extractedPacket.add(tmp[i]);
return extractedPacket;