Class ResourceFingerprintVisitor
- java.lang.Object
-
- org.linuxforhealth.fhir.model.visitor.DefaultVisitor
-
- org.linuxforhealth.fhir.model.visitor.PathAwareVisitor
-
- org.linuxforhealth.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 org.linuxforhealth.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, byte[] value)
void
doVisit(java.lang.String elementName, java.lang.Boolean value)
void
doVisit(java.lang.String elementName, java.lang.Integer value)
void
doVisit(java.lang.String elementName, java.lang.String value)
void
doVisit(java.lang.String elementName, java.math.BigDecimal value)
void
doVisit(java.lang.String elementName, java.time.LocalDate value)
void
doVisit(java.lang.String elementName, java.time.LocalTime value)
void
doVisit(java.lang.String elementName, java.time.Year value)
void
doVisit(java.lang.String elementName, java.time.YearMonth value)
void
doVisit(java.lang.String elementName, java.time.ZonedDateTime 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 pairboolean
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)
-
Methods inherited from class org.linuxforhealth.fhir.model.visitor.PathAwareVisitor
doVisitEnd, doVisitEnd, doVisitStart, getPath, reset, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visitEnd, visitEnd, visitStart, visitStart
-
Methods inherited from class org.linuxforhealth.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, 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
-
doVisit
public void doVisit(java.lang.String elementName, byte[] value)
- Overrides:
doVisit
in classPathAwareVisitor
-
doVisit
public void doVisit(java.lang.String elementName, java.math.BigDecimal value)
- Overrides:
doVisit
in classPathAwareVisitor
-
doVisit
public void doVisit(java.lang.String elementName, java.lang.Boolean value)
- Overrides:
doVisit
in classPathAwareVisitor
-
doVisit
public void doVisit(java.lang.String elementName, java.lang.Integer value)
- Overrides:
doVisit
in classPathAwareVisitor
-
doVisit
public void doVisit(java.lang.String elementName, java.time.LocalDate value)
- Overrides:
doVisit
in classPathAwareVisitor
-
doVisit
public void doVisit(java.lang.String elementName, java.time.LocalTime value)
- Overrides:
doVisit
in classPathAwareVisitor
-
doVisit
public void doVisit(java.lang.String elementName, java.lang.String value)
- Overrides:
doVisit
in classPathAwareVisitor
-
doVisit
public void doVisit(java.lang.String elementName, java.time.Year value)
- Overrides:
doVisit
in classPathAwareVisitor
-
doVisit
public void doVisit(java.lang.String elementName, java.time.YearMonth value)
- Overrides:
doVisit
in classPathAwareVisitor
-
doVisit
public void doVisit(java.lang.String elementName, java.time.ZonedDateTime value)
- Overrides:
doVisit
in classPathAwareVisitor
-
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:
-
-