Class Path

    • Constructor Detail

      • Path

        protected Path​(java.lang.String path,
                       ArtifactModel model)
        Creates a path from the given string representation. A path may be a (regular) pattern!
        Parameters:
        path - the path to construct the path object from
        model - the artifact model as a basis for relative paths
    • Method Detail

      • createInstance

        public static Path createInstance​(Path path,
                                          ArtifactModel model)
        Creates a path from the given (relative) path and directly localizes it into model. A path may be a (regular) pattern!
        Parameters:
        path - the path to construct this path object from
        model - the artifact model as a basis for relative paths
        Returns:
        the created path
      • createInstance

        public static Path createInstance​(java.lang.String path,
                                          ArtifactModel model)
        Creates a path from the given string representation. A path may be a (regular) pattern!
        Parameters:
        path - the path to construct the path object from
        model - the artifact model as a basis for relative paths
        Returns:
        the created path
      • createInstance

        public static Path createInstance​(java.io.File file,
                                          ArtifactModel model)
        Creates a path from the given string representation. A path may be a (regular) pattern!
        Parameters:
        file - the file to construct the path from
        model - the artifact model as a basis for relative paths
        Returns:
        the created path
      • lookupOrCreate

        private static Path lookupOrCreate​(java.lang.String path,
                                           ArtifactModel model)
        Looks up the given path in the path cache or creates a new path object registering it in the path cache of model.
        Parameters:
        path - the path to create the path object for
        model - the artifact model as a basis for relative paths
        Returns:
        the created/found path
      • getArtifactModel

        public ArtifactModel getArtifactModel()
        Returns the containing artifact model.
        Returns:
        the containing artifact model
      • create

        public static Path create​(java.lang.String path)
                           throws VilException
        Creates a path from the given string representation. A path may be a (regular) pattern!
        Parameters:
        path - the path to construct the path object from
        Returns:
        the created path object
        Throws:
        VilException - in case that the path does not comply to Java conventions
      • getPath

        public java.lang.String getPath()
        Returns the path represented by this instance. This path may be a pattern.
        Returns:
        the represented path
      • getAbsolutePath

        public java.io.File getAbsolutePath()
        Returns the absolute path with respect to model.
        Returns:
        the absolute path
      • getParent

        public Path getParent()
        Returns the parent of this path.
        Returns:
        the parent, this if there is no further parent
      • getAbsolutePath

        private java.io.File getAbsolutePath​(java.io.File base)
        Returns the absolute path.
        Parameters:
        base - the base path for turning relative paths into absolute paths
        Returns:
        the absolute path
      • isPattern

        public boolean isPattern()
        Returns whether this path is a pattern.
        Returns:
        true if it is a pattern, false else
      • toJavaPath

        public JavaPath toJavaPath()
                            throws VilException
        Turns this path into a java package name.
        Returns:
        the related java Package name
        Throws:
        VilException - in case that the related Java path cannot be created
      • toJavaPath

        public JavaPath toJavaPath​(java.lang.String prefixRegEx)
                            throws VilException
        Turns this path into a java package name.
        Parameters:
        prefixRegEx - an optional regular expression (intended for path prefixes) to be replaced by the empty string (may be null)
        Returns:
        the related java Package name
        Throws:
        VilException - in case that the related Java path cannot be created
      • toOSPath

        public java.lang.String toOSPath()
        Turns this path into a relative native OS path.
        Returns:
        the native OS path as a string
      • toAbsoluteOSPath

        public java.lang.String toAbsoluteOSPath()
                                          throws VilException
        Turns this path into an absolute native OS path.
        Returns:
        the native OS path as a string
        Throws:
        VilException - in case that accessing the absolute path fails
      • deleteAll

        public void deleteAll()
                       throws VilException
        Deletes all files in the given path.
        Throws:
        VilException - in case of I/O problems
      • mkdir

        public void mkdir()
                   throws VilException
        Creates the directories pointing to path.
        Throws:
        VilException - in case of a pattern path or if access to the absolute path fails
      • convert

        public static Path convert​(java.lang.String val)
        Conversion operation.
        Parameters:
        val - the value to be converted
        Returns:
        the converted value
      • convert

        public static IFileSystemArtifact convert​(Path path)
                                           throws VilException
        Converts a path into a file system artifact.
        Parameters:
        path - the path to be converted
        Returns:
        the resulting artifact
        Throws:
        VilException - in case of problems
      • matches

        public boolean matches​(Path path)
        Returns whether this path matches the given path.
        Parameters:
        path - the path to check the match for
        Returns:
        true of the match is positive, false else
      • match

        private static boolean match​(Path pattern,
                                     Path path,
                                     boolean prefix)
        Convert the paths into absolute normalized paths and match or test for prefix equality.
        Parameters:
        pattern - the path representing the pattern
        path - the path to be matched
        prefix - do a prefix check of pattern in path or match pattern as ANT pattern in path
        Returns:
        true if path matches pattern, false else
      • selectByType

        public Set<FileArtifact> selectByType​(java.lang.Class<?> type)
        Does type selection of artifacts by type equality.
        Parameters:
        type - the target type
        Returns:
        the selected artifacts (the type will be adjusted to the actual type of type)
      • selectByKind

        public Set<FileArtifact> selectByKind​(java.lang.Class<?> type)
        Does type selection of artifacts by sub-typing.
        Parameters:
        type - the target type
        Returns:
        the selected artifacts (the type will be adjusted to the actual type of type)
      • typeReject

        public Set<FileArtifact> typeReject​(java.lang.Class<?> type)
        Does type selection of artifacts by not matched sub-typing.
        Parameters:
        type - the target type
        Returns:
        the selected artifacts (the type will be adjusted to the actual type of type)
      • selectAll

        public Set<FileArtifact> selectAll()
        Selects all file artifacts represented by this path.
        Returns:
        all file artifacts represented by path
      • concat

        public static java.lang.String concat​(Path path,
                                              java.lang.String string)
        Represents the path/string concatenation operation.
        Parameters:
        path - the Path to be considered
        string - the String to be considered
        Returns:
        path + string
      • concat

        public static java.lang.String concat​(java.lang.String string,
                                              Path path)
        Represents the path/string concatenation operation.
        Parameters:
        string - the String to be considered
        path - the Path to be considered
        Returns:
        string + path
      • getStringValue

        public java.lang.String getStringValue​(IStringValueProvider.StringComparator comparator)
        Description copied from interface: IStringValueProvider
        Returns the string value of this object.
        Specified by:
        getStringValue in interface IStringValueProvider
        Parameters:
        comparator - if the sequence of elements, e.g., in case of collections, shall be ordered according to the comparator, null if the original sequence shall be returned
        Returns:
        the string value
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • lastModification

        public long lastModification()
        Returns the last modification timestamp of this artifact.
        Returns:
        the last modification timestamp, 0 if unknown
      • exists

        public boolean exists()
        Returns whether this artifact is exists.
        Returns:
        true if this artifact exists, false else
      • getName

        public java.lang.String getName()
                                 throws VilException
        Returns the simple name of this artifact.
        Returns:
        the simple name
        Throws:
        VilException - in case that the operation cannot continue
      • getPathSegments

        public java.lang.String getPathSegments()
        Returns the path segments of this path (excluding the names).
        Returns:
        the path segments
      • rename

        public Path rename​(java.lang.String name)
                    throws VilException
        Renames the underlying artifact and returns a new path if necessary.
        Parameters:
        name - the new name (absolute or relative)
        Returns:
        the new path reflecting the replaced artifact
        Throws:
        VilException - in case that renaming fails
      • isTemporary

        public boolean isTemporary()
        Returns whether this path is considered to be temporary.
        Returns:
        true if it is temporary, false else
      • copy

        public Set<IFileSystemArtifact> copy​(IFileSystemArtifact target)
                                      throws VilException
        Copies the artifacts denoted by this path to target.
        Parameters:
        target - the target artifact
        Returns:
        the created or touched artifacts
        Throws:
        VilException - in case that file system operations or artifact model operations fail
      • move

        public Set<IFileSystemArtifact> move​(IFileSystemArtifact target)
                                      throws VilException
        Moves the artifacts denoted by this path to target.
        Parameters:
        target - the target artifact
        Returns:
        the created or touched artifacts
        Throws:
        VilException - in case that file system operations or artifact model operations fail