BrightSide Workbench Full Report + Source Code
org.turro.elephant.search.SearchFormatter Class Reference
Collaboration diagram for org.turro.elephant.search.SearchFormatter:

Public Member Functions

 SearchFormatter (String query, boolean ignoreCase)
 
void processLine (String line)
 
boolean wasFound ()
 
String getResult ()
 
int getFound ()
 
String queryToRegExp (String query)
 

Static Public Member Functions

static String queryToSQL (String field, String query, boolean ignoreCase)
 
static String removeHTML (String line)
 
static String removeHTMLTag (String line, String string)
 

Protected Attributes

Stack lines
 
String query
 
Pattern pat
 
int count
 
boolean ignoreCase
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 28 of file SearchFormatter.java.

Constructor & Destructor Documentation

◆ SearchFormatter()

org.turro.elephant.search.SearchFormatter.SearchFormatter ( String  query,
boolean  ignoreCase 
)

Creates a new instance of SearchFormatter

Definition at line 36 of file SearchFormatter.java.

Here is the call graph for this function:

Member Function Documentation

◆ getFound()

int org.turro.elephant.search.SearchFormatter.getFound ( )

Definition at line 74 of file SearchFormatter.java.

74  {
75  return found;
76  }
Here is the caller graph for this function:

◆ getResult()

String org.turro.elephant.search.SearchFormatter.getResult ( )

Definition at line 66 of file SearchFormatter.java.

66  {
67  String result = "";
68  for(int i = 0; i < lines.size(); i++) {
69  result += lines.get(i) + "<br/>";
70  }
71  return result;
72  }
Here is the caller graph for this function:

◆ processLine()

void org.turro.elephant.search.SearchFormatter.processLine ( String  line)

Definition at line 44 of file SearchFormatter.java.

44  {
45  if(line == null) return;
46  line = removeHTMLTag(line, "script");
47  line = removeHTMLTag(line, "style");
48  line = removeHTML(line);
49  line = removeMacros(line);
50  Matcher mat = pat.matcher(line);
51  int lfound = 0;
52  while(mat.find()) {
53  lfound++;
54  }
55  if(lfound > 0) {
56  line = line.replaceAll("(" + reQuery + ")", "<span class='found'>$1</span>");
57  lines.push(line);
58  found += lfound;
59  }
60  }
static String removeHTMLTag(String line, String string)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ queryToRegExp()

String org.turro.elephant.search.SearchFormatter.queryToRegExp ( String  query)

Definition at line 78 of file SearchFormatter.java.

78  {
79  if(query == null) return "";
80  String[] values = query.split("\\s+");
81  count = values.length;
82  String result = "(", sep = "";
83  for(int i = 0; i < count; i++) {
84  result += sep + "(" + values[i] + ")";
85  sep = "|";
86  }
87  return (ignoreCase ? "(?i)" : "") + result + ")";
88  }
Here is the caller graph for this function:

◆ queryToSQL()

static String org.turro.elephant.search.SearchFormatter.queryToSQL ( String  field,
String  query,
boolean  ignoreCase 
)
static

Definition at line 90 of file SearchFormatter.java.

90  {
91  String[] values = query.split("\\s+");
92  String result = "(", sep = "";
93  for(int i = 0; i < values.length; i++) {
94  if(ignoreCase) {
95  result += sep + "UCASE(" + field + ") LIKE '%" + values[i].toUpperCase() + "%' ";
96  }
97  else {
98  result += sep + field + " LIKE '%" + values[i] + "%' ";
99  }
100  sep = "OR ";
101  }
102  return result + ")";
103  }
Here is the caller graph for this function:

◆ removeHTML()

static String org.turro.elephant.search.SearchFormatter.removeHTML ( String  line)
static

Definition at line 105 of file SearchFormatter.java.

105  {
106  return line.replaceAll("\\<\\/?[\\?a-zA-Z\\-\\:\\_0-9]+\\ ?.*?\\>", "");
107  }
Here is the caller graph for this function:

◆ removeHTMLTag()

static String org.turro.elephant.search.SearchFormatter.removeHTMLTag ( String  line,
String  string 
)
static

Definition at line 109 of file SearchFormatter.java.

109  {
110  return line.replaceAll("\\<" + string + " .*?\\<\\/" + string + "\\>", "");
111  }
Here is the caller graph for this function:

◆ wasFound()

boolean org.turro.elephant.search.SearchFormatter.wasFound ( )

Definition at line 62 of file SearchFormatter.java.

62  {
63  return lines.size() > 0;
64  }
Here is the caller graph for this function:

Member Data Documentation

◆ count

int org.turro.elephant.search.SearchFormatter.count
protected

Definition at line 32 of file SearchFormatter.java.

◆ ignoreCase

boolean org.turro.elephant.search.SearchFormatter.ignoreCase
protected

Definition at line 33 of file SearchFormatter.java.

◆ lines

Stack org.turro.elephant.search.SearchFormatter.lines
protected

Definition at line 29 of file SearchFormatter.java.

◆ pat

Pattern org.turro.elephant.search.SearchFormatter.pat
protected

Definition at line 31 of file SearchFormatter.java.

◆ query

String org.turro.elephant.search.SearchFormatter.query
protected

Definition at line 30 of file SearchFormatter.java.


The documentation for this class was generated from the following file: