Class MD5Template

java.lang.Object
org.jpos.space.MD5Template
All Implemented Interfaces:
Serializable, Template

public class MD5Template extends Object implements Template, Serializable
Space Template that compares entries by an MD5 digest of their serialized form rather than by reference equality.
See Also:
  • Constructor Details

    • MD5Template

      public MD5Template(Object key, Object value)
      Constructs a template that matches entries whose serialized form digests to value.
      Parameters:
      key - entry key
      value - reference value to digest
    • MD5Template

      public MD5Template(Object key, byte[] digest)
      Constructs a template directly from a precomputed digest.
      Parameters:
      key - entry key
      digest - precomputed MD5 digest
  • Method Details

    • digest

      public byte[] digest(Object obj)
      Computes the MD5 digest of obj's serialized form.
      Parameters:
      obj - object to digest
      Returns:
      the MD5 digest bytes
    • equals

      public boolean equals(Object obj)
      Description copied from interface: Template
      Indicates whether the candidate obj matches this template.
      Specified by:
      equals in interface Template
      Overrides:
      equals in class Object
      Parameters:
      obj - candidate value
      Returns:
      true when matched
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getKey

      public Object getKey()
      Returns the key this template is registered under.
      Specified by:
      getKey in interface Template
      Returns:
      the entry key
    • getDigest

      public byte[] getDigest()
      Returns the digest used for comparison.
      Returns:
      the MD5 digest bytes
    • getDigestAsString

      Returns the digest as a hex-encoded string.
      Returns:
      the digest hex string
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • serialize

      public static byte[] serialize(Object obj) throws IOException
      Serializes obj via ObjectOutputStream, returning the resulting bytes.
      Parameters:
      obj - object to serialize
      Returns:
      the serialized byte array
      Throws:
      IOException - if writing fails