Documents the features of the 'r6-generator-maven-plugin' by providing an example of an R package automatically generated from Java code by the plugin. It is not intended to be useful beyond testing, demonstrating and documenting the features of the r6 generator plugin.

Version: 1.1.0

Generated: 2024-05-16T16:22:15.382427434

Usage


 J = testRapi::JavaApi$get(logLevel)
   

Arguments

logLevel

optional - the slf4j log level as a string - one of OFF (most specific, no logging), FATAL (most specific, little data), ERROR, WARN, INFO, DEBUG, TRACE (least specific, a lot of data), ALL (least specific, all data)

Package initialisation and control

Package method JavaApi$installDependencies()

This package level method checks for, and installs any dependencies needed for the running of the package. It is called automatically on first package load and so in general does not need to be used directly.

Usage


testRapi::JavaApi$installDependencies()
      

Arguments

  • none

Returns

nothing. called for side effects.


Package method JavaApi$rebuildDependencies()

This package level method removes existing dependencies and re-installs dependencies needed for the running of the package. It is called automatically on first package load and so in general does not need to be called.

Usage


testRapi::JavaApi$rebuildDependencies()
      

Arguments

  • none

Returns

nothing. called for side effects.


Package method JavaApi$versionInformation()

This package level method returns debugging version information for the package

Usage


testRapi::JavaApi$versionInformation()
      

Arguments

  • none

Returns

A list containing a set of versioning information about this package.


Package method JavaApi$get()

This is the main entry point for the package and the root of the Java API in this package. All classes defined in the package are made available as items under this root. The JavaApi object manages the communication between R and Java.

Usage


J = testRapi::JavaApi$get()
# package classes and functions are nested under the `J` api object.
      

Arguments

logLevel

The desired verbosity of the package. One of "OFF", "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE", "ALL".

Returns

A R6 testRapi::JavaApi object containing the access point to the objects and functions defined in this package


Api method J$changeLogLevel(logLevel)

Once the package is initialised the log level can be changed to increase the level of messages from the api.

Usage


J = testRapi::JavaApi$get()
J$changeLogLevel("DEBUG")
      

Arguments

logLevel

The desired verbosity of the package. One of "OFF", "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE", "ALL".

Returns

nothing. used for side effects.


Api method J$reconfigureLog(log4jproperties)

Experimental / Advanced use: Once the package is initialised the log configureation can be changed to log to an external file for example.

Usage


J = testRapi::JavaApi$get()
prp = fs::path(getwd(),"log4j.properties")
if (fs::file_exists(prp)) {
  J$changeLogLevel(prp)
}
      

Arguments

log4jproperties

a full path to a log4jproperies file

Returns

nothing. used for side effects.


Api method J$printMessages()

Experimental / Internal use: Messages from Java to R are queued and printed after each function call. It is unlikely that any will be not printed so in normal circumstances this function should do nothing.

Usage


J = testRapi::JavaApi$get()
J$printMessages()
      

Arguments

  • none

Returns

nothing. used for side effects.

Static methods and constructors


Method MinimalExample$new()

the default no-args constructor

Usage


J = testRapi::JavaApi$get()
J$MinimalExample$new()
        

Arguments

  • none

Returns

R6 MinimalExample object:


Method BounceTest$new()

the default no-args constructor

Usage


J = testRapi::JavaApi$get()
J$BounceTest$new()
        

Arguments

  • none

Returns

R6 BounceTest object:


Method FeatureTest$new()

A maximum of one constructor of any signature can be used.

If different constructors are needed then they may be used but not included in the R Api (i.e. not annotated with @RMethod.)

Static factory methods can be used instead.

Usage


J = testRapi::JavaApi$get()
J$FeatureTest$new(logMessage)
        

Arguments

logMessage - a message which will be logged

- (java expects a String)

Returns

R6 FeatureTest object:

Examples


minExample = J$FeatureTest$new('Hello from Java constructor!')
      


Method FeatureTest$demoStatic()

Static methods are also supported.

These are accessed through the root of the R api, and as a functional interface

Usage


J = testRapi::JavaApi$get()
J$FeatureTest$demoStatic(message)
# this method is also exposed as a package function:
testRapi::demo_static(message)
        

Arguments

message a message

- (java expects a String)

Returns

void:

Examples


J = JavaApi$get()
J$FeatureTest$demoStatic('Ola, el mundo')
demo_static('Bonjour, le monde')
      


Method FeatureTest$diamonds()

The ggplot2::diamonds dataframe

A copy serialised into java, using RObject.writeRDS, saved within the jar file of the package, and exposed here using RObject.readRDS.

Usage


J = testRapi::JavaApi$get()
J$FeatureTest$diamonds()
# this method is also exposed as a package function:
testRapi::diamonds()
        

Arguments

  • none

Returns

RDataframe: the ggplot2::diamonds dataframe

Examples


dplyr::glimpse( diamonds() )
      


Method FeatureTest$collider()

no title

Usage


J = testRapi::JavaApi$get()
J$FeatureTest$collider(message1, message2)
# this method is also exposed as a package function:
testRapi::collider.feature_test(message1, message2)
        

Arguments

message1

- (java expects a RCharacter)

message2

- (java expects a RCharacter)

Returns

RCharacter:


Method FeatureTest$asyncStaticCountdown()

no title

Usage


J = testRapi::JavaApi$get()
J$FeatureTest$asyncStaticCountdown(label, rtimer)
# this method is also exposed as a package function:
testRapi::async_static_countdown(label, rtimer)
        

Arguments

label

- (java expects a RCharacter)

rtimer

- (java expects a RInteger)

Returns

An `RFuture` with methods `cancel()`, `isCancelled()`, `isDone()` and `get()`. The result of a `get()` call will be an RCharacter:


Method FeatureTest$asyncFactory()

no title

Usage


J = testRapi::JavaApi$get()
J$FeatureTest$asyncFactory()
# this method is also exposed as a package function:
testRapi::async_factory()
        

Arguments

  • none

Returns

An `RFuture` with methods `cancel()`, `isCancelled()`, `isDone()` and `get()`. The result of a `get()` call will be an R6 FactoryTest object:


Method MoreFeatureTest$new()

the first constructor is used if there are none annotated

Usage


J = testRapi::JavaApi$get()
J$MoreFeatureTest$new(message1, message2)
        

Arguments

message1 - the message to be printed

- (java expects a RCharacter)

message2 - will be used for toString

- (java expects a RCharacter)

Returns

R6 MoreFeatureTest object:


Method MoreFeatureTest$create()

A static object constructor

Usage


J = testRapi::JavaApi$get()
J$MoreFeatureTest$create(message1, message2)
# this method is also exposed as a package function:
testRapi::create(message1, message2)
        

Arguments

message1 - the message to be printed

- (java expects a RCharacter)

message2 - will be used for toString

- (java expects a RCharacter)

Returns

R6 MoreFeatureTest object: A MoreFeatureTest R6 object

Examples


J = JavaApi$get()
J$MoreFeatureTest$create('Hello,',' World')
      


Method MoreFeatureTest$concat()

no title

Usage


J = testRapi::JavaApi$get()
J$MoreFeatureTest$concat(message1, message2)
# this method is also exposed as a package function:
testRapi::concat(message1, message2)
        

Arguments

message1

- (java expects a RCharacter)

message2

- (java expects a RCharacter)

Returns

RCharacter:


Method MoreFeatureTest$collider()

no title

Usage


J = testRapi::JavaApi$get()
J$MoreFeatureTest$collider(message1, message2)
# this method is also exposed as a package function:
testRapi::collider.more_feature_test(message1, message2)
        

Arguments

message1

- (java expects a RCharacter)

message2

- (java expects a RCharacter)

Returns

RCharacter:

Examples


library(testthat)
tmp = collider.more_feature_test('should ','work')
expect_equal(tmp,'more feature test: should work')
      


Method FactoryTest$new()

the default no-args constructor

Usage


J = testRapi::JavaApi$get()
J$FactoryTest$new()
        

Arguments

  • none

Returns

R6 FactoryTest object:


Method Serialiser$new()

the default no-args constructor

Usage


J = testRapi::JavaApi$get()
J$Serialiser$new()
        

Arguments

  • none

Returns

R6 Serialiser object:


Method Serialiser$serialiseDataframe()

no title

Usage


J = testRapi::JavaApi$get()
J$Serialiser$serialiseDataframe(dataframe, filename)
# this method is also exposed as a package function:
testRapi::serialise_dataframe(dataframe, filename)
        

Arguments

dataframe

- (java expects a RDataframe)

filename

- (java expects a String)

Returns

void:


Method Serialiser$deserialiseDataframe()

no title

Usage


J = testRapi::JavaApi$get()
J$Serialiser$deserialiseDataframe(filename)
# this method is also exposed as a package function:
testRapi::deserialise_dataframe(filename)
        

Arguments

filename

- (java expects a String)

Returns

RDataframe:


Method Serialiser$serialiseList()

no title

Usage


J = testRapi::JavaApi$get()
J$Serialiser$serialiseList(dataframe, filename)
# this method is also exposed as a package function:
testRapi::serialise_list(dataframe, filename)
        

Arguments

dataframe

- (java expects a RList)

filename

- (java expects a String)

Returns

void:


Method Serialiser$deserialiseList()

no title

Usage


J = testRapi::JavaApi$get()
J$Serialiser$deserialiseList(filename)
# this method is also exposed as a package function:
testRapi::deserialise_list(filename)
        

Arguments

filename

- (java expects a String)

Returns

RList:


Method Serialiser$serialiseNamedList()

no title

Usage


J = testRapi::JavaApi$get()
J$Serialiser$serialiseNamedList(dataframe, filename)
# this method is also exposed as a package function:
testRapi::serialise_named_list(dataframe, filename)
        

Arguments

dataframe

- (java expects a RNamedList)

filename

- (java expects a String)

Returns

void:


Method Serialiser$deserialiseNamedList()

no title

Usage


J = testRapi::JavaApi$get()
J$Serialiser$deserialiseNamedList(filename)
# this method is also exposed as a package function:
testRapi::deserialise_named_list(filename)
        

Arguments

filename

- (java expects a String)

Returns

RNamedList:

Examples

## -----------------------------------
## Check library dependencies for testRapi
## -----------------------------------
testRapi::JavaApi$installDependencies()

## -----------------------------------
## Construct a testRapi Java API instance
## -----------------------------------

J = testRapi::JavaApi$get()
# or a more verbose configuration
# J = testRapi::JavaApi$get("DEBUG")


## -----------------------------------
## Method `J$MinimalExample$new(...)`
## -----------------------------------
if (FALSE) {
# no example given - appropriate parameter values must be provided:
J$MinimalExample$new()
# or alternatively:
testRapi::new()
}

## -----------------------------------
## Method `J$BounceTest$new(...)`
## -----------------------------------
if (FALSE) {
# no example given - appropriate parameter values must be provided:
J$BounceTest$new()
# or alternatively:
testRapi::new()
}

## -----------------------------------
## Method `J$FeatureTest$new(...)`
## -----------------------------------
minExample = J$FeatureTest$new('Hello from Java constructor!')
#> Hello from Java constructor!

## -----------------------------------
## Method `J$FeatureTest$demoStatic(...)`
## Aliased as `testRapi::demo_static(...)`
## -----------------------------------
J = JavaApi$get()
J$FeatureTest$demoStatic('Ola, el mundo')
#> Ola, el mundo
demo_static('Bonjour, le monde')
#> Bonjour, le monde

## -----------------------------------
## Method `J$FeatureTest$diamonds(...)`
## Aliased as `testRapi::diamonds(...)`
## -----------------------------------
dplyr::glimpse( diamonds() )
#> Rows: 53,940
#> Columns: 10
#> $ carat   <dbl> 0.23, 0.21, 0.23, 0.29, 0.31, 0.24, 0.24, 0.26, 0.22, 0.23, 0.…
#> $ cut     <ord> Ideal, Premium, Good, Premium, Good, Very Good, Very Good, Ver…
#> $ color   <ord> E, E, E, I, J, J, I, H, E, H, J, J, F, J, E, E, I, J, J, J, I,…
#> $ clarity <ord> SI2, SI1, VS1, VS2, SI2, VVS2, VVS1, SI1, VS2, VS1, SI1, VS1, …
#> $ depth   <dbl> 61.5, 59.8, 56.9, 62.4, 63.3, 62.8, 62.3, 61.9, 65.1, 59.4, 64…
#> $ table   <dbl> 55, 61, 65, 58, 58, 57, 57, 55, 61, 61, 55, 56, 61, 54, 62, 58…
#> $ price   <int> 326, 326, 327, 334, 335, 336, 336, 337, 337, 338, 339, 340, 34…
#> $ x       <dbl> 3.95, 3.89, 4.05, 4.20, 4.34, 3.94, 3.95, 4.07, 3.87, 4.00, 4.…
#> $ y       <dbl> 3.98, 3.84, 4.07, 4.23, 4.35, 3.96, 3.98, 4.11, 3.78, 4.05, 4.…
#> $ z       <dbl> 2.43, 2.31, 2.31, 2.63, 2.75, 2.48, 2.47, 2.53, 2.49, 2.39, 2.…

## -----------------------------------
## Method `J$FeatureTest$collider(...)`
## Aliased as `testRapi::collider.feature_test(...)`
## -----------------------------------
if (FALSE) {
# no example given - appropriate parameter values must be provided:
J$FeatureTest$collider(message1, message2)
# or alternatively:
testRapi::collider.feature_test(message1, message2)
}

## -----------------------------------
## Method `J$FeatureTest$asyncStaticCountdown(...)`
## Aliased as `testRapi::async_static_countdown(...)`
## -----------------------------------
if (FALSE) {
# no example given - appropriate parameter values must be provided:
J$FeatureTest$asyncStaticCountdown(label, rtimer)
# or alternatively:
testRapi::async_static_countdown(label, rtimer)
}

## -----------------------------------
## Method `J$FeatureTest$asyncFactory(...)`
## Aliased as `testRapi::async_factory(...)`
## -----------------------------------
if (FALSE) {
# no example given - appropriate parameter values must be provided:
J$FeatureTest$asyncFactory()
# or alternatively:
testRapi::async_factory()
}

## -----------------------------------
## Method `J$MoreFeatureTest$new(...)`
## -----------------------------------
if (FALSE) {
# no example given - appropriate parameter values must be provided:
J$MoreFeatureTest$new(message1, message2)
# or alternatively:
testRapi::new(message1, message2)
}

## -----------------------------------
## Method `J$MoreFeatureTest$create(...)`
## Aliased as `testRapi::create(...)`
## -----------------------------------
J = JavaApi$get()
J$MoreFeatureTest$create('Hello,',' World')
#> constuctor: Hello,,  World
#> [1] "toString:  World"

## -----------------------------------
## Method `J$MoreFeatureTest$concat(...)`
## Aliased as `testRapi::concat(...)`
## -----------------------------------
if (FALSE) {
# no example given - appropriate parameter values must be provided:
J$MoreFeatureTest$concat(message1, message2)
# or alternatively:
testRapi::concat(message1, message2)
}

## -----------------------------------
## Method `J$MoreFeatureTest$collider(...)`
## Aliased as `testRapi::collider.more_feature_test(...)`
## -----------------------------------
library(testthat)
tmp = collider.more_feature_test('should ','work')
expect_equal(tmp,'more feature test: should work')

## -----------------------------------
## Method `J$FactoryTest$new(...)`
## -----------------------------------
if (FALSE) {
# no example given - appropriate parameter values must be provided:
J$FactoryTest$new()
# or alternatively:
testRapi::new()
}

## -----------------------------------
## Method `J$Serialiser$new(...)`
## -----------------------------------
if (FALSE) {
# no example given - appropriate parameter values must be provided:
J$Serialiser$new()
# or alternatively:
testRapi::new()
}

## -----------------------------------
## Method `J$Serialiser$serialiseDataframe(...)`
## Aliased as `testRapi::serialise_dataframe(...)`
## -----------------------------------
if (FALSE) {
# no example given - appropriate parameter values must be provided:
J$Serialiser$serialiseDataframe(dataframe, filename)
# or alternatively:
testRapi::serialise_dataframe(dataframe, filename)
}

## -----------------------------------
## Method `J$Serialiser$deserialiseDataframe(...)`
## Aliased as `testRapi::deserialise_dataframe(...)`
## -----------------------------------
if (FALSE) {
# no example given - appropriate parameter values must be provided:
J$Serialiser$deserialiseDataframe(filename)
# or alternatively:
testRapi::deserialise_dataframe(filename)
}

## -----------------------------------
## Method `J$Serialiser$serialiseList(...)`
## Aliased as `testRapi::serialise_list(...)`
## -----------------------------------
if (FALSE) {
# no example given - appropriate parameter values must be provided:
J$Serialiser$serialiseList(dataframe, filename)
# or alternatively:
testRapi::serialise_list(dataframe, filename)
}

## -----------------------------------
## Method `J$Serialiser$deserialiseList(...)`
## Aliased as `testRapi::deserialise_list(...)`
## -----------------------------------
if (FALSE) {
# no example given - appropriate parameter values must be provided:
J$Serialiser$deserialiseList(filename)
# or alternatively:
testRapi::deserialise_list(filename)
}

## -----------------------------------
## Method `J$Serialiser$serialiseNamedList(...)`
## Aliased as `testRapi::serialise_named_list(...)`
## -----------------------------------
if (FALSE) {
# no example given - appropriate parameter values must be provided:
J$Serialiser$serialiseNamedList(dataframe, filename)
# or alternatively:
testRapi::serialise_named_list(dataframe, filename)
}

## -----------------------------------
## Method `J$Serialiser$deserialiseNamedList(...)`
## Aliased as `testRapi::deserialise_named_list(...)`
## -----------------------------------
if (FALSE) {
# no example given - appropriate parameter values must be provided:
J$Serialiser$deserialiseNamedList(filename)
# or alternatively:
testRapi::deserialise_named_list(filename)
}