Class Query

java.lang.Object
org.rapidcontext.core.storage.Query

public class Query extends Object
A storage query for streaming metadata or data results. Searches are performed depth-first and will only returns objects (or their metadata), omitting indices.
Version:
1.0
  • Constructor Details

    • Query

      public Query(Storage storage, Path base)
      Creates a new query for the specified storage.
      Parameters:
      storage - the storage to query
      base - the base path
  • Method Details

    • filter

      public Query filter(Predicate<Path> predicate)
      Adds a path predicate filter to all results.
      Parameters:
      predicate - the predicate to filter with
      Returns:
      this query instance
    • filterShowHidden

      public Query filterShowHidden(boolean hidden)
      Toggle hidden path inclusion in results (defaults to false).
      Parameters:
      hidden - include hidden paths
      Returns:
      this query instance
    • filterDepth

      public Query filterDepth(int depth)
      Adds a path depth filter to all results. A depth of zero (0) will only match child paths directly on the base path.
      Parameters:
      depth - the additional depth, or -1 for any
      Returns:
      this query instance
    • filterFileExtension

      public Query filterFileExtension(String ext)
      Adds a file name extension filter to all results.
      Parameters:
      ext - the file extension to match
      Returns:
      this query instance
    • filterAccess

      public Query filterAccess(String permission)
      Adds an access filter (for current user) to all results.
      Parameters:
      permission - the permission to require
      Returns:
      this query instance
    • paths

      public Stream<Path> paths()
      Returns the stream of matching object paths.
      Returns:
      the stream of matching object paths
    • metadatas

      public Stream<Metadata> metadatas()
      Returns the stream of metadata found.
      Returns:
      the stream of metadata found
    • metadatas

      public Stream<Metadata> metadatas(Class<?> clazz)
      Returns the stream of metadata found for objects of a specified type.
      Parameters:
      clazz - the class required for objects
      Returns:
      the stream of metadata found
    • objects

      public Stream<Object> objects()
      Returns the stream of objects found.
      Returns:
      the stream of objects found
    • objects

      public <T> Stream<T> objects(Class<T> clazz)
      Returns the stream of objects found of a specified type.
      Type Parameters:
      T - the type to cast objects to
      Parameters:
      clazz - the class required for objects
      Returns:
      the stream of objects found