\r\n

51Degrees Device Detection Java  4.3Newer Version 4.4

Device detection services for 51Degrees Pipeline
  • fiftyone
  • devicedetection
  • shared
  • testhelpers
  • FileUtils

fiftyone.devicedetection.shared.testhelpers.FileUtils Class Reference

Static Public Member Functions

static String  getHashFileName ()
Helper to find the location of an Enterprise or Lite Hash file in the default search scope. More...
static File  getHashFile ()
Helper to find the location of an Enterprise or Lite Hash file in the default search scope. More...
static File  getEvidenceFile ()
static File  getFilePath (String file, String searchRoot)
Search for a resource (file) in a context {searchRoot}. More...
static File  getFilePath (String file)
Search (the project directory) for a resource. More...
static File  jarFileHelper (String file)
Search the classpath for a resource. More...

Static Public Attributes

static final String  ENTERPRISE_HASH_DATA_FILE_NAME = "Enterprise-HashV41.hash"
static final String  LITE_HASH_DATA_FILE_NAME = "51Degrees-LiteV4.1.hash"
static final String  UA_FILE_NAME = "20000 User Agents.csv"
static final String  EVIDENCE_FILE_NAME = "20000 Evidence Records.yml"
static int  DEPTH_TO_SEARCH = 30
MAX depth to iterate when searching for files below specified root.
static String  TEMP_FILE_PREFIX = "DDTempFile"
Prefix for temp files that are created by jarFileHelper(String).

Member Function Documentation

◆ getFilePath() [1/2]

static File fiftyone.devicedetection.shared.testhelpers.FileUtils.getFilePath ( String   file,
String   searchRoot  
)
static

Search for a resource (file) in a context {searchRoot}.

The file sought must end in the supplied string, where the components of the string must wholly match the components of the location it is found in - per Path#endsWith

When using this feature be aware that the first match is returned, not the closest in scope, so try to use unique filenames.

Parameters
file - the qualified name of the resource to find
searchRoot - which part of the directory structure to search
Returns
a File representing the resource
Exceptions
IllegalArgumentException - if the resource can't be found

◆ getFilePath() [2/2]

static File fiftyone.devicedetection.shared.testhelpers.FileUtils.getFilePath ( String   file )
static

Search (the project directory) for a resource.

If it doesn't exist throw an exception.

If the system property project.root has been set, probably in the maven surefire plugin config, then this is set as the scope of the search, otherwise the scope is system property user.dir (the directory Java was launched from).

Parameters
file - the qualified name of the resource to find
Returns
a File representing the resource
See also
getFilePath(String, String)

◆ getHashFile()

static File fiftyone.devicedetection.shared.testhelpers.FileUtils.getHashFile ( )
static

Helper to find the location of an Enterprise or Lite Hash file in the default search scope.

Returns
a file or empty if not found

◆ getHashFileName()

static String fiftyone.devicedetection.shared.testhelpers.FileUtils.getHashFileName ( )
static

Helper to find the location of an Enterprise or Lite Hash file in the default search scope.

Returns
a file or null if not found

◆ jarFileHelper()

static File fiftyone.devicedetection.shared.testhelpers.FileUtils.jarFileHelper ( String   file )
static

Search the classpath for a resource.

If it doesn't exist throw an exception. If the file is in a jar then copy it to a temp file, so it can be used as an actual file.

Callers might wish to delete the temp file created when one is created and can assess whether this is the case as the name of the filename created will start with TEMP_FILE_PREFIX which they can alter to suit their needs.

Files created here have the property deleteOnExit;

Parameters
file - a filename
Returns
a File representing the resource