Package dev.nm.misc.license
Class License
- java.lang.Object
-
- dev.nm.misc.license.License
-
public final class License extends Object
This is the license management system for the library. To use this library in the client program, you need a valid license. Before any API calls to this library, the client program needs to specify the license by either:- putting the license file with file term specified by
DEFAULT_LICENSE_FILESunder the same directory as the nmdev library jar file, runtime working directory, or classpath; or - calling
setLicenseFile(java.io.File)to specify the license file; or - calling
setLicenseKey(java.lang.String)to set the license key.
setLicenseFile(java.io.File). Another way to set the license programmatically is to callsetLicenseKey(java.lang.String)with the key string. Once you got a valid license, you can copy the license key in the license file. UsingsetLicenseKey(java.lang.String), the file I/O for loading license file can be avoided.- See Also:
- License Agreement
- putting the license file with file term specified by
-
-
Field Summary
Fields Modifier and Type Field Description static StringDATE_FORMAT_STRINGDate format for all kinds of dates in a license file.static String[]DEFAULT_LICENSE_FILESDefault license file names.static StringLICENSE_FILE_PROPERTYThe system property term for setting license file.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgetLicenseKey()Gets the license key string of the current license.static StringgetLicenseLocation()Gets the location of the current loaded license.static StringgetValue(String name)static StringgetVersion()Gets the version number.static voidsetLicenseFile(File licenseFile)Overrides the default license file.static voidsetLicenseKey(String key)Sets the license key for this invocation.
-
-
-
Field Detail
-
LICENSE_FILE_PROPERTY
public static final String LICENSE_FILE_PROPERTY
The system property term for setting license file. BesidessetLicenseFile(java.io.File), license file can be specified by system property using -D option in 'java' command.- See Also:
- Constant Field Values
-
DEFAULT_LICENSE_FILES
public static final String[] DEFAULT_LICENSE_FILES
Default license file names.
-
DATE_FORMAT_STRING
public static final String DATE_FORMAT_STRING
Date format for all kinds of dates in a license file.- See Also:
- Constant Field Values
-
-
Method Detail
-
setLicenseFile
public static void setLicenseFile(File licenseFile)
Overrides the default license file. This has to be called before the default license is loaded. A license file can only be set once. All subsequent calls will lead toRuntimeException.- Parameters:
licenseFile- the license file
-
setLicenseKey
public static void setLicenseKey(String key)
Sets the license key for this invocation. A license file can only be set once. All subsequent calls will lead toRuntimeException.- Parameters:
key- the license key
-
getVersion
public static String getVersion()
Gets the version number. The version number is in the format:<major version>.<minor version>.<bugfix version>
- Returns:
- the version number
-
getLicenseKey
public static String getLicenseKey()
Gets the license key string of the current license. The returned string can be passed intosetLicenseKey(java.lang.String)for setting up license programmatically without file I/O.- Returns:
- the license key string
-
getLicenseLocation
public static String getLicenseLocation()
Gets the location of the current loaded license.- Returns:
- the license location
-
-