groovy.lang.GroovyClassLoader.isFile()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(169)

本文整理了Java中groovy.lang.GroovyClassLoader.isFile()方法的一些代码示例,展示了GroovyClassLoader.isFile()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GroovyClassLoader.isFile()方法的具体详情如下:
包路径:groovy.lang.GroovyClassLoader
类名称:GroovyClassLoader
方法名:isFile

GroovyClassLoader.isFile介绍

暂无

代码示例

代码示例来源:origin: org.codehaus.groovy/groovy

private URL getSourceFile(String name, String extension) {
  String filename = name.replace('.', '/') + "." + extension;
  URL ret = getResource(filename);
  if (isFile(ret) && getFileForUrl(ret, filename) == null) return null;
  return ret;
}

代码示例来源:origin: org.codehaus.groovy/groovy

/**
 * Decides if the given source is newer than a class.
 *
 * @param source the source we may want to compile
 * @param cls    the former class
 * @return true if the source is newer, false else
 * @throws IOException if it is not possible to open an
 *                     connection for the given source
 * @see #getTimeStamp(Class)
 */
protected boolean isSourceNewer(URL source, Class cls) throws IOException {
  long lastMod;
  // Special handling for file:// protocol, as getLastModified() often reports
  // incorrect results (-1)
  if (isFile(source)) {
    // Coerce the file URL to a File
    // See ClassNodeResolver.isSourceNewer for another method that replaces '|' with ':'.
    // WTF: Why is this done and where is it documented?
    String path = source.getPath().replace('/', File.separatorChar).replace('|', ':');
    File file = new File(path);
    lastMod = file.lastModified();
  } else {
    URLConnection conn = source.openConnection();
    lastMod = conn.getLastModified();
    conn.getInputStream().close();
  }
  long classTime = getTimeStamp(cls);
  return classTime + config.getMinimumRecompilationInterval() < lastMod;
}

代码示例来源:origin: org.codehaus.groovy/groovy

if (isFile(source)) {
  try {
    return parseClass(new GroovyCodeSource(new File(source.toURI()), sourceEncoding));

代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm

private URL getSourceFile(String name, String extension) {
  String filename = name.replace('.', '/') + "." + extension;
  URL ret = getResource(filename);
  if (isFile(ret) && getFileForUrl(ret, filename) == null) return null;
  return ret;
}

代码示例来源:origin: org.codehaus.groovy/groovy-jdk14

/**
 * Decides if the given source is newer than a class.
 *
 * @param source the source we may want to compile
 * @param cls    the former class
 * @return true if the source is newer, false else
 * @throws IOException if it is not possible to open an
 *                     connection for the given source
 * @see #getTimeStamp(Class)
 */
protected boolean isSourceNewer(URL source, Class cls) throws IOException {
  long lastMod;
  // Special handling for file:// protocol, as getLastModified() often reports
  // incorrect results (-1)
  if (isFile(source)) {
    // Coerce the file URL to a File
    String path = source.getPath().replace('/', File.separatorChar).replace('|', ':');
    File file = new File(path);
    lastMod = file.lastModified();
  } else {
    URLConnection conn = source.openConnection();
    lastMod = conn.getLastModified();
    conn.getInputStream().close();
  }
  long classTime = getTimeStamp(cls);
  return classTime + config.getMinimumRecompilationInterval() < lastMod;
}

代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm

/**
 * Decides if the given source is newer than a class.
 *
 * @param source the source we may want to compile
 * @param cls    the former class
 * @return true if the source is newer, false else
 * @throws IOException if it is not possible to open an
 *                     connection for the given source
 * @see #getTimeStamp(Class)
 */
protected boolean isSourceNewer(URL source, Class cls) throws IOException {
  long lastMod;
  // Special handling for file:// protocol, as getLastModified() often reports
  // incorrect results (-1)
  if (isFile(source)) {
    // Coerce the file URL to a File
    String path = source.getPath().replace('/', File.separatorChar).replace('|', ':');
    File file = new File(path);
    lastMod = file.lastModified();
  } else {
    URLConnection conn = source.openConnection();
    lastMod = conn.getLastModified();
    conn.getInputStream().close();
  }
  long classTime = getTimeStamp(cls);
  return classTime + config.getMinimumRecompilationInterval() < lastMod;
}

代码示例来源:origin: org.codehaus.groovy/groovy-jdk14

private URL getSourceFile(String name) {
  String filename = name.replace('.', '/') + config.getDefaultScriptExtension();
  URL ret = getResource(filename);
  if (isFile(ret) && getFileForUrl(ret,filename)==null) return null;
  return ret;
}

代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm

String name = source.toExternalForm();
sourceCache.remove(name);
if (isFile(source)) {
  try {
    return parseClass(new GroovyCodeSource(new File(source.toURI()), config.getSourceEncoding()));

相关文章