Class Target

java.lang.Object
com.spertus.jacquard.common.Target

public final class Target extends Object
The target of a Grader, which must be a file.
  • Method Details

    • fromPath

      public static Target fromPath(Path path)
      Creates a target from a path, which must be to a single file.
      Parameters:
      path - the path
      Returns:
      the target
      Throws:
      ClientException - if the path is to a directory rather than a file
    • fromPathString

      public static Target fromPathString(String s)
      Creates a target from a relative path string to a file. It does not matter whether forward slashes or backslashes are used as separators.
      Parameters:
      s - a relative path string to a file
      Returns:
      the target
      Throws:
      ClientException - if the path is to a directory rather than a file
    • fromClass

      public static Target fromClass(Class<?> targetClass)
      Creates a target from a class that the student is responsible for submitting. The class's package must not be empty.
      Parameters:
      targetClass - the class
      Returns:
      the target
      Throws:
      ClientException - if the package of the class is invalid
    • fromPathStrings

      public static List<Target> fromPathStrings(String dir, String... files)
      Creates targets from a directory string and list of files in the directory.
      Parameters:
      dir - a relative directory string (ending with / or \)
      files - the names of the files in the directory
      Returns:
      the targets
      Throws:
      ClientException - if dir does not end with a path separator
    • fromDirectory

      public static List<Target> fromDirectory(String dir)
      Creates targets from all the files in the specified directory.
      Parameters:
      dir - a relative directory string
      Returns:
      the targets
      Throws:
      ClientException - if dir is not a directory or is not accessible
    • toPathString

      public String toPathString()
      Gets the string representation of this target's absolute path.
      Returns:
      the string representation of this target's absolute path
    • toPath

      public Path toPath()
      Gets this target's path
      Returns:
      this target's path
    • toFile

      public File toFile()
      Gets this target's file (which may be a directory).
      Returns:
      this target's file
    • toDirectory

      public Path toDirectory()
      Gets this target's directory.
      Returns:
      the directory
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object