當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。