public final class FormatBundle extends Object
You can either create a bundle with all builtin format specifiers (see
below for the list), or an empty one which you have to fill yourself. The
methods to use for these are respectively defaultBundle() and newBundle().
The default bundle will contain validators (FormatSpecifier
instances) for the following format attributes:
date-time,email,host-name,ip-address,ipv6,regex,uri,Other format attributes defined by the specification are hosted in a different package: json-schema-formats.
you can override these, but it is not advised that you do so: they
have been carefully designed so as to conform to the specification as closely
as possible -- in particular, leave regex alone (see
RhinoHelper).
FormatSpecifier| Modifier and Type | Field and Description |
|---|---|
private static Map<String,FormatSpecifier> |
BUILTIN_FORMATS
The builtin format specifiers
|
private Map<String,FormatSpecifier> |
specifiers
This bundle's specifiers
|
| Modifier | Constructor and Description |
|---|---|
private |
FormatBundle()
Constructor for a completely empty bundle
|
private |
FormatBundle(Map<String,FormatSpecifier> specifiers)
Constructor with a provided specifier map
|
| Modifier and Type | Method and Description |
|---|---|
static FormatBundle |
defaultBundle()
Create a new bundle with the default format specifier set
|
Map<String,FormatSpecifier> |
getSpecifiers()
Get an immutable map of this bundle's specifiers
|
void |
mergeWith(FormatBundle other)
Merge with another bundle
|
static FormatBundle |
newBundle()
Create a new, empty bundle
|
void |
registerFormat(String fmt,
FormatSpecifier specifier)
Register a new format specifier
|
String |
toString() |
void |
unregisterFormat(String fmt)
Unregister a specifier
|
private static final Map<String,FormatSpecifier> BUILTIN_FORMATS
private final Map<String,FormatSpecifier> specifiers
private FormatBundle()
private FormatBundle(Map<String,FormatSpecifier> specifiers)
specifiers - the specifiers listpublic static FormatBundle newBundle()
public static FormatBundle defaultBundle()
public void registerFormat(String fmt, FormatSpecifier specifier)
Note: it will unconditionally override any existing specifier, so be careful!
fmt - the format specifier namespecifier - the specifier instancepublic void unregisterFormat(String fmt)
fmt - the specifier namepublic void mergeWith(FormatBundle other)
Note that specifiers defined in the bundle given as an argument will happily override those defined in the current bundle. Use with care!
other - the other bundlepublic Map<String,FormatSpecifier> getSpecifiers()
Copyright © 2012. All Rights Reserved.