Class AbstractTemplateMethodStringCodec

java.lang.Object
de.calamanari.pk.templatemethod.AbstractTemplateMethodStringCodec
Direct Known Subclasses:
ExampleTemplateMethodStringCodec

public abstract class AbstractTemplateMethodStringCodec
extends java.lang.Object
Abstract Template Method String Codec
This demonstrates TEMPLATE METHOD pattern
Author:
Karl Eilebrecht
  • Constructor Summary

    Constructors
    Constructor Description
    AbstractTemplateMethodStringCodec()  
  • Method Summary

    Modifier and Type Method Description
    abstract boolean checkValid​(java.lang.String encodedText)
    Operation to be implemented by subclasses: Checks whether the given string is a properly encoded string.
    abstract java.lang.String decode​(java.lang.String text)
    Operation to be implemented by subclasses: Decodes the given text
    abstract java.lang.String encode​(java.lang.String text)
    Operation to be implemented by subclasses: Encodes the given text.
    java.lang.String processText​(java.lang.String text)
    This TEMPLATE METHOD processes the string using operations implemented by concrete subclasses.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • processText

      public java.lang.String processText​(java.lang.String text)
      This TEMPLATE METHOD processes the string using operations implemented by concrete subclasses.
      Parameters:
      text - input text
      Returns:
      output text
    • encode

      public abstract java.lang.String encode​(java.lang.String text)
      Operation to be implemented by subclasses: Encodes the given text.
      Parameters:
      text - raw data
      Returns:
      encoded string
    • decode

      public abstract java.lang.String decode​(java.lang.String text)
      Operation to be implemented by subclasses: Decodes the given text
      Parameters:
      text - encoded string
      Returns:
      decoded string
    • checkValid

      public abstract boolean checkValid​(java.lang.String encodedText)
      Operation to be implemented by subclasses: Checks whether the given string is a properly encoded string.
      Parameters:
      encodedText - encoded string
      Returns:
      true if encoded string is valid and could be decoded