getFtpPortnumber()
);
The Java Config class comes with a number of supported data-types that can be used out-of-the-box. Also, it is very easy to add a new data-type to your Config class.
Name | Description | Example |
---|---|---|
String | Basic java.lang.String. Any value in the property file is accepted, the only requirement is that at least the key exists (in which case an empty string will be returned). Returned Strings are never null, and are always trimmed from pre- and post-fix whitespace. | default.css |
int | An integer. | 1023, or -99993 |
java.net.URL | An URL. The syntax of the URL must be valid, and the protocol in the URL must be one supported by the Java VM. This is validated using the java.net.URL(String string) constructor. No check is done on whether or not the URL exists or is reachable from the current computer. | http://www.chess.nl/document.html |
java.util.Date | A Date: a specific instant in time. The String
given must be parseable by the DateFormat that can
be retrieved by the following call:
DateFormat.getDateTimeInstance(DateFormat.LONG,
DateFormat.MEDIUM, Locale.US)
. When using a SimpleDateFormat the following
String can be used, using Locale.US:
MMMM d, yyyy hh:mm:ss a
| November 26, 2003 2:09:28 PM |
boolean | A boolean. A number of different values are accepted: on, true, yes and 1, and off, false, no and 0. | yes, or no |
Size in bytes | Returns a long with a size in bytes. The
format of the value is a decimal number, optionally
followed by a unit indication (KB, MB, GB). The decimal number may contain a comma (to group numbers) or a dot (to indicate a fraction), it's an American format (Locale.US). A dot can only be used when a unit is given (as the result can only be integral). A value that can not be converted to a long without losing precision will not be accepted. | 10KB (meaning 10*1024 bytes), or 777 (meaning
777 bytes) Not okay: 0.23 KB, as this would result in 235.52 bytes, which cannot be expressed in a long. |
Duration in milliseconds | Returns a long with a duration in milliseconds. The format of the input String is human-readable text, such as "5 minutes", "one day, 7 hours and a minute", or simply "5000ms". A time-unit is required (weeks, days, hours, minutes, seconds, milliseconds). | 5 minutes (meaning 5 * 60 * 1000 milliseconds), 2 s (meaning 2000 milliseconds). |
MessageFormatPattern | Returns a String that is a pattern that will work nicely with Java's MessageFormat class. The pattern is tested by rendering it with a number of possible values. | There {0,choice,0#are no files|1#is one file|1<are {0,number, integer} files} in this directory. |
All the numeric primitives that are supported by Java Config also do a check on the maximum-size of their primitive. That means that an overflow cannot occur because of a very large String-value that wouldn't fit in an integer or long.