Class StringTranslatorFactory
java.lang.Object
com.googlecode.objectify.impl.translate.ValueTranslatorFactory<String,Object>
com.googlecode.objectify.impl.translate.StringTranslatorFactory
- All Implemented Interfaces:
TranslatorFactory<String,Object>
public class StringTranslatorFactory extends ValueTranslatorFactory<String,Object>
Knows how to convert Strings. Datastore representation might be String or it might be Text.
Will work with anything that's in the datastore just by calling toString() on what we get back;
convenient for converting between say Number and the String representation, possibly dangerous
otherwise.
-
Field Summary
Modifier and TypeFieldDescriptionstatic int
Maximum number of BYTES we can store in a String before we have to convert to Text.static int
Google isn't explicit that UTF-8 encoding is used, but it's a safe assumption. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected ValueTranslator<String,Object>
createValueTranslator(TypeKey<String> tk, CreateContext ctx, Path path)
Create a translator, knowing that we have the appropriate type.Methods inherited from class com.googlecode.objectify.impl.translate.ValueTranslatorFactory
create
-
Field Details
-
MAX_STRING_BYTES
public static final int MAX_STRING_BYTESMaximum number of BYTES we can store in a String before we have to convert to Text.- See Also:
- Constant Field Values
-
SAFE_STRING_CHARS
public static final int SAFE_STRING_CHARSGoogle isn't explicit that UTF-8 encoding is used, but it's a safe assumption. Worst case is 4 bytes per character. So if we have more than that number of chars, we have to convert to UTF-8 to test the actual length.- See Also:
- Constant Field Values
-
-
Constructor Details
-
StringTranslatorFactory
public StringTranslatorFactory()
-
-
Method Details
-
createValueTranslator
protected ValueTranslator<String,Object> createValueTranslator(TypeKey<String> tk, CreateContext ctx, Path path)Description copied from class:ValueTranslatorFactory
Create a translator, knowing that we have the appropriate type. You don't need to check for type matching.- Specified by:
createValueTranslator
in classValueTranslatorFactory<String,Object>
- Parameters:
tk
- type is guaranteed to erase to something assignable to Class
-