/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* See LICENSE.txt included in this distribution for the specific
* language governing permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at LICENSE.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*
* Portions Copyright 2011 Jens Elkner.
*/
/**
* This is supposed to get the matching lines from sourcefile.
* since lucene does not easily give the match context.
*/
public class Context {
private final LineMatcher[] m;
private char[] buffer;
/**
* Map whose keys tell which fields to look for in the source file, and
* whose values tell if the field is case insensitive (true for
* insensitivity, false for sensitivity).
*/
static {
}
/**
* Constructs a context generator
* @param query the query to generate the result for
* @param queryStrings map from field names to queries against the fields
*/
if (m != null) {
//System.err.println("Found Matchers = "+ m.length + " for " + query);
buffer = new char[MAXFILEREAD];
}
}
public boolean isEmpty() {
return m == null;
}
/**
* Build the {@code queryAsURI} string that holds the query in a form
* that's suitable for sending it as part of a URI.
*
* @param subqueries a map containing the query text for each field
*/
if (subqueries.isEmpty()) {
queryAsURI = "";
return;
}
}
.append('&');
}
}
private boolean alt = true;
/**
* ???.
* Closes the given <var>in</var> reader on return.
*
* @param in File to be matched
* @param out to write the context
* @param morePrefix to link to more... page
* @param path path of the file
* @param tags format to highlight defs.
* @param limit should the number of matching lines be limited?
* @return Did it get any matching context?
*/
if (m == null) {
return false;
}
boolean anything = false;
try {
for (int i = 0; i < m.length; i++) {
/* desc[0] is matched symbol
* desc[1] is line number
* desc[2] is type
* desc[3] is matching line;
*/
anything = true;
} else {
anything = true;
}
} else {
}
break;
}
}
}
} catch (Exception e) {
// @todo verify why we ignore all exceptions?
}
}
}
/**
* Just to get the matching tag send a null in
*/
return anything;
}
int charsRead = 0;
boolean truncated = false;
lim = false;
}
if (lim) {
try {
if (charsRead == MAXFILEREAD) {
// we probably only read parts of the file, so set the
// truncated flag to enable the [all...] link that
// requests all matches
truncated = true;
// truncate to last line read (don't look more than 100
// characters back)
if (buffer[i] == '\n') {
charsRead = i;
break;
}
}
}
} catch (IOException e) {
return anything;
}
if (charsRead == 0) {
return anything;
}
} else {
}
}
try {
int matchedLines = 0;
for (int i = 0; i < m.length; i++) {
matchedLines++;
//out.write("<br> <i>Matched " + token + " maxlines = " + matchedLines + "</i><br>");
break;
} else {
}
}
}
out.write("<a href=\"" + Util.URIEncodePath(morePrefix) + pathE + "?" + queryAsURI + "\">[all...]</a>");
}
} catch (IOException e) {
} finally {
try {
} catch (IOException e) {
}
}
}
return anything;
}
}