/*
* 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.
*/
/**
* Search Context.
*
* @author Trond Norbye
* @version $Revision$
*/
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];
}
}
/**
* Check, whether one ore more line matchers (query terms) are present.
* @return {@code true} if present.
* @see #Context(Query, Map)
*/
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;
}
}
}
}
private boolean alt = true;
/**
* Search given tags in the given input stream and write out htmlized
* results to the given output stream.
* Closes the given <var>in</var> reader on return.
*
* @param in File to be matched
* @param out to write the context
* @param urlPrefix URL prefix to use for generated links. Ignored if
* {@code null}.
* @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?
* @param hits where to add obtained hits
* @return Did it get any matching context?
*/
@SuppressWarnings("boxing")
{
if (m == null) {
return false;
}
boolean anything = false;
try {
for (int i = 0; i < m.length; i++) {
};
anything = true;
} else {
anything = true;
}
} else {
}
break;
}
}
}
} catch (Exception e) {
// @todo verify why we ignore all exceptions?
+ e.getMessage());
}
}
}
/**
* 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 {
}
}
}
}
} catch (IOException e) {
+ e.getMessage());
} finally {
// don't close
try {
} catch (IOException e) {
}
}
}
return anything;
}
}