Package com.ibm.fhir.model.visitor
Class ResourceFingerprintVisitor
- java.lang.Object
-
- com.ibm.fhir.model.visitor.DefaultVisitor
-
- com.ibm.fhir.model.visitor.PathAwareVisitor
-
- com.ibm.fhir.model.visitor.ResourceFingerprintVisitor
-
- All Implemented Interfaces:
Visitor
public class ResourceFingerprintVisitor extends PathAwareVisitor
Compute a cryptographic hash of the visited nodes, skipping those which may be altered by the persistence layer.
-
-
Field Summary
-
Fields inherited from class com.ibm.fhir.model.visitor.DefaultVisitor
visitChildren
-
-
Constructor Summary
Constructors Constructor Description ResourceFingerprintVisitor()
Public constructor.ResourceFingerprintVisitor(byte[] salt)
Public constructor.ResourceFingerprintVisitor(SaltHash baseline)
Public constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doVisit(java.lang.String elementName, java.lang.String value)
protected void
doVisitStart(java.lang.String elementName, int elementIndex, Resource resource)
SaltHash
getSaltAndHash()
Compute the digest and return the result along with the salt that was usedprotected boolean
includePath()
Test whether or not the current path value should be included in the fingerprintprotected void
updateDigest(java.lang.String name, java.lang.String value)
Update the digest with the name/value pairvoid
visit(java.lang.String elementName, byte[] value)
boolean
visit(java.lang.String elementName, int index, Instant value)
Delegates to#visit(elementName, elementIndex, Element)
boolean
visit(java.lang.String elementName, int index, String value)
Delegates to#visit(elementName, elementIndex, Element)
void
visit(java.lang.String elementName, java.lang.Boolean value)
void
visit(java.lang.String elementName, java.lang.Integer value)
void
visit(java.lang.String elementName, java.math.BigDecimal value)
void
visit(java.lang.String elementName, java.time.LocalDate value)
void
visit(java.lang.String elementName, java.time.LocalTime value)
void
visit(java.lang.String elementName, java.time.Year value)
void
visit(java.lang.String elementName, java.time.YearMonth value)
void
visit(java.lang.String elementName, java.time.ZonedDateTime value)
-
Methods inherited from class com.ibm.fhir.model.visitor.PathAwareVisitor
doVisitEnd, doVisitEnd, doVisitStart, getPath, reset, visit, visitEnd, visitEnd, visitStart, visitStart
-
Methods inherited from class com.ibm.fhir.model.visitor.DefaultVisitor
postVisit, postVisit, preVisit, preVisit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visitEnd, visitStart
-
-
-
-
Constructor Detail
-
ResourceFingerprintVisitor
public ResourceFingerprintVisitor(byte[] salt)
Public constructor. Uses the given salt- Parameters:
salt
-
-
ResourceFingerprintVisitor
public ResourceFingerprintVisitor(SaltHash baseline)
Public constructor. Uses the salt from the given SaltHash Preferred, to avoid confusion between salt and hash- Parameters:
baseline
-
-
ResourceFingerprintVisitor
public ResourceFingerprintVisitor()
Public constructor. Generates a new salt
-
-
Method Detail
-
getSaltAndHash
public SaltHash getSaltAndHash()
Compute the digest and return the result along with the salt that was used- Returns:
-
doVisitStart
protected void doVisitStart(java.lang.String elementName, int elementIndex, Resource resource)
- Overrides:
doVisitStart
in classPathAwareVisitor
-
visit
public boolean visit(java.lang.String elementName, int index, String value)
Description copied from class:DefaultVisitor
Delegates to#visit(elementName, elementIndex, Element)
- Specified by:
visit
in interfaceVisitor
- Overrides:
visit
in classDefaultVisitor
- Returns:
- true if the children of this string should be visited; otherwise false
-
visit
public boolean visit(java.lang.String elementName, int index, Instant value)
Description copied from class:DefaultVisitor
Delegates to#visit(elementName, elementIndex, Element)
- Specified by:
visit
in interfaceVisitor
- Overrides:
visit
in classDefaultVisitor
- Returns:
- true if the children of this instant should be visited; otherwise false
-
visit
public void visit(java.lang.String elementName, byte[] value)
- Specified by:
visit
in interfaceVisitor
- Overrides:
visit
in classDefaultVisitor
-
visit
public void visit(java.lang.String elementName, java.math.BigDecimal value)
- Specified by:
visit
in interfaceVisitor
- Overrides:
visit
in classDefaultVisitor
-
visit
public void visit(java.lang.String elementName, java.lang.Boolean value)
- Specified by:
visit
in interfaceVisitor
- Overrides:
visit
in classDefaultVisitor
-
visit
public void visit(java.lang.String elementName, java.lang.Integer value)
- Specified by:
visit
in interfaceVisitor
- Overrides:
visit
in classDefaultVisitor
-
visit
public void visit(java.lang.String elementName, java.time.LocalDate value)
- Specified by:
visit
in interfaceVisitor
- Overrides:
visit
in classDefaultVisitor
-
visit
public void visit(java.lang.String elementName, java.time.LocalTime value)
- Specified by:
visit
in interfaceVisitor
- Overrides:
visit
in classDefaultVisitor
-
doVisit
public void doVisit(java.lang.String elementName, java.lang.String value)
- Overrides:
doVisit
in classPathAwareVisitor
-
visit
public void visit(java.lang.String elementName, java.time.Year value)
- Specified by:
visit
in interfaceVisitor
- Overrides:
visit
in classDefaultVisitor
-
visit
public void visit(java.lang.String elementName, java.time.YearMonth value)
- Specified by:
visit
in interfaceVisitor
- Overrides:
visit
in classDefaultVisitor
-
visit
public void visit(java.lang.String elementName, java.time.ZonedDateTime value)
- Specified by:
visit
in interfaceVisitor
- Overrides:
visit
in classDefaultVisitor
-
updateDigest
protected void updateDigest(java.lang.String name, java.lang.String value)
Update the digest with the name/value pair- Parameters:
name
-value
-
-
includePath
protected boolean includePath()
Test whether or not the current path value should be included in the fingerprint- Returns:
-
-