R.filesets (version 2.15.1)

FullNameInterface: The FullNameInterface class interface

Description

Package: R.filesets
Class FullNameInterface

Interface
~~|
~~+--FullNameInterface

Directly known subclasses:
ChecksumFile, ChecksumFileSet, GenericDataFile, GenericDataFileSet, GenericDataFileSetList, GenericTabularFile, GenericTabularFileSet, RDataFile, RDataFileSet, RdsFile, RdsFileSet, TabularTextFile, TabularTextFileSet

public abstract class FullNameInterface
extends Interface

Usage

FullNameInterface(...)

Arguments

...

Not used.

Fields and Methods

Methods:

appendFullNameTranslator-
clearFullNameTranslator-
getFullNameGets the full name.
getNameGets the name.
getTagsGets the tags.
hasTag-
hasTagsChecks whether the fullname contains a given set of tag(s).
setFullNameSets the full name.
setFullNameTranslator-
setNameSets the name part of the fullname.
setTagsSets the tags.

Methods inherited from Interface:
extend, print, uses

Author

Henrik Bengtsson

Details

The full name consists of a name followed by optional comma-separated tags. For instance, the full name of foo,a.2,b has name foo with tags a.2 and b.

Examples

Run this code
# Setup a file set
path <- system.file("R", package="R.filesets")
ds <- GenericDataFileSet$byPath(path)

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Data set
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cat("Path of data set:\n")
print(getPath(ds))

cat("Fullname of data set:\n")
print(getFullName(ds))


# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Data files
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cat("Pathnames:\n")
print(getPathnames(ds))

cat("Filenames:\n")
print(sapply(ds, getFilename))

cat("Default fullnames:\n")
print(getFullNames(ds))

cat("Extensions:\n")
print(sapply(ds, getExtension))


# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Translation of data file names
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Translate fullnames to lower case
setFullNamesTranslator(ds, function(names, ...) tolower(names))
cat("Lower-case fullnames:\n")
print(getFullNames(ds))

# Append a translator that reverse the order of the letters
revStr <- function(names, ...) {
  names <- strsplit(names, split="", fixed=TRUE)
  names <- lapply(names, FUN=rev)
  names <- sapply(names, FUN=paste, collapse="")
  names
}
appendFullNamesTranslator(ds, revStr)
cat("Reversed lower-case fullnames:\n")
fn3 <- getFullNames(ds)
print(fn3)


# Alternative for setting up a sequence of translators
setFullNamesTranslator(ds, list(function(names, ...) tolower(names), revStr))
cat("Reversed lower-case fullnames:\n")
fn3b <- getFullNames(ds)
print(fn3b)
stopifnot(identical(fn3b, fn3))

# Reset
clearFullNamesTranslator(ds)
cat("Default fullnames (after resetting):\n")
print(getFullNames(ds))

Run the code above in your browser using DataLab