APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.jpackage.internal.util

public final Class PathGroup

extends Object
Class Inheritance
Static Imports
java.util.stream.Collectors.collectingAndThen, .Collectors.groupingBy, .Collectors.toMap, .Collectors.toSet

Group of paths. Each path in the group is assigned a unique id.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static record
private static record
public static interface
PathGroup.TransformHandler

Handler of file copying and directory creating.

Field Summary

Modifier and TypeField and Description
private final Map<Object, Path>

Constructor Summary

AccessConstructor and Description
public
PathGroup(Map<Object, Path>
the initial paths
paths
)

Creates path group with the initial paths.

Method Summary

Modifier and TypeMethod and Description
public void
copy(PathGroup
the destination path group
dst
,
CopyOption... options)

Copies files/directories from the locations in the path group into the locations of the given path group.

private static void
copy(PathGroup src, PathGroup dst, PathGroup.TransformHandler handler, boolean followSymlinks)

private static void
copy(List<PathGroup.CopySpec> copySpecs, List<Path> excludePaths, PathGroup.TransformHandler handler, boolean followSymlinks)

private void
public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public Path

Returns:

the path corresponding to the given identifier in this path group or null if there is no such path
getPath
(Object
the identifier
id
)

Returns a path associated with the given identifier in this path group.

public void
ghostPath(Path
the path to associate the new unique identifier in this path group
path
)

Adds a path associated with the new unique identifier to this path group.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public Set<Object>

Returns:

all identifiers of this path group
keys
()

Gets all identifiers of this path group.

private static boolean
match(Path what, List<Path> paths)

public void
move(PathGroup
the destination path group
dst
,
CopyOption... options)

Similar to copy(PathGroup, CopyOption...) but moves files/directories instead of copying.

public List<Path>

Returns:

paths associated with all identifiers in this path group
paths
()

Gets paths associated with all identifiers in this path group.

public PathGroup

Returns:

a new path group resolved against the given root path
resolveAt
(Path
the root against which to resolve paths
root
)

Creates a copy of this path group with all paths resolved against the given root.

public List<Path>

Returns:

unique root paths in this path group
roots
()

Gets root paths in this path group.

public void
setPath(Object
the identifier
id
,
Path
the path to associate with the identifier or null
path
)

Assigns the specified path value to the given identifier in this path group.

public long

Returns:

the total number of bytes in root paths of this path group
sizeInBytes
()

Gets the number of bytes in root paths of this path group.

private static long
public void
transform(PathGroup
the destination path group
dst
,
PathGroup.TransformHandler
the path transformation handler
handler
)

Similar to copy(PathGroup, CopyOption...) but uses the given handler to transform paths instead of coping.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

entriesback to summary
private final Map<Object, Path> entries

Constructor Detail

PathGroupback to summary
public PathGroup(Map<Object, Path> paths)

Creates path group with the initial paths.

Parameters
paths:Map<Object, Path>

the initial paths

Method Detail

copyback to summary
public void copy(PathGroup dst, CopyOption... options) throws IOException

Copies files/directories from the locations in the path group into the locations of the given path group. For every identifier found in this and the given group, copy the associated file or directory from the location specified by the path value associated with the identifier in this group into the location associated with the identifier in the given group.

Parameters
dst:PathGroup

the destination path group

Exceptions
IOException:
If an I/O error occurs
copyback to summary
private static void copy(PathGroup src, PathGroup dst, PathGroup.TransformHandler handler, boolean followSymlinks) throws IOException
copyback to summary
private static void copy(List<PathGroup.CopySpec> copySpecs, List<Path> excludePaths, PathGroup.TransformHandler handler, boolean followSymlinks) throws IOException
deleteEntriesback to summary
private void deleteEntries() throws IOException
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
getPathback to summary
public Path getPath(Object id)

Returns a path associated with the given identifier in this path group.

Parameters
id:Object

the identifier

Returns:Path

the path corresponding to the given identifier in this path group or null if there is no such path

ghostPathback to summary
public void ghostPath(Path path)

Adds a path associated with the new unique identifier to this path group.

Parameters
path:Path

the path to associate the new unique identifier in this path group

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
keysback to summary
public Set<Object> keys()

Gets all identifiers of this path group.

The order of identifiers in the returned list is undefined.

Returns:Set<Object>

all identifiers of this path group

matchback to summary
private static boolean match(Path what, List<Path> paths)
moveback to summary
public void move(PathGroup dst, CopyOption... options) throws IOException

Similar to copy(PathGroup, CopyOption...) but moves files/directories instead of copying.

Parameters
dst:PathGroup

the destination path group

Exceptions
IOException:
If an I/O error occurs
pathsback to summary
public List<Path> paths()

Gets paths associated with all identifiers in this path group.

The order of paths in the returned list is undefined.

Returns:List<Path>

paths associated with all identifiers in this path group

resolveAtback to summary
public PathGroup resolveAt(Path root)

Creates a copy of this path group with all paths resolved against the given root. Taken action is equivalent to creating a copy of this path group and calling root.resolve() on every path in the copy.

Parameters
root:Path

the root against which to resolve paths

Returns:PathGroup

a new path group resolved against the given root path

rootsback to summary
public List<Path> roots()

Gets root paths in this path group.

If multiple identifiers are associated with the same path value in the group, the path value is added to the returned list only once. Paths that are descendants of other paths in the group are not added to the returned list.

The order of paths in the returned list is undefined.

Returns:List<Path>

unique root paths in this path group

setPathback to summary
public void setPath(Object id, Path path)

Assigns the specified path value to the given identifier in this path group. If the given identifier doesn't exist in this path group, it is added, otherwise, the current value associated with the identifier is replaced with the given path value. If the path value is null the given identifier is removed from this path group if it existed; otherwise, no action is taken.

Parameters
id:Object

the identifier

path:Path

the path to associate with the identifier or null

sizeInBytesback to summary
public long sizeInBytes() throws IOException

Gets the number of bytes in root paths of this path group. The method sums the size of all root path entries in the group. If the path entry is a directory it calculates the total size of the files in the directory. If the path entry is a file, it takes its size.

Returns:long

the total number of bytes in root paths of this path group

Exceptions
IOException:
If an I/O error occurs
sizeInBytesback to summary
private static long sizeInBytes(Path path) throws UncheckedIOException
transformback to summary
public void transform(PathGroup dst, PathGroup.TransformHandler handler) throws IOException

Similar to copy(PathGroup, CopyOption...) but uses the given handler to transform paths instead of coping.

Parameters
dst:PathGroup

the destination path group

handler:PathGroup.TransformHandler

the path transformation handler

Exceptions
IOException:
If an I/O error occurs
jdk.jpackage.internal.util back to summary

private final Record PathGroup.Copy

extends Record
implements TransformHandler
Class Inheritance
All Implemented Interfaces
jdk.jpackage.internal.util.PathGroup.TransformHandler
Record Components
move:boolean 
followSymlinks:boolean 
options:CopyOption[] 

Field Summary

Modifier and TypeField and Description
private final boolean
followSymlinks

Record Component accessed by followSymlinks().

private final boolean
move

Record Component accessed by move().

private final CopyOption[]
options

Record Component accessed by options().

Constructor Summary

AccessConstructor and Description
pack-priv
Copy(boolean move, CopyOption... options)

private
Copy(boolean move, boolean followSymlinks, CopyOption... options)

Method Summary

Modifier and TypeMethod and Description
public void
copyFile(Path src, Path dst)

Overrides default jdk.jpackage.internal.util.PathGroup.TransformHandler.copyFile.

Request to copy a file from the given source location into the given destination location.

public void
createDirectory(Path dir)

Overrides default jdk.jpackage.internal.util.PathGroup.TransformHandler.createDirectory.

Request to create a directory at the given location.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public boolean
move()

Record Component getter of move.

public CopyOption[]
options()

Record Component getter of options.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

moveback to summary
private final boolean move

Record Component accessed by move().

optionsback to summary
private final CopyOption[] options

Record Component accessed by options().

Constructor Detail

Copyback to summary
pack-priv Copy(boolean move, CopyOption... options)
Copyback to summary
private Copy(boolean move, boolean followSymlinks, CopyOption... options)

Method Detail

copyFileback to summary
public void copyFile(Path src, Path dst) throws IOException

Overrides default jdk.jpackage.internal.util.PathGroup.TransformHandler.copyFile.

Doc from jdk.jpackage.internal.util.PathGroup.TransformHandler.copyFile.

Request to copy a file from the given source location into the given destination location.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
createDirectoryback to summary
public void createDirectory(Path dir) throws IOException

Overrides default jdk.jpackage.internal.util.PathGroup.TransformHandler.createDirectory.

Doc from jdk.jpackage.internal.util.PathGroup.TransformHandler.createDirectory.

Request to create a directory at the given location.

Annotations
@Override
equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

moveback to summary
public boolean move()

Record Component getter of move.

optionsback to summary
public CopyOption[] options()

Record Component getter of options.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

jdk.jpackage.internal.util back to summary

private final Record PathGroup.CopySpec

extends Record
Class Inheritance
Record Components
basepath:Path 
from:Path 
to:Path 

Field Summary

Modifier and TypeField and Description
private final Path
basepath

Record Component accessed by basepath().

private final Path
from

Record Component accessed by from().

private final Path
to

Record Component accessed by to().

Constructor Summary

AccessConstructor and Description
pack-priv
CopySpec(Path basepath, Path from, Path to)

pack-priv
CopySpec(Path from, Path to)

Method Summary

Modifier and TypeMethod and Description
public Path
basepath()

Record Component getter of basepath.

public boolean
equals(Object obj)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public Path
from()

Record Component getter of from.

pack-priv Path
public int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public Path
to()

Record Component getter of to.

pack-priv Path
public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

basepathback to summary
private final Path basepath

Record Component accessed by basepath().

fromback to summary
private final Path from

Record Component accessed by from().

toback to summary
private final Path to

Record Component accessed by to().

Constructor Detail

CopySpecback to summary
pack-priv CopySpec(Path basepath, Path from, Path to)
CopySpecback to summary
pack-priv CopySpec(Path from, Path to)

Method Detail

basepathback to summary
public Path basepath()

Record Component getter of basepath.

equalsback to summary
public boolean equals(Object obj)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
Annotations
@Override
fromback to summary
public Path from()

Record Component getter of from.

fromNormalizedback to summary
pack-priv Path fromNormalized()
hashCodeback to summary
public int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

Annotations
@Override
toback to summary
public Path to()

Record Component getter of to.

toNormalizedback to summary
pack-priv Path toNormalized()
toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

jdk.jpackage.internal.util back to summary

public Interface PathGroup.TransformHandler

Known Direct Implementers
jdk.jpackage.internal.util.PathGroup.Copy

Handler of file copying and directory creating.
See Also
transform

Method Summary

Modifier and TypeMethod and Description
public default void
copyFile(Path
the source file location
src
,
Path
the destination file location
dst
)

Request to copy a file from the given source location into the given destination location.

public default void
createDirectory(Path
the path where the directory is requested to be created
dir
)

Request to create a directory at the given location.

Method Detail

copyFileback to summary
public default void copyFile(Path src, Path dst) throws IOException

Request to copy a file from the given source location into the given destination location.

Implementation Note

Default implementation takes no action

Parameters
src:Path

the source file location

dst:Path

the destination file location

Exceptions
IOException:
If an I/O error occurs
createDirectoryback to summary
public default void createDirectory(Path dir) throws IOException

Request to create a directory at the given location.

Implementation Note

Default implementation takes no action

Parameters
dir:Path

the path where the directory is requested to be created