当前位置: 首页>>代码示例>>Java>>正文


Java Janitor类代码示例

本文整理汇总了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);
    //}
}
 
开发者ID:apache,项目名称:groovy,代码行数:24,代码来源:ExceptionMessage.java

示例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("");
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:23,代码来源:LocatedMessage.java

示例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);
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:17,代码来源:ByteBufReaderSource.java

示例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 );
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:13,代码来源:SimpleMessage.java

示例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();
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:18,代码来源:SyntaxErrorMessage.java

示例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();
}
 
开发者ID:apache,项目名称:groovy,代码行数:38,代码来源:SourceText.java

示例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);
        }
    });
}
 
开发者ID:cloudbees,项目名称:groovy-cps,代码行数:16,代码来源:CpsTransformer.java

示例8: write

import org.codehaus.groovy.control.Janitor; //导入依赖的package包/类
public void write( PrintWriter writer, Janitor janitor )
{
    writer.print( "warning: " );
    super.write( writer, janitor );
}
 
开发者ID:apache,项目名称:groovy,代码行数:6,代码来源:WarningMessage.java

示例9: setUp

import org.codehaus.groovy.control.Janitor; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    readerSource = new AbstractReaderSourceSubclass();
    janitor = new Janitor();
}
 
开发者ID:apache,项目名称:groovy,代码行数:6,代码来源:AbstractReaderSourceTest.java

示例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 );
 
开发者ID:apache,项目名称:groovy,代码行数:9,代码来源:ReaderSource.java

示例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 );
 
开发者ID:apache,项目名称:groovy,代码行数:7,代码来源:Message.java


注:本文中的org.codehaus.groovy.control.Janitor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。