本文整理汇总了Java中org.codehaus.groovy.control.Janitor类的典型用法代码示例。如果您正苦于以下问题:Java Janitor类的具体用法?Java Janitor怎么用?Java Janitor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Janitor类属于org.codehaus.groovy.control包,在下文中一共展示了Janitor类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import org.codehaus.groovy.control.Janitor; //导入依赖的package包/类
/**
* Writes out a nicely formatted summary of the exception.
*/
public void write( PrintWriter output, Janitor janitor )
{
String description = "General error during " + owner.getPhaseDescription() + ": ";
String message = cause.getMessage();
if( message != null )
{
output.println( description + message );
}
else
{
output.println( description + cause );
}
output.println();
//if (verbose) {
cause.printStackTrace(output);
//}
}
示例2: write
import org.codehaus.groovy.control.Janitor; //导入依赖的package包/类
public void write( PrintWriter writer, Janitor janitor )
{
if (owner instanceof SourceUnit) {
SourceUnit source = (SourceUnit) owner;
String name = source.getName();
int line = context.getStartLine();
int column = context.getStartColumn();
String sample = source.getSample( line, column, janitor );
if( sample != null )
{
writer.println( source.getSample(line, column, janitor) );
}
writer.println( name + ": " + line + ": " + this.message );
writer.println("");
} else {
writer.println( "<No Relevant Source>: " + this.message );
writer.println("");
}
}
示例3: getLine
import org.codehaus.groovy.control.Janitor; //导入依赖的package包/类
/**
* {@inheritDoc}
* @see org.codehaus.groovy.control.io.ReaderSource#getLine(int, org.codehaus.groovy.control.Janitor)
*/
@Override
public String getLine(int lineNumber, Janitor janitor) {
int start = 0;
int eol = 0;
final ByteBuf b = prejectedBuffer.duplicate().resetReaderIndex();
for(int i = 0; i < lineNumber; i++) {
eol = findEndOfLine(b);
if(eol==-1) return null;
start = eol+1;
}
return b.slice(start, eol).toString(UTF8);
}
示例4: write
import org.codehaus.groovy.control.Janitor; //导入依赖的package包/类
public void write( PrintWriter writer, Janitor janitor )
{
if( owner instanceof SourceUnit )
{
String name = ((SourceUnit)owner).getName();
writer.println( "" + name + ": " + message );
}
else
{
writer.println( message );
}
}
示例5: write
import org.codehaus.groovy.control.Janitor; //导入依赖的package包/类
/**
* Writes out a nicely formatted summary of the syntax error.
*/
public void write(PrintWriter output, Janitor janitor) {
String name = source.getName();
int line = getCause().getStartLine();
int column = getCause().getStartColumn();
String sample = source.getSample(line, column, janitor);
output.print(name + ": " + line + ": " + getCause().getMessage());
if (sample != null) {
output.println();
output.print(sample);
output.println();
}
}
示例6: SourceText
import org.codehaus.groovy.control.Janitor; //导入依赖的package包/类
/**
* Constructs a <tt>SourceText</tt> by reading the given assertion's source
* text from the given source unit.
*
* @param stat an assertion statement
* @param sourceUnit the source unit containing the assertion statement
* @param janitor a <tt>Janitor</tt> for cleaning up reader sources
*/
public SourceText(AssertStatement stat, SourceUnit sourceUnit, Janitor janitor) {
if (!hasPlausibleSourcePosition(stat))
throw new SourceTextNotAvailableException(stat, sourceUnit, "Invalid source position");
firstLine = stat.getLineNumber();
textOffsets.add(0);
StringBuilder normalizedTextBuffer = new StringBuilder();
for (int line = stat.getLineNumber(); line <= stat.getLastLineNumber(); line++) {
String lineText = sourceUnit.getSample(line, 0, janitor);
if (lineText == null)
throw new SourceTextNotAvailableException(stat, sourceUnit, "SourceUnit.getSample() returned null");
if (line == stat.getLastLineNumber())
lineText = lineText.substring(0, stat.getLastColumnNumber() - 1);
if (line == stat.getLineNumber()) {
lineText = lineText.substring(stat.getColumnNumber() - 1);
lineOffsets.add(stat.getColumnNumber() - 1);
} else
lineOffsets.add(countLeadingWhitespace(lineText));
lineText = lineText.trim();
if (line != stat.getLastLineNumber() && lineText.length() > 0)
lineText += ' ';
normalizedTextBuffer.append(lineText);
textOffsets.add(normalizedTextBuffer.length());
}
normalizedText = normalizedTextBuffer.toString();
}
示例7: visitAssertStatement
import org.codehaus.groovy.control.Janitor; //导入依赖的package包/类
@Override
public void visitAssertStatement(final AssertStatement statement) {
Janitor j = new Janitor();
final String text = new SourceText(statement, sourceUnit, j).getNormalizedText();
j.cleanup();
makeNode("assert_", new Runnable() {
@Override
public void run() {
visit(statement.getBooleanExpression());
visit(statement.getMessageExpression());
literal(text);
}
});
}
示例8: write
import org.codehaus.groovy.control.Janitor; //导入依赖的package包/类
public void write( PrintWriter writer, Janitor janitor )
{
writer.print( "warning: " );
super.write( writer, janitor );
}
示例9: setUp
import org.codehaus.groovy.control.Janitor; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
readerSource = new AbstractReaderSourceSubclass();
janitor = new Janitor();
}
示例10: getLine
import org.codehaus.groovy.control.Janitor; //导入依赖的package包/类
/**
* Returns a line from the source, or null, if unavailable. If
* you supply a Janitor, resources will be cached.
* @param lineNumber the number of the line of interest
* @param janitor helper to clean up afterwards
* @return the line of interest
*/
String getLine( int lineNumber, Janitor janitor );
示例11: write
import org.codehaus.groovy.control.Janitor; //导入依赖的package包/类
/**
* Writes the message to the specified PrintWriter. The supplied
* ProcessingUnit is the unit that holds this Message.
*/
public abstract void write( PrintWriter writer, Janitor janitor );