public class SSRFProperties extends Properties
This simple utility class enables the selective (or global) application of metadata configurations to SSRF components.
SSRF Properties extends Properties
and represents a persistent set of
properties. Each key and its corresponding value in the property list is a
string.
SSRF Properties can be saved to a File/Stream or loaded from a File/Stream.
defaults
Constructor and Description |
---|
SSRFProperties() |
Modifier and Type | Method and Description |
---|---|
boolean |
containsClass(Class<?> clazz)
Determine if the properties contains the indicated class.
|
static SSRFProperties |
getDefault()
Get an instance of the default SSRF properties configuration.
|
String |
getProperty(Class<?> clazz,
Field field)
Searches for the property with the specified key in this property list.
|
String |
getProperty(String classPath,
String fieldName)
Searches for the property with the specified key in this property list.
|
String |
getProperty(String classPath,
String fieldName,
String defaultValue)
Searches for the property with the specified key in this property list.
|
void |
load(File inFile)
Read a property list (key and element pairs) from the input propertie file.
|
void |
loadFromXML(File inFile)
Loads all of the properties represented by the XML document on the
specified input file into this properties table.
|
void |
store(File outFile)
Writes the property list (key and element pairs) in this Properties table
to the output file in a format suitable for loading into a Properties table
using the
load(File) method. |
void |
storeToXML(File outFile)
Writes the property list (key and element pairs) in this Properties table
to the output file in a format suitable for loading into a Properties table
using the
loadFromXML(java.io.File) method. |
getProperty, list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keys, keySet, merge, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, size, toString, values
public static SSRFProperties getDefault()
The default SSRF profile is a global classification Unclassified configuration cls=U ("Unclassified") suitable for general (public) distribution.
The returned SSRFProperties instance may be freely edited and updated before assigning it to a SSRF configuration. Typically at minimum the "TSerial.organisation" property is set to a four-character organization code.
public boolean containsClass(Class<?> clazz)
This method scans the properties KEYs looking for any entry with the indicated class value.
clazz
- the class type to look forpublic String getProperty(Class<?> clazz, Field field)
If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns null if the property is not found.
clazz
- the containing class under inspectionfield
- the class field under inspectionpublic String getProperty(String classPath, String fieldName)
Searches for the property with the specified key in this property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns null if the property is not found.
getProperty
in class Properties
classPath
- the containing class namefieldName
- the field namepublic String getProperty(String classPath, String fieldName, String defaultValue)
If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns the default value argument if the property is not found.
classPath
- the containing class namefieldName
- the field namedefaultValue
- a default valuepublic void load(File inFile) throws IOException
The input file is in a simple line-oriented format and is assumed to use the ISO 8859-1 character encoding; that is each byte is one Latin1 character. Characters not in Latin1, and certain special characters, are represented in keys and elements using Unicode escapes as defined in section 3.3 of The Java™ Language Specification.
inFile
- a properties fileIOException
- if the file cannot be read, is malformed or does not
existpublic void loadFromXML(File inFile) throws IOException, InvalidPropertiesFormatException
The XML document must have the following DOCTYPE declaration: <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
Furthermore, the document must satisfy the properties DTD described above.
inFile
- a properties fileIOException
InvalidPropertiesFormatException
public void store(File outFile) throws IOException
load(File)
method.
This method outputs the comments, properties keys and values in the same format as specified in store(Writer), with the following differences:
The stream is written using the ISO 8859-1 character encoding.
Characters not in Latin-1 in the comments are written as \\uxxxx for their appropriate unicode hexadecimal value xxxx.
Characters less than and characters greater than ~ in property keys or values are written as \\uxxxx for the appropriate hexadecimal value xxxx.
outFile
- the output fileIOException
- if the output file cannot be writtenpublic void storeToXML(File outFile) throws IOException
loadFromXML(java.io.File)
method.
The XML document will have the following DOCTYPE declaration: <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
If the specified comment is null then no comment will be stored in the document.
outFile
- the output fileIOException
- if the output file cannot be writtenCopyright © 2016 OpenSSRF.org. All rights reserved.