com.github.fge.jsonschema.format
Class AbstractFormatAttribute

java.lang.Object
  extended by com.github.fge.jsonschema.format.AbstractFormatAttribute
All Implemented Interfaces:
FormatAttribute
Direct Known Subclasses:
AbstractDateFormatAttribute, Base64FormatAttribute, DateTimeAttribute, EmailAttribute, HexStringFormatAttribute, IPv4FormatAttribute, IPv6Attribute, JsonPointerFormatAttribute, MacAddressFormatAttribute, PhoneAttribute, RegexAttribute, SharedHostNameAttribute, URIAttribute, URITemplateFormatAttribute, UTCMillisecAttribute, UUIDFormatAttribute

public abstract class AbstractFormatAttribute
extends Object
implements FormatAttribute

Base abstract class for a format attribute

You should really use this class instead of implementing FormatAttribute directly. Its main, but important, helping role is to build the list of supported types for you.


Constructor Summary
protected AbstractFormatAttribute(String fmt, NodeType first, NodeType... other)
          Protected constructor
 
Method Summary
protected  ProcessingMessage newMsg(FullData data, MessageBundle bundle, String key)
          Return a new message for this format attribute
 EnumSet<NodeType> supportedTypes()
          Return the set of JSON Schema types this format attribute applies to
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.github.fge.jsonschema.format.FormatAttribute
validate
 

Constructor Detail

AbstractFormatAttribute

protected AbstractFormatAttribute(String fmt,
                                  NodeType first,
                                  NodeType... other)
Protected constructor

Parameters:
fmt - the name for this format attribute
first - first supported type
other - other supported types, if any
See Also:
supportedTypes()
Method Detail

supportedTypes

public final EnumSet<NodeType> supportedTypes()
Description copied from interface: FormatAttribute
Return the set of JSON Schema types this format attribute applies to

It is important that this method be implemented correctly. Remind that validation for a given format attribute and an instance which type is not supported always succeeds.

Specified by:
supportedTypes in interface FormatAttribute
Returns:
the set of supported types

newMsg

protected final ProcessingMessage newMsg(FullData data,
                                         MessageBundle bundle,
                                         String key)
Return a new message for this format attribute

Parameters:
data - the validation context
key - key in the format bundle message
Returns:
a new message