Top Description Fields Constructors Methods
org.apache.commons.text.lookup

pack-priv final Class JavaPlatformStringLookup

extends AbstractStringLookup
Class Inheritance
Imports
java.util.Locale, org.apache.commons.lang3.StringUtils, org.apache.commons.text.StringSubstitutor

Looks up keys related to Java: Java version, JRE version, VM version, and so on.

The lookup keys with examples are:

Using a StringLookup from the StringLookupFactory:

StringLookupFactory.INSTANCE.javaPlatformStringLookup().lookup("version");

Using a StringSubstitutor:

StringSubstitutor.createInterpolator().replace("... ${java:version} ..."));

The above examples convert "version" to the current VM version, for example, "Java version 1.8.0_181".

Public access is through StringLookupFactory.

Since
1.3
See Also
StringLookupFactory

Field Summary

Modifier and TypeField and Description
pack-priv static final JavaPlatformStringLookup
INSTANCE

Defines the singleton for this class.

private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
Inherited from org.apache.commons.text.lookup.AbstractStringLookup:
SPLIT_CHSPLIT_STR

Constructor Summary

AccessConstructor and Description
private
JavaPlatformStringLookup()

No need to build instances for now.

Method Summary

Modifier and TypeMethod and Description
pack-priv String

Returns:

hardware processor information.
getHardware
()

Accessible through the Lookup key hardware.

pack-priv String

Returns:

system locale and file encoding information.
getLocale
()

Accessible through the Lookup key locale.

pack-priv String

Returns:

operating system information.
getOperatingSystem
()

Accessible through the Lookup key os.

pack-priv String

Returns:

Java Runtime Environment information.
getRuntime
()

Accessible through the Lookup key runtime.

private String

Returns:

a system property value.
getSystemProperty
(final String
a system property name.
name
)

Gets the given system property.

private String

Returns:

The prefix + a system property value.
getSystemProperty
(final String
the prefix to use for the result string.
prefix
,
final String
a system property name.
name
)

Gets the given system property.

pack-priv String

Returns:

Java Virtual Machine information.
getVirtualMachine
()

Accessible through the Lookup key vm.

public String

Returns:

The value of the environment variable.
lookup
(final String
the key to be looked up, may be null.
key
)

Implements org.apache.commons.text.lookup.StringLookup.lookup.

Looks up the value of the Java platform key.

public static void
main(final String[]
the standard Java main method parameter which is unused for our running of this class.
args
)

The main method for running the JavaPlatformStringLookup.

Inherited from org.apache.commons.text.lookup.AbstractStringLookup:
substringAftersubstringAftersubstringAfterLasttoLookupKeytoLookupKey

Field Detail

INSTANCEback to summary
pack-priv static final JavaPlatformStringLookup INSTANCE

Defines the singleton for this class.

KEY_HARDWAREback to summary
private static final String KEY_HARDWARE

hardware key for driving JavaPlatformStringLookup#lookup(String).

KEY_LOCALEback to summary
private static final String KEY_LOCALE

locale key for driving JavaPlatformStringLookup#lookup(String).

KEY_OSback to summary
private static final String KEY_OS

os key for driving JavaPlatformStringLookup#lookup(String).

KEY_RUNTIMEback to summary
private static final String KEY_RUNTIME

runtime key for driving JavaPlatformStringLookup#lookup(String).

KEY_VERSIONback to summary
private static final String KEY_VERSION

version key for driving JavaPlatformStringLookup#lookup(String).

KEY_VMback to summary
private static final String KEY_VM

vm key for driving JavaPlatformStringLookup#lookup(String).

Constructor Detail

JavaPlatformStringLookupback to summary
private JavaPlatformStringLookup()

No need to build instances for now.

Method Detail

getHardwareback to summary
pack-priv String getHardware()

Accessible through the Lookup key hardware.

Returns:String

hardware processor information.

getLocaleback to summary
pack-priv String getLocale()

Accessible through the Lookup key locale.

Returns:String

system locale and file encoding information.

getOperatingSystemback to summary
pack-priv String getOperatingSystem()

Accessible through the Lookup key os.

Returns:String

operating system information.

getRuntimeback to summary
pack-priv String getRuntime()

Accessible through the Lookup key runtime.

Returns:String

Java Runtime Environment information.

getSystemPropertyback to summary
private String getSystemProperty(final String name)

Gets the given system property.

Parameters
name:String

a system property name.

Returns:String

a system property value.

getSystemPropertyback to summary
private String getSystemProperty(final String prefix, final String name)

Gets the given system property.

Parameters
prefix:String

the prefix to use for the result string.

name:String

a system property name.

Returns:String

The prefix + a system property value.

getVirtualMachineback to summary
pack-priv String getVirtualMachine()

Accessible through the Lookup key vm.

Returns:String

Java Virtual Machine information.

lookupback to summary
public String lookup(final String key)

Implements org.apache.commons.text.lookup.StringLookup.lookup.

Looks up the value of the Java platform key.

The lookup keys with examples are:

  • version: "Java version 1.8.0_181"
  • runtime: "Java(TM) SE Runtime Environment (build 1.8.0_181-b13) from Oracle Corporation"
  • vm: "Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)"
  • os: "Windows 10 10.0, architecture: amd64-64"
  • hardware: "processors: 4, architecture: amd64-64, instruction sets: amd64"
  • locale: "default locale: en_US, platform encoding: iso-8859-1"
Parameters
key:String

the key to be looked up, may be null.

Returns:String

The value of the environment variable.

Annotations
@Override
mainback to summary
public static void main(final String[] args)

The main method for running the JavaPlatformStringLookup.

Parameters
args:String[]

the standard Java main method parameter which is unused for our running of this class.