Java Utililty Methods Stack Usage

List of utility methods to do Stack Usage

Description

The list of methods to do Stack Usage are organized into topic(s).

Method

StringremoveDotSegments(String relativePath)
remove Dot Segments
int pos = relativePath.indexOf('?');
if (pos != -1) {
    relativePath = relativePath.substring(0, pos);
pos = relativePath.indexOf('#');
if (pos != -1) {
    relativePath = relativePath.substring(0, pos);
if (relativePath.indexOf('/') == -1) {
    return relativePath;
String[] parts = relativePath.split("/");
Stack<String> path = new Stack<String>();
String part;
for (int i = 0; i < parts.length; i++) {
    part = parts[i].trim();
    if (part.isEmpty() || part.equals(".")) {
    } else if (part.equals("..")) {
        path.pop();
    } else {
        path.add(part);
String absoluteUrl = "";
if (path.size() > 0) {
    for (int i = 0; i < path.size(); i++) {
        if (i > 0 && path.get(i).indexOf('.') != -1 && path.get(i - 1).equals(path.get(i))) {
            continue;
        absoluteUrl += "/" + path.get(i);
} else {
    absoluteUrl = "/";
if (relativePath.endsWith("/") && !absoluteUrl.endsWith("/")) {
    absoluteUrl = absoluteUrl + "/";
return absoluteUrl;
StringremoveParenthesis(String text)
Removes parenthesis in a string
int pos = text.indexOf('(');
if (pos == -1)
    return text;
Stack<Integer> stack = new Stack<Integer>();
pos = 0;
while (pos < text.length()) {
    if (text.charAt(pos) == '(') {
        stack.push(pos);
...
voidresolveOneLineExpression(String line, String space, List target)
resolve One Line Expression
Stack<Character> stack = new Stack<>();
String expr = removeComments(line);
boolean flag = false;
int index = 0;
for (char c : line.toCharArray()) {
    ++index;
    if (c == '(') {
        if (!flag) {
...
intresolveSeparateIfSentence(List lines, int cursor, List target, String space)
resolve Separate If Sentence
int next = cursor + 1;
int end = indexOfSeparateIfSentence(lines, lines.get(cursor), next);
if (end != -1) {
    for (int i = cursor; i < end; i++) {
        target.add(lines.get(i));
    target.add(lines.get(end) + " {");
    target.add(lines.get(end + 1));
...
String[]split(final String str)
Splits the provided text into an array, using whitespace as the separator.
return split(str, null, -1);
String[]split(String string, String token)
Same as calling split(string, token, 0)
return split(string, token, 0);