org.simantics.databoard.history
Class StringVariantBinding

java.lang.Object
  extended by org.simantics.databoard.binding.Binding
      extended by org.simantics.databoard.binding.VariantBinding
          extended by org.simantics.databoard.history.StringVariantBinding
All Implemented Interfaces:
java.util.Comparator<java.lang.Object>

public class StringVariantBinding
extends VariantBinding

This class binding Variant to a filename/URL compatible String. The value is human-readable for strings, integers and longs. For datatypes the value is Base64 encoded binary. Filenames have the following encoding: S String types, if string doesn't have the following control characters " : < > | ? * # \ / % [0..31] [128..] are escaped with % I Integer types L Long types B All other cases. The value is binary encoded and presented as single line Base64 string. Base64 encoding has url and filename safe options enabled. See StringVariantBindingExample

Author:
Toni Kalajainen

Nested Class Summary
 
Nested classes/interfaces inherited from class org.simantics.databoard.binding.Binding
Binding.Visitor<T>, Binding.Visitor1
 
Field Summary
static char[] HEX_VALUES
           
static StringVariantBinding INSTANCE
           
 
Constructor Summary
StringVariantBinding()
           
 
Method Summary
 void assertInstaceIsValid(java.lang.Object obj, java.util.Set<java.lang.Object> validInstances)
          Assert the obj is valid data type
 java.lang.Object create(java.lang.Object value, Binding binding)
          Create a new variant object.
 Binding getBinding(java.lang.Object variant)
          Returns a suggestion for the binding of the value of the variant.
 DataType getType(java.lang.Object variant)
           
 java.lang.Object getValue(java.lang.Object obj)
          Get the value of the variant.
 java.lang.Object getValue(java.lang.Object obj, Binding binding)
          Get the value in the variant.
 boolean isInstance(java.lang.Object obj)
           
 void setValue(java.lang.Object variant, java.lang.Object value, Binding binding)
          Set the value of an existing variant container.
 
Methods inherited from class org.simantics.databoard.binding.VariantBinding
accept, accept, createUnchecked, deepCompare, deepHashValue
 
Methods inherited from class org.simantics.databoard.binding.Binding
assertInstaceIsValid, clone, cloneUnchecked, compare, createDefault, createDefaultUnchecked, createRandom, createRandomUnchecked, equals, hashValue, isImmutable, parseValue, parseValue, parseValueDefinition, printValue, printValueDefinition, serializer, serializer, serializerUnchecked, type
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

HEX_VALUES

public static final char[] HEX_VALUES

INSTANCE

public static final StringVariantBinding INSTANCE
Constructor Detail

StringVariantBinding

public StringVariantBinding()
Method Detail

create

public java.lang.Object create(java.lang.Object value,
                               Binding binding)
                        throws BindingException
Description copied from class: VariantBinding
Create a new variant object. The value argument may be included in the result.

Specified by:
create in class VariantBinding
Returns:
variant
Throws:
BindingException

getBinding

public Binding getBinding(java.lang.Object variant)
                   throws BindingException
Description copied from class: VariantBinding
Returns a suggestion for the binding of the value of the variant. The binding is a suggestion for most optimal usage.

Specified by:
getBinding in class VariantBinding
Returns:
binding
Throws:
BindingException

getType

public DataType getType(java.lang.Object variant)
                 throws BindingException
Specified by:
getType in class VariantBinding
Throws:
BindingException

getValue

public java.lang.Object getValue(java.lang.Object obj,
                                 Binding binding)
                          throws BindingException
Description copied from class: VariantBinding
Get the value in the variant. The returned value may represent internal value of variant.

Specified by:
getValue in class VariantBinding
Returns:
value
Throws:
BindingException

getValue

public java.lang.Object getValue(java.lang.Object obj)
                          throws BindingException
Description copied from class: VariantBinding
Get the value of the variant. The value is bound with the suggested binding, see VariantBinding.getBinding(Object).

Specified by:
getValue in class VariantBinding
Returns:
value
Throws:
BindingException

setValue

public void setValue(java.lang.Object variant,
                     java.lang.Object value,
                     Binding binding)
              throws BindingException
Description copied from class: VariantBinding
Set the value of an existing variant container. Note, This is not implemented in all bindings.

Specified by:
setValue in class VariantBinding
Throws:
BindingException

assertInstaceIsValid

public void assertInstaceIsValid(java.lang.Object obj,
                                 java.util.Set<java.lang.Object> validInstances)
                          throws BindingException
Description copied from class: Binding
Assert the obj is valid data type

Specified by:
assertInstaceIsValid in class Binding
Parameters:
obj - the instance
validInstances - optional set of already validated instances
Throws:
BindingException - on invalid instance

isInstance

public boolean isInstance(java.lang.Object obj)
Specified by:
isInstance in class Binding