Here you can find the source of getCodeSnippetCLT(Element codeElement, String content, String fqn, String api, String kind, String[] titles)
public static List<Integer> getCodeSnippetCLT(Element codeElement, String content, String fqn, String api, String kind, String[] titles)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.jsoup.nodes.Element; public class Main { public static List<Integer> getCodeSnippetCLT(Element codeElement, String content, String fqn, String api, String kind, String[] titles) { List<Integer> indexes = new ArrayList<Integer>(); if (codeElement.tagName().equals("pre")) { if (content.startsWith("M")) { content = content.split(":")[2]; } else if (content.startsWith("F")) { content = content.split(":")[3]; } else { String[] tmp = content.split(":")[1].split("\\."); if (tmp.length == 1) content = tmp[0];/* w ww . ja va2 s . c o m*/ else content = tmp[1]; } Pattern pattern; if (!kind.equals("method")) pattern = Pattern.compile("(?<=\\W)" + api + "(?=\\W)", Pattern.DOTALL); else pattern = Pattern.compile("(?<=\\W)" + api + "(?=\\()", Pattern.DOTALL); Matcher m = pattern.matcher(codeElement.html()); while (m.find()) indexes.add(m.regionStart()); if (indexes.size() == 0) System.out.println("nothing was found"); } return indexes; } }