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


Java Log.trace方法代码示例

本文整理汇总了Java中jline.internal.Log.trace方法的典型用法代码示例。如果您正苦于以下问题:Java Log.trace方法的具体用法?Java Log.trace怎么用?Java Log.trace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jline.internal.Log的用法示例。


在下文中一共展示了Log.trace方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: flush

import jline.internal.Log; //导入方法依赖的package包/类
public void flush() throws IOException {
    Log.trace("Flushing history");

    if (!file.exists()) {
        File dir = file.getParentFile();
        if (!dir.exists() && !dir.mkdirs()) {
            Log.warn("Failed to create directory: ", dir);
        }
        if (!file.createNewFile()) {
            Log.warn("Failed to create file: ", file);
        }
    }

    PrintStream out = new PrintStream(new BufferedOutputStream(new FileOutputStream(file)));
    try {
        for (Entry entry : this) {
            out.println(entry.value());
        }
    }
    finally {
        out.close();
    }
}
 
开发者ID:AcademicTorrents,项目名称:AcademicTorrents-Downloader,代码行数:24,代码来源:FileHistory.java

示例2: readCharacter

import jline.internal.Log; //导入方法依赖的package包/类
/**
 * Read a character from the console.
 *
 * @return the character, or -1 if an EOF is received.
 */
public final int readCharacter() throws IOException {
    int c = reader.read();
    if (c >= 0) {
        Log.trace("Keystroke: ", c);
        // clear any echo characters
        if (terminal.isSupported()) {
            clearEcho(c);
        }
    }
    return c;
}
 
开发者ID:AcademicTorrents,项目名称:AcademicTorrents-Downloader,代码行数:17,代码来源:ConsoleReader.java

示例3: load

import jline.internal.Log; //导入方法依赖的package包/类
public void load(final File file) throws IOException {
    checkNotNull(file);
    if (file.exists()) {
        Log.trace("Loading history from: ", file);
        load(new FileReader(file));
    }
}
 
开发者ID:AcademicTorrents,项目名称:AcademicTorrents-Downloader,代码行数:8,代码来源:FileHistory.java

示例4: purge

import jline.internal.Log; //导入方法依赖的package包/类
public void purge() throws IOException {
    Log.trace("Purging history");

    clear();

    if (!file.delete()) {
        Log.warn("Failed to delete history file: ", file);
    }
}
 
开发者ID:AcademicTorrents,项目名称:AcademicTorrents-Downloader,代码行数:10,代码来源:FileHistory.java

示例5: complete

import jline.internal.Log; //导入方法依赖的package包/类
public int complete(final String buffer, final int cursor, final List<CharSequence> candidates) {
    // buffer can be null
    checkNotNull(candidates);

    ArgumentDelimiter delim = getDelimiter();
    ArgumentList list = delim.delimit(buffer, cursor);
    int argpos = list.getArgumentPosition();
    int argIndex = list.getCursorArgumentIndex();

    if (argIndex < 0) {
        return -1;
    }

    List<Completer> completers = getCompleters();
    Completer completer;

    // if we are beyond the end of the completers, just use the last one
    if (argIndex >= completers.size()) {
        completer = completers.get(completers.size() - 1);
    }
    else {
        completer = completers.get(argIndex);
    }

    // ensure that all the previous completers are successful before allowing this completer to pass (only if strict).
    for (int i = 0; isStrict() && (i < argIndex); i++) {
        Completer sub = completers.get(i >= completers.size() ? (completers.size() - 1) : i);
        String[] args = list.getArguments();
        String arg = (args == null || i >= args.length) ? "" : args[i];

        List<CharSequence> subCandidates = new LinkedList<CharSequence>();

        if (sub.complete(arg, arg.length(), subCandidates) == -1) {
            return -1;
        }

        if (subCandidates.size() == 0) {
            return -1;
        }
    }

    int ret = completer.complete(list.getCursorArgument(), argpos, candidates);

    if (ret == -1) {
        return -1;
    }

    int pos = ret + list.getBufferPosition() - argpos;

    // Special case: when completing in the middle of a line, and the area under the cursor is a delimiter,
    // then trim any delimiters from the candidates, since we do not need to have an extra delimiter.
    //
    // E.g., if we have a completion for "foo", and we enter "f bar" into the buffer, and move to after the "f"
    // and hit TAB, we want "foo bar" instead of "foo  bar".

    if ((cursor != buffer.length()) && delim.isDelimiter(buffer, cursor)) {
        for (int i = 0; i < candidates.size(); i++) {
            CharSequence val = candidates.get(i);

            while (val.length() > 0 && delim.isDelimiter(val, val.length() - 1)) {
                val = val.subSequence(0, val.length() - 1);
            }

            candidates.set(i, val);
        }
    }

    Log.trace("Completing ", buffer, " (pos=", cursor, ") with: ", candidates, ": offset=", pos);

    return pos;
}
 
开发者ID:AcademicTorrents,项目名称:AcademicTorrents-Downloader,代码行数:72,代码来源:ArgumentCompleter.java

示例6: complete

import jline.internal.Log; //导入方法依赖的package包/类
@Override
public int complete(String buffer, final int cursor, final List<CharSequence> candidates) {
    // candidates can be null
    checkNotNull(candidates);

    if (buffer == null) {
        buffer = "";
    }
    ArgumentDelimiter delim = getDelimiter();
    ArgumentList list = delim.delimit(buffer, cursor);
    int argpos = list.getArgumentPosition();
    int argIndex = list.getCursorArgumentIndex();

    if (argIndex < 0) {
        return -1;
    }

    List<Completer> completers = getCompleters();
    Completer completer;

    // if we are beyond the end of the completers, just use the last one
    if (argIndex >= completers.size()) {
        completer = completers.get(completers.size() - 1);
    }
    else {
        completer = completers.get(argIndex);
    }

    // ensure that all the previous completers are successful before allowing this completer to pass (only if strict).
    for (int i = 0; isStrict() && (i < argIndex); i++) {
        Completer sub = completers.get(i >= completers.size() ? (completers.size() - 1) : i);
        String[] args = list.getArguments();
        String arg = (args == null || i >= args.length) ? "" : args[i];

        List<CharSequence> subCandidates = new LinkedList<CharSequence>();
        if (sub instanceof ArgumentListAware) {
            ((ArgumentListAware) sub).setArgumentList(list);
        }

        if (sub.complete(arg, arg.length(), subCandidates) == -1) {
            return -1;
        }

        if (subCandidates.size() == 0) {
            return -1;
        }
    }

    if (completer instanceof ArgumentListAware) {
        ((ArgumentListAware) completer).setArgumentList(list);
    }

    int ret = completer.complete(list.getCursorArgument(), argpos, candidates);
    if (ret == -1) {
        return -1;
    }

    int pos = ret + list.getBufferPosition() - argpos;

    // Special case: when completing in the middle of a line, and the area under the cursor is a delimiter,
    // then trim any delimiters from the candidates, since we do not need to have an extra delimiter.
    //
    // E.g., if we have a completion for "foo", and we enter "f bar" into the buffer, and move to after the "f"
    // and hit TAB, we want "foo bar" instead of "foo  bar".

    if ((cursor != buffer.length()) && delim.isDelimiter(buffer, cursor)) {
        for (int i = 0; i < candidates.size(); i++) {
            CharSequence val = candidates.get(i);

            while (val.length() > 0 && delim.isDelimiter(val, val.length() - 1)) {
                val = val.subSequence(0, val.length() - 1);
            }

            candidates.set(i, val);
        }
    }

    Log.trace("Completing ", buffer, " (pos=", cursor, ") with: ", candidates, ": offset=", pos);

    return pos;
}
 
开发者ID:vmware,项目名称:workflowTools,代码行数:82,代码来源:ImprovedArgumentCompleter.java


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