Top Description Inners Fields Constructors Methods
org.graalvm.polyglot.io

public final Class IOAccess

extends Object
Class Inheritance
Imports
java.util.Objects, org.graalvm.polyglot.Context

Represents an IO access configuration of a polyglot context. The IO access configuration determines how a guest language can access the host IO. The access to host IO can be disabled, enabled, or virtualized using a custom file system.
Since
23.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
IOAccess.Builder

Builder to create a custom IO access configuration.

Field Summary

Modifier and TypeField and Description
public static final IOAccess
ALL

Provides guest language full access to host IO.

private final boolean
private final boolean
private final FileSystem
private final String
public static final IOAccess
NONE

Provides guest language no access to IO.

Constructor Summary

AccessConstructor and Description
pack-priv
IOAccess(String name, boolean allowHostFileAccess, boolean allowHostSocketAccess, FileSystem fileSystem)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

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

pack-priv FileSystem
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.

pack-priv boolean
pack-priv boolean
public static IOAccess.Builder
newBuilder()

Creates a new builder that allows to create a custom IO access configuration.

public static IOAccess.Builder
newBuilder(IOAccess prototype)

Creates a new builder that allows to create a custom IO access configuration based of a preset configuration.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

ALLback to summary
public static final IOAccess ALL

Provides guest language full access to host IO. Guest language have full access to host file system and host sockets. The ALL is a default value for Contexts created with all access set to true. If you are using this preset, the newly added privileges will default to true for this preset.

Equivalent of using the following builder configuration:


IOAccess.newBuilder()
          .allowHostFileAccess(true)
          .allowHostSocketAccess(true)
          .build();

Since
23.0
allowHostFileAccessback to summary
private final boolean allowHostFileAccess
allowHostSocketAccessback to summary
private final boolean allowHostSocketAccess
fileSystemback to summary
private final FileSystem fileSystem
nameback to summary
private final String name
NONEback to summary
public static final IOAccess NONE

Provides guest language no access to IO. Guest language only has read-only access to the language's home files. The NONE is a default value for Contexts created without all access. If you are using this preset, the newly added privileges will default to false for this preset.

Equivalent of using the following builder configuration:


IOAccess.newBuilder().build();

Since
23.0

Constructor Detail

IOAccessback to summary
pack-priv IOAccess(String name, boolean allowHostFileAccess, boolean allowHostSocketAccess, FileSystem fileSystem)

Method Detail

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.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
Since
23.0
getFileSystemback to summary
pack-priv FileSystem getFileSystem()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the 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.
Returns:int

a hash code value for this object

Annotations
@Override
Since
23.0
hasHostFileAccessback to summary
pack-priv boolean hasHostFileAccess()
hasHostSocketAccessback to summary
pack-priv boolean hasHostSocketAccess()
newBuilderback to summary
public static IOAccess.Builder newBuilder()

Creates a new builder that allows to create a custom IO access configuration. The builder configuration needs to be completed using the method.

Since
23.0
newBuilderback to summary
public static IOAccess.Builder newBuilder(IOAccess prototype)

Creates a new builder that allows to create a custom IO access configuration based of a preset configuration. The preset configuration is copied and used as a template for the returned builder. The builder configuration needs to be completed using the method.

Since
23.0
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
Since
23.0
org.graalvm.polyglot.io back to summary

public final Class IOAccess.Builder

extends Object
Class Inheritance

Builder to create a custom IO access configuration.
Since
23.0

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private FileSystem
private String

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
Builder(IOAccess prototype)

Method Summary

Modifier and TypeMethod and Description
public IOAccess.Builder
allowHostFileAccess(boolean allow)

If true, it allows the guest language unrestricted access to files on the host system.

public IOAccess.Builder
allowHostSocketAccess(boolean allow)

If true, it allows the guest language unrestricted access to host system sockets.

public IOAccess
build()

Creates an instance of the custom IO access configuration.

public IOAccess.Builder

Returns:

the Builder
fileSystem
(FileSystem
the file system to use in the guest language
fileSystem
)

Sets a new FileSystem.

pack-priv IOAccess.Builder
name(String givenName)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allowHostFileAccessback to summary
private boolean allowHostFileAccess
allowHostSocketAccessback to summary
private boolean allowHostSocketAccess
customFileSystemback to summary
private FileSystem customFileSystem
nameback to summary
private String name

Constructor Detail

Builderback to summary
pack-priv Builder()
Builderback to summary
pack-priv Builder(IOAccess prototype)

Method Detail

allowHostFileAccessback to summary
public IOAccess.Builder allowHostFileAccess(boolean allow)

If true, it allows the guest language unrestricted access to files on the host system.

Since
23.0
allowHostSocketAccessback to summary
public IOAccess.Builder allowHostSocketAccess(boolean allow)

If true, it allows the guest language unrestricted access to host system sockets.

Since
23.0
buildback to summary
public IOAccess build()

Creates an instance of the custom IO access configuration.

Exceptions
IllegalArgumentException:
if host file access is enabled and a custom file system is set.
Since
23.0
fileSystemback to summary
public IOAccess.Builder fileSystem(FileSystem fileSystem)

Sets a new FileSystem. Access to the file system in the guest language will be virtualized using the fileSystem. A file system can restrict access to files or fully virtualize file system operations. An example of virtualization is a memory-based file system.

Parameters
fileSystem:FileSystem

the file system to use in the guest language

Returns:IOAccess.Builder

the Builder

Since
23.0
nameback to summary
pack-priv IOAccess.Builder name(String givenName)