/** * Delegates to a comparison of names. * @param other the object to compare to. * @return a negative integer, zero, or a positive integer as this Resource * is less than, equal to, or greater than the specified Resource. * @since Ant 1.6 */ @Override public int compareTo(Resource other) { if (isReference()) { return getCheckedRef().compareTo(other); } return toString().compareTo(other.toString()); }
@Override protected synchronized void handle(Resource r) { long size = r.getSize(); if (size == Resource.UNKNOWN_SIZE) { log("Size unknown for " + r.toString(), Project.MSG_WARN); } else { accum += size; } } }
/** * Return this URLResource formatted as a String. * @return a String representation of this URLResource. */ public synchronized String toString() { return isReference() ? getCheckedRef().toString() : String.valueOf(getURL()); }
@Override protected void handle(Resource r) { getPs().print(r.toString()); getPs().print(" : "); //when writing to the log, we'll see what's happening: long size = r.getSize(); if (size == Resource.UNKNOWN_SIZE) { getPs().println("unknown"); } else { getPs().println(size); } } }
/** * Return true if this Resource is selected. * @param r the Resource to check. * @return whether the Resource was selected. */ public boolean isSelected(Resource r) { String n = r.getName(); if (matches(n)) { return true; } String s = r.toString(); return !s.equals(n) && matches(s); }
/** * {@inheritDoc} */ @Override public String toString() { if (isReferenceOrProxy()) { return getReferencedOrProxied().toString(); } return getValue(); }
@Override public String toString() { if (isReference()) { return getCheckedRef().toString(); } return getName(); }
private void runTransaction(PrintStream out) throws IOException, SQLException { if (!tSqlCommand.isEmpty()) { log("Executing commands", Project.MSG_INFO); runStatements(new StringReader(tSqlCommand), out); } if (tSrcResource != null) { log("Executing resource: " + tSrcResource.toString(), Project.MSG_INFO); Charset charset = encoding == null ? Charset.defaultCharset() : Charset.forName(encoding); try (Reader reader = new InputStreamReader( tSrcResource.getInputStream(), charset)) { runStatements(reader, out); } } } }
/** * Get the string representation of this Resource. * @return this Resource formatted as a String. * @since Ant 1.7 */ @Override public String toString() { if (isReference()) { return getCheckedRef().toString(); } String n = getName(); return n == null ? "(anonymous)" : n; }
/** * Returns the list of files corresponding to the resource collection * * @param resources - A list of {@link ResourceCollection} * @return the list of files corresponding to the resource collection * @throws BuildException */ private List<String> getFiles(List<ResourceCollection> resources) throws BuildException { List<String> files= Lists.newArrayList(); for (ResourceCollection rc : resources) { for (Resource o : rc) { if (o instanceof FileResource) { FileResource fr = ((FileResource) o); if (fr.isDirectory()) { throw new BuildException("Directory based FileResources are not supported."); } if (! fr.isExists()) { log("'" + fr.toLongString() + "' does not exist", Project.MSG_VERBOSE); } files.add(fr.getFile().getAbsolutePath()); } else { log("Unsupported Resource type: " + o.toString(), Project.MSG_VERBOSE); } } } return files; }
/** * Get a long String representation of this Resource. * This typically should be the value of <code>toString()</code> * prefixed by a type description. * @return this Resource formatted as a long String. * @since Ant 1.7 */ public final String toLongString() { return isReference() ? getCheckedRef().toLongString() : getDataTypeName() + " \"" + toString() + '"'; }
/** * validate, then hand off to the subclass * @throws BuildException on error */ @Override public void execute() throws BuildException { validate(); Resource s = getSrcResource(); if (!s.isExists()) { log("Nothing to do: " + s.toString() + " doesn't exist."); } else if (zipFile.lastModified() < s.getLastModified()) { log("Building: " + zipFile.getAbsolutePath()); pack(); } else { log("Nothing to do: " + zipFile.getAbsolutePath() + " is up to date."); } }
/** * Format this Resource as a String. * @return String representation of this Resource. */ @Override public String toString() { return isReference() ? getCheckedRef().toString() : getArchive().toString() + ':' + getName(); }
/** * Returns the list of files corresponding to the resource collection * * @param resources - A list of {@link ResourceCollection} * @return the list of files corresponding to the resource collection * @throws BuildException */ private List<String> getFiles(List<ResourceCollection> resources) throws BuildException { List<String> files = Lists.newArrayList(); for (ResourceCollection rc : resources) { for (Resource o : rc) { if (o instanceof FileResource) { FileResource fr = ((FileResource) o); if (fr.isDirectory()) { throw new BuildException("Directory based FileResources are not supported."); } if (!fr.isExists()) { log("'" + fr.toLongString() + "' does not exist", Project.MSG_VERBOSE); } files.add(fr.getFile().getAbsolutePath()); } else { log("Unsupported Resource type: " + o.toString(), Project.MSG_VERBOSE); } } } return files; }
/** * Load the specified Saxon configuration file. * * @param saxonConfigFile the path to the Saxon configuration file to be loaded */ public void setSaxonConfigFile(Resource saxonConfigFile) { try { userArgs.setSaxonConfig(saxonConfigFile.getInputStream(), saxonConfigFile.toString()); } catch (Exception e) { handleError(e); } }
/** * Specify a particular configuration file to be loaded. * * @param configFile the path to a particular configuration file to be loaded */ public void setConfigFile(Resource configFile) { try { userArgs.setConfig(configFile.getInputStream(), configFile.toString()); } catch (Exception e) { handleError(e); } }
/** * Set the pipeline. optional, nested <pipeline> will be used if not set. * * @param pipeline pipeline location */ public void setPipeline(Resource pipeline) { try { userArgs.setPipeline(pipeline.getInputStream(), pipeline.toString()); this.pipelineResource = pipeline; } catch (Exception e) { handleError(e); } }
/** * Load the specified Saxon configuration file. * * @param saxonConfigFile the path to the Saxon configuration file to be loaded */ public void setSaxonConfigFile(Resource saxonConfigFile) { try { userArgs.setSaxonConfig(saxonConfigFile.getInputStream(), saxonConfigFile.toString()); } catch (Exception e) { handleError(e); } }
/** * Specify a particular configuration file to be loaded. * * @param configFile the path to a particular configuration file to be loaded */ public void setConfigFile(Resource configFile) { try { userArgs.setConfig(configFile.getInputStream(), configFile.toString()); } catch (Exception e) { handleError(e); } }