congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
ResourceCollection
Code IndexAdd Tabnine to your IDE (free)

How to use
ResourceCollection
in
org.apache.tools.ant.types

Best Java code snippets using org.apache.tools.ant.types.ResourceCollection (Showing top 20 results out of 315)

origin: org.apache.ant/ant

/**
 * Construct a new ConcatResourceInputStream
 * for the specified ResourceCollection.
 * @param rc the ResourceCollection to combine.
 */
 public ConcatResourceInputStream(ResourceCollection rc) {
   iter = rc.iterator();
 }
origin: org.apache.ant/ant

if (!rc.isFilesystemOnly() && !supportsNonFileResources()) {
  throw new BuildException(
    "Only FileSystem resources are supported.");
if (rc.isEmpty()) {
  throw new BuildException(MSG_WHEN_COPYING_EMPTY_RC_TO_FILE);
if (rc.size() == 1) {
  final Resource res = rc.iterator().next();
  final FileProvider r = res.as(FileProvider.class);
  if (file == null) {
origin: org.apache.ant/ant

/**
 * Add all resources in a resource collection to the source list.
 * @since Ant 1.7.1
 * @param collection the resource to load
 * @throws BuildException if a resource cannot be read
 */
public void loadResources(ResourceCollection collection) {
  collection.forEach(this::loadResource);
}
origin: org.apache.ant/ant

/**
 * Set the source resource.
 * @param a the resource to load as a single element Resource collection.
 */
public void addConfigured(ResourceCollection a) {
  if (a.size() != 1) {
    throw new BuildException(
      "only single argument resource collections are supported");
  }
  src = a.iterator().next();
}
origin: org.apache.ant/ant

/**
 * Take all elements except for the last <code>count</code> elements.
 * @return a Collection of Resources.
 */
@Override
protected Collection<Resource> getCollection() {
  int ct = getValidCount();
  ResourceCollection nested = getResourceCollection();
  if (ct > nested.size()) {
    return Collections.emptyList();
  }
  return nested.stream().limit((long) nested.size() - ct)
    .collect(Collectors.toList());
}
origin: org.apache.ant/ant

/**
 * whether the given resource collection is a (subclass of)
 * FileSet that only contains file system resources.
 * @param rc the resource collection to check.
 * @return true if the collection is a fileset.
 * @since Ant 1.7
 */
protected static boolean isFileFileSet(final ResourceCollection rc) {
  return rc instanceof FileSet && rc.isFilesystemOnly();
}
origin: org.apache.ant/ant

  /**
   * Learn whether this {@link ResourceCollection} is empty.
   * @return boolean
   */
  default boolean isEmpty() {
    return size() == 0;
  }
}
origin: org.apache.ant/ant

/**
 * Set the source resource.
 * @param a the resource to load as a single element Resource collection.
 * @since Ant 1.7
 */
public synchronized void addConfigured(ResourceCollection a) {
  if (src != null) {
    throw new BuildException("only a single source is supported");
  }
  if (a.size() != 1) {
    throw new BuildException(
        "only single-element resource collections are supported");
  }
  src = a.iterator().next();
}
origin: org.testng/testng

private ResourceCollection createResourceCollection(Reference ref) {
 Object o = ref.getReferencedObject();
 if (!(o instanceof ResourceCollection)) {
   throw new BuildException("Only File based ResourceCollections are supported.");
 }
 ResourceCollection rc = (ResourceCollection) o;
 if (!rc.isFilesystemOnly()) {
   throw new BuildException("Only ResourceCollections from local file system are supported.");
 }
 return rc;
}
origin: org.apache.ant/ant

/**
 * Fulfill the condition contract.
 * @return true if the specified ResourceCollection satisfies the set criteria.
 * @throws BuildException if an error occurs.
 */
@Override
public boolean eval() {
  if (rc == null) {
    throw new BuildException(ONE_NESTED_MESSAGE);
  }
  if (count == null) {
    throw new BuildException(COUNT_REQUIRED);
  }
  return when.evaluate(Integer.valueOf(rc.size()).compareTo(count));
}
origin: org.apache.ant/ant

/**
 * Take the last <code>count</code> elements.
 * @return a Collection of Resources.
 */
@Override
protected Collection<Resource> getCollection() {
  int count = getValidCount();
  ResourceCollection rc = getResourceCollection();
  int size = rc.size();
  int skip = Math.max(0, size - count);
  List<Resource> result =
    rc.stream().skip(skip).collect(Collectors.toList());
  int found = result.size();
  if (found == count || (size < count && found == size)) {
    return result;
  }
  //mismatch:
  String msg = String.format(
    "Resource collection %s reports size %d but returns %d elements.",
    rc, size, found + skip);
  //size was understated -> too many results; warn and continue:
  if (found > count) {
    log(msg, Project.MSG_WARN);
    return result.subList(found - count, found);
  }
  //size was overstated; we missed some and are now in error-land:
  throw new BuildException(msg);
}
origin: org.apache.ant/ant

@Override
public boolean hasNext() {
  boolean result = ri != null && ri.hasNext();
  while (!result && rci.hasNext()) {
    ri = rci.next().iterator();
    result = ri.hasNext();
  }
  return result;
}
@Override
origin: org.apache.ant/ant

/**
 * Set the source resource.
 * @param a the resource to pack as a single element Resource collection.
 */
public void addConfigured(ResourceCollection a) {
  if (a.size() != 1) {
    throw new BuildException(
        "only single argument resource collections are supported as archives");
  }
  setSrcResource(a.iterator().next());
}
origin: org.apache.ant/ant

/**
 * Sets the archive that holds this as a single element Resource
 * collection.
 * @param a the archive as a single element Resource collection.
 */
public void addConfigured(ResourceCollection a) {
  super.addConfigured(a);
  if (!a.isFilesystemOnly()) {
    throw new BuildException("only filesystem resources are supported");
  }
}
origin: org.apache.ant/ant

/**
 * Execute as a Task.
 */
@Override
public void execute() {
  if (rc == null) {
    throw new BuildException(ONE_NESTED_MESSAGE);
  }
  if (property == null) {
    log("resource count = " + rc.size());
  } else {
    getProject().setNewProperty(property, Integer.toString(rc.size()));
  }
}
origin: org.apache.ant/ant

/**
 * Return a {@link Stream} over this {@link ResourceCollection}.
 * @return {@link Stream} of {@link Resource}
 * @since Ant 1.10.2
 */
default Stream<? extends Resource> stream() {
  final Stream.Builder<Resource> b = Stream.builder();
  forEach(b);
  return b.build();
}
origin: org.apache.ant/ant

private Resource getXest(ResourceCollection rc, ResourceComparator c) {
  return StreamUtils.iteratorAsStream(rc.iterator()).max(c).orElse(null);
}
origin: org.apache.ant/ant

/**
 * Set the source resource.
 * @param a the source resource collection.
 * @since Ant 1.7
 */
public void addConfigured(ResourceCollection a) {
  if (a.size() != 1) {
    throw new BuildException(
      "only single argument resource collections are supported.");
  }
  setSrcResource(a.iterator().next());
}
origin: cbeust/testng

private ResourceCollection createResourceCollection(Reference ref) {
 Object o = ref.getReferencedObject();
 if (!(o instanceof ResourceCollection)) {
  throw new BuildException("Only File based ResourceCollections are supported.");
 }
 ResourceCollection rc = (ResourceCollection) o;
 if (!rc.isFilesystemOnly()) {
  throw new BuildException("Only ResourceCollections from local file system are supported.");
 }
 return rc;
}
origin: org.apache.ant/ant

/**
 * Efficient size implementation.
 * @return int size
 */
@Override
public synchronized int size() {
  return Math.min(getResourceCollection().size(), getValidCount());
}
org.apache.tools.ant.typesResourceCollection

Javadoc

Interface describing a collection of Resources.

Most used methods

  • iterator
  • isFilesystemOnly
    Indicate whether this ResourceCollection is composed entirely of Resources accessible via local file
  • size
    Learn the number of contained Resources.
  • forEach
  • isEmpty
    Learn whether this ResourceCollection is empty.
  • stream
    Return a Stream over this ResourceCollection.

Popular in Java

  • Reading from database using SQL prepared statement
  • getApplicationContext (Context)
  • requestLocationUpdates (LocationManager)
  • getContentResolver (Context)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • Kernel (java.awt.image)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now