Checks and returns the table caption keyword at the beginning of a give line

@param line
input line
@return matched keyword if found / null if not found
546749
private String getMatchedTabledKeyword(String line) {
    	for (String keyword : Config.TABLE_KEYWORDS) {
    		if (line.startsWith(keyword)) {
    			return keyword;
    		}
    	}
    	return null;
    }
830711
public String getLabel(final String caption, final boolean captizliseFirstLetter) {
		if (captizliseFirstLetter) {
			return JKFormatUtil.capitalizeFirstLetters(getLabel(caption));
		} else {
			return getLabel(caption);
		}
	}
903329
public static String join(String start, String linePrefix, Collection<?> lines) {
        if (lines.isEmpty()) {
            return "";
        }
        StringBuilder out = new StringBuilder(start);
        for (Object line : lines) {
            out.append(linePrefix).append(line).append("\n");
        }
        return out.substring(0, out.length() - 1); //lose last EOL
    }
225532
private static StackLine getStackLine(
            TestMethodTable table, String classQualifiedName, String methodSimpleName, int line) {
        if (line <= 0) {
            return null; // 0 or negative line number never matches
        }
        List<TestMethod> nameMethods = table.getByName(classQualifiedName, methodSimpleName);
        for (TestMethod method : nameMethods) {
            for (int i = 0; i < method.getCodeBody().size(); i++) {
                CodeLine codeLine = method.getCodeBody().get(i);
                if (codeLine.getStartLine() <= line && line <= codeLine.getEndLine()) {
                    StackLine result = new StackLine();
                    result.setMethodKey(method.getKey());
                    result.setMethod(method);
                    result.setCodeBodyIndex(i);
                    result.setLine(line);
                    return result;
                }
            }
        }
        return null;
    }
130449
private String segmenterNonBreaker(String line) {

    // these are fine because they do not affect offsets
    line = line.trim();
    line = RuleBasedTokenizer.doubleSpaces.matcher(line).replaceAll(" ");
    final StringBuilder sb = new StringBuilder();
    String segmentedText = "";
    int i;
    final String[] words = line.split(" ");
    // iterate over the words
    for (i = 0; i < words.length - 1; i++) {
      final Matcher nonSegmentedWordMatcher = nonSegmentedWords
          .matcher(words[i]);
      // candidate word to be segmented found:
      if (nonSegmentedWordMatcher.find()) {
        final String curWord = nonSegmentedWordMatcher.replaceAll("$1");
        final String finalPunct = nonSegmentedWordMatcher.replaceAll("$2");
        if (!curWord.isEmpty() && curWord.matches("(" + this.NON_BREAKER + ")")
            && finalPunct.isEmpty()) {
          // if current word is not empty and is a no breaker and there is not
          // final punctuation
        } else if (acronym.matcher(words[i]).find()) {
          // if acronym
        } else if (nextCandidateWord.matcher(words[i + 1]).find()) {
          // if next word contains initial punctuation and then uppercase or
          // digit do:
          if (!(!curWord.isEmpty() && curWord.matches(NON_BREAKER_DIGITS)
              && finalPunct.isEmpty()
              && startDigit.matcher(words[i + 1]).find())) {
            // segment unless current word is a non breaker digit and next word
            // is not final punctuation or does not start with a number
            words[i] = words[i] + "\n";
          }
        }
      }
      sb.append(words[i]).append(" ");
      segmentedText = sb.toString();
    }
    // add last index of words array removed for easy look ahead
    segmentedText = segmentedText + words[i];
    return segmentedText;
  }
936710
public synchronized void parseLine(String line) throws SyntaxErrorException
	{
		if (null != getParserOutcome() && isParserOutcomeMultipleLine())
		{
			parseLine__multipleLineMode(line);
		}
		else
		{
			parseLine__singleLineMode(line);
		}
	}
344367
public static Parser<Void> lineComment(String begin) {
    return Patterns.lineComment(begin).toScanner(begin);
  }
1321410
protected final OperationStatus matchStatus(String line,
      OperationStatus... statii) {
    OperationStatus rv = null;
    for (OperationStatus status : statii) {
      if (line.equals(status.getMessage())) {
        rv = status;
      }
    }
    if (rv == null) {
      rv = new OperationStatus(false, line, StatusCode.fromAsciiLine(line));
    }
    return rv;
  }
640801
public static String[] getDataFromLine(final String line, final String seperator)
	{
		return getDataFromLine(line, seperator, false);
	}
170181
private boolean isBlankRow(String[] line)
    {
        boolean ret = true;
        for(int i = 0; i < line.length && ret; i++)
        {
            if(line[i] != null && line[i].trim().length() > 0)
                ret = false;
        }
        return ret;
    }
1308372
public static String getLine(String content, int line) {
    if (content == null) {
      return null;
    }

    String[] contentSplit = content.replace("\r\n", "\n").split("\n");

    if (contentSplit.length < line) {
      return null;
    }
    return contentSplit[line - 1];
  }
413115
public String getFragmentByLines(int startLine, int endLine) {
    Preconditions.checkArgument(startLine <= endLine);
    return Joiner.on("\n").join(getLines(startLine, endLine)) + "\n";
  }
1071621
public void processLine(String line) throws CLIException {
		if (line.trim().equals("?")) {
			output.output(String.format(HINT_FORMAT, appName), outputConverter);
		} else {
			List<Token> tokens = Token.tokenize(line);
			if (tokens.size() > 0) {
				String discriminator = tokens.get(0).getString();
				processCommand(discriminator, tokens);
			}
		}
	}
804347
private void extractTablesFromAPage(ArrayList<TextPiece> linesOfAPage,
	    ArrayList<Table> tables, ArrayList<TextPiece> wordsOfAPage, int i,
	    File pdfFile, ArrayList<ArrayList<TextPiece>> linesByPage) {
	if (linesOfAPage.size() > 30) {
	    /*
	     * Checks for table keywords
	     */
	    boolean tableKwdExist = false;
	    int prevTableEndIndex = 0;
	    for (TextPiece t : linesOfAPage) {
		String textWithoutSpace = t.getText().replace(" ", "");
		if (getMatchedTabledKeyword(textWithoutSpace) != null) {
		    tableKwdExist = true;
		    break;
		}
	    }

	    /*
	     * TODO [improve]: keywords are searched twice, no need to do the
	     * first search in the future
	     */
	    if (tableKwdExist == true) {
		for (int k = 0; k < linesOfAPage.size();) {
		    TextPiece line = linesOfAPage.get(k);
		    TextPiece prevLine = (k == 0) ? null : linesOfAPage
			    .get(k - 1);
		    String textWithoutSpace = line.getText().replace(" ", "");
		    String keyword = getMatchedTabledKeyword(textWithoutSpace);

		    if (keyword != null
			    && (textWithoutSpace.startsWith("tableofcontent") == false)
			    && (textWithoutSpace.startsWith("TABLEOFCONTENT") == false)
			    && (textWithoutSpace.startsWith("TableofContent") == false)) {
			char lastCharInKwd = keyword
				.charAt(keyword.length() - 1);
			String oldKwd = line.getText().substring(0,
				line.getText().indexOf(lastCharInKwd) + 1);
			String newLine = "Table"
				+ line.getText()
					.substring(
						line.getText().indexOf(
							lastCharInKwd) + 1,
						line.getText().length());
			// linesOfAPage.get(k).setText(newLine);

			if (prevLine != null && line.getY() == prevLine.getY())
			    k++;
			else {
			    /*
			     * try to extract this table
			     */
			    TableCandidate tc = new TableCandidate();
			    tc.setKeyword(keyword);
			    // tc.setXMLDoc(xml_doc); // to add all table
			    // metadata elements in TableCandidate

			    k = extractOneTable(k, linesOfAPage, keyword, tc,
				    wordsOfAPage, i, prevTableEndIndex,
				    linesByPage);
			    if (tc.isValid()) {
				if (tc.isTopCaption())
				    prevTableEndIndex = tc.getBodyEndLine();
				else
				    prevTableEndIndex = tc.getCaptionEndLine();
				if (Config.DEBUG_MODE)
				    tc.print();
				String metadata_StructureLevel = tc
					.getMetadata_StructureLevel();
				String tableMeta_thisDoc = m_docInfo
					.getTableMetaInThisDoc();
				String tableMetaHighLevel = tc
					.getMetadata_HighLevel();
				String latestMetaData = tableMeta_thisDoc
					+ tableMetaHighLevel
					+ metadata_StructureLevel;
				m_docInfo.setTableMetadata(latestMetaData);

				/*
				 * Generates the extracted table list, then XML
				 * output from each table
				 */
				// System.out.println(Integer.toString(i)+" Adding");
				Table oneTable = new Table();
				oneTable.setValidTable(tc);
				tables.add(oneTable);

				oneTable.setPageNumber(i + 1);
			    }
			}
		    } else
			k++;
		}
	    } else {// TODO: log
	    }
	} else {
	    /*
	     * Impossible to contain tables because of few texts in the page
	     */
	}
    }
498743
public static String[] disectCommandLine(String line) {
		return StringSupport.split(line, "() ,;", "\"", false, false, false).toArray(new String[0]);
	}
86514
static int startsWithAsterisk(String line) {
        if (line.startsWith("*")) {
            return 0;
        } else if ((line.startsWith(" ") || line.startsWith("\t")) && line.length() > 1) {
            int res = startsWithAsterisk(line.substring(1));
            if (res == -1) {
                return -1;
            } else {
                return 1 + res;
            }
        } else {
            return -1;
        }
    }
1209590
public String getSnippet(LineColumn start, LineColumn end) {
        // preconditions
        if (start == null || end == null) { return null; } // no text to return
        if (start.equals(end)) { return null; } // no text to return
        if (lines.size() == 1 && current.length() == 0) { return null; } // buffer hasn't been filled yet

        // working variables
        int startLine = start.getLine();
        int startColumn = start.getColumn();
        int endLine = end.getLine();
        int endColumn = end.getColumn();

        // reset any out of bounds requests
        if (startLine < 1) { startLine = 1;}
        if (endLine < 1) { endLine = 1;}
        if (startColumn < 1) { startColumn = 1;}
        if (endColumn < 1) { endColumn = 1;}
        if (startLine > lines.size()) { startLine = lines.size(); }
        if (endLine > lines.size()) { endLine = lines.size(); }

        // obtain the snippet from the buffer within specified bounds
        StringBuilder snippet = new StringBuilder();
        for (int i = startLine - 1; i < endLine;i++) {
            String line = ((StringBuilder)lines.get(i)).toString();
            if (startLine == endLine) {
                // reset any out of bounds requests (again)
                if (startColumn > line.length()) { startColumn = line.length();}
                if (startColumn < 1) { startColumn = 1;}
                if (endColumn > line.length()) { endColumn = line.length() + 1;}
                if (endColumn < 1) { endColumn = 1;}
                if (endColumn < startColumn) { endColumn = startColumn;}

                line = line.substring(startColumn - 1, endColumn - 1);
            } else {
                if (i == startLine - 1) {
                    if (startColumn - 1 < line.length()) {
                        line = line.substring(startColumn - 1);
                    }
                }
                if (i == endLine - 1) {
                    if (endColumn - 1 < line.length()) {
                        line = line.substring(0,endColumn - 1);
                    }
                }
            }
            snippet.append(line);
        }
        return snippet.toString();
    }