/*
* 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
*/
/*
*/
/**
* it is supposed to get the matching lines from history log files.
* since lucene does not easily give the match context.
*/
public class HistoryContext {
private final LineMatcher[] m;
/**
* Map whose keys tell which fields to look for in the history, and
* whose values tell if the field is case insensitive (true for
* insensitivity, false for sensitivity).
*/
/**
* Create a new context wrt. to the given query.
* @param query query to use.
*/
if (m != null) {
}
}
/**
* Check, whether one ore more line matchers (query terms) are present.
* @return {@code true} if present.
* @see #HistoryContext(Query)
*/
public boolean isEmpty() {
return m == null;
}
/**
* Obtain the history for the source file <var>filename</var> and append
* matches to <var>hits</var>.
*
* @param filename the source file for which the history should be fetched
* @param path the path of the source file (rooted at SOURCE_ROOT)
* @param hits where to append matches.
* @return {@code true} if matches where found.
* @throws HistoryException
*/
throws HistoryException
{
if (m == null) {
return false;
}
}
/**
* write out matching history log entries htmlized.
*
* @param parent the directory which contains the source file
* @param basename the basename of the source file
* @param path the path of the source file (rooted at SOURCE_ROOT)
* @param out where to write htmlized results
* @param context the servlet context path of the application (the path
* prefix for URLs)
* @return {@code true} if matches where found and written out.
* @throws HistoryException
*/
{
}
/**
* Obtain the history for the source file <var>src</var> and write out
* matching history log entries htmlized.
*
* @param src the source file represented by <var>path</var>
* (SOURCE_ROOT + path)
* @param path the path of the file (rooted at SOURCE_ROOT)
* @param out write destination
* @param context the servlet context path of the application (the path
* prefix for URLs)
* @return {@code true} if at least one line has been written out.
* @throws HistoryException
*/
throws HistoryException
{
if (m == null) {
return false;
}
}
/**
* Writes matching history log entries from 'in' either htmlized to 'out'
* or append them to 'hits'.
* @param in the history to fetch entries from
* @param out to write matched context
* @param path path to the file
* @param hits list of hits
* @param wcontext web context - beginning of url
*/
@SuppressWarnings("null")
{
// There should be exactly one destination for the output. If
// none or both are specified, it's a bug.
throw new IllegalArgumentException(
"Exactly one of out and hits should be non-null");
}
if (m == null) {
return false;
}
int matchedLines = 0;
try {
// this prefetch mechanism is here because of the diff link
// generation
// we currently generate the diff to previous revision
: null;
int matchState;
int start = -1;
for (int i = 0; i< m.length; i++) {
if (start < 0) {
}
} else {
}
matchedLines++;
break;
if (start < 0) {
}
} else {
start = -1;
}
}
}
}
} catch (Exception e) {
+ e.getMessage());
}
return matchedLines > 0;
}
/**
* Write a match htmlized to a stream.
*
* @param out the receiving stream
* @param line the matching line
* @param start start position of the match
* @param end position of the first char after the match
* @param flatten should multi-line log entries be flattened to a single
* @param path path to the file
* @param wcontext web context (begin of url).
* @param nrev old revision
* @param rev current revision
* line? If {@code true}, replace newline with space.
*/
{
//does below need to be encoded? see bug 16985
.append("\" title=\"diff to previous version\">diff</a> ");
}
}
}