Class AnonymizingTypeTranslator
- java.lang.Object
-
- org.apache.tinkerpop.gremlin.process.traversal.Translator.ScriptTranslator.AbstractTypeTranslator
-
- org.apache.tinkerpop.gremlin.process.traversal.translator.GroovyTranslator.DefaultTypeTranslator
-
- org.apache.tinkerpop.gremlin.process.traversal.translator.AnonymizingTypeTranslator
-
- All Implemented Interfaces:
BiFunction<String,Object,Script>
,Translator.ScriptTranslator.TypeTranslator
public class AnonymizingTypeTranslator extends GroovyTranslator.DefaultTypeTranslator
This Translator will translateBytecode
into a representation that has been stripped of any user data (anonymized). A default anonymizer is provided, but can be replaced with a custom anonymizer as needed. The default anonymizer replaces any String, Numeric, Date, Timestamp, or UUID with a type-based token. Identical values will receive the same token (e.g. if "foo" is assigned "string0" then all occurrences of "foo" will be replaced with "string0").
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
AnonymizingTypeTranslator.Anonymizer
Customizable anonymizer interface.static class
AnonymizingTypeTranslator.DefaultAnonymizer
This default implementation keeps a map from type (Java Class) to another map from instances to anonymized token.
-
Field Summary
-
Fields inherited from class org.apache.tinkerpop.gremlin.process.traversal.Translator.ScriptTranslator.AbstractTypeTranslator
ANONYMOUS_TRAVERSAL_PREFIX, script, withParameters
-
-
Constructor Summary
Constructors Constructor Description AnonymizingTypeTranslator()
Default constructor creates aAnonymizingTypeTranslator.DefaultAnonymizer
+ withParameters=false.AnonymizingTypeTranslator(boolean withParameters)
AnonymizingTypeTranslator(AnonymizingTypeTranslator.Anonymizer anonymizer, boolean withParameters)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
getSyntax(Number o)
Take the numeric argument and convert it to a string representation in the target language.protected String
getSyntax(String o)
Take the string argument and convert it to a string representation in the target language (i.e.protected String
getSyntax(Timestamp o)
Take theTimestamp
argument and convert it to a string representation in the target language.protected String
getSyntax(Date o)
Take theDate
argument and convert it to a string representation in the target language.protected String
getSyntax(UUID o)
Take theUUID
argument and convert it to a string representation in the target language.protected Script
produceScript(Class<?> o)
Gets the string representation of a class with the default implementation simply checking to see if theClass
is inCoreImports
or not.-
Methods inherited from class org.apache.tinkerpop.gremlin.process.traversal.translator.GroovyTranslator.DefaultTypeTranslator
getNullSyntax, getSyntax, getSyntax, getSyntax, getSyntax, getSyntax, produceCardinalityValue, produceScript, produceScript, produceScript, produceScript, produceScript, produceScript, produceScript, produceScript, produceScript, produceScript
-
Methods inherited from class org.apache.tinkerpop.gremlin.process.traversal.Translator.ScriptTranslator.AbstractTypeTranslator
apply, convertToScript, getAnonymousTraversalPrefix
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.function.BiFunction
andThen
-
-
-
-
Constructor Detail
-
AnonymizingTypeTranslator
public AnonymizingTypeTranslator()
Default constructor creates aAnonymizingTypeTranslator.DefaultAnonymizer
+ withParameters=false.
-
AnonymizingTypeTranslator
public AnonymizingTypeTranslator(boolean withParameters)
-
AnonymizingTypeTranslator
public AnonymizingTypeTranslator(AnonymizingTypeTranslator.Anonymizer anonymizer, boolean withParameters)
-
-
Method Detail
-
getSyntax
protected String getSyntax(String o)
Description copied from class:Translator.ScriptTranslator.AbstractTypeTranslator
Take the string argument and convert it to a string representation in the target language (i.e. escape, enclose in appropriate quotes, etc.)- Overrides:
getSyntax
in classGroovyTranslator.DefaultTypeTranslator
-
getSyntax
protected String getSyntax(Date o)
Description copied from class:Translator.ScriptTranslator.AbstractTypeTranslator
Take theDate
argument and convert it to a string representation in the target language.- Overrides:
getSyntax
in classGroovyTranslator.DefaultTypeTranslator
-
getSyntax
protected String getSyntax(Timestamp o)
Description copied from class:Translator.ScriptTranslator.AbstractTypeTranslator
Take theTimestamp
argument and convert it to a string representation in the target language.- Overrides:
getSyntax
in classGroovyTranslator.DefaultTypeTranslator
-
getSyntax
protected String getSyntax(UUID o)
Description copied from class:Translator.ScriptTranslator.AbstractTypeTranslator
Take theUUID
argument and convert it to a string representation in the target language.- Overrides:
getSyntax
in classGroovyTranslator.DefaultTypeTranslator
-
getSyntax
protected String getSyntax(Number o)
Description copied from class:Translator.ScriptTranslator.AbstractTypeTranslator
Take the numeric argument and convert it to a string representation in the target language. Languages that can discern differences in types of numbers will wish to further check the type of theNumber
instance itself (i.e.Double
,Integer
, etc.)- Overrides:
getSyntax
in classGroovyTranslator.DefaultTypeTranslator
-
produceScript
protected Script produceScript(Class<?> o)
Description copied from class:GroovyTranslator.DefaultTypeTranslator
Gets the string representation of a class with the default implementation simply checking to see if theClass
is inCoreImports
or not. If it is present that means it can be referenced using the simple name otherwise it uses the canonical name. Those building customTranslator.ScriptTranslator
instances might override this if they have other classes that are not inCoreImports
by default.- Overrides:
produceScript
in classGroovyTranslator.DefaultTypeTranslator
-
-