Class HdocUtil

java.lang.Object
com.saperion.util.HdocUtil

public final class HdocUtil extends Object
This Util should help, while working with SAPERION Document IDs. It can decode and encode the SAPERION IDs, so that it can interchange them with SAP and HTML-Gateway.
Author:
Daniel Manzke
  • Field Details

    • DIGITS

      public static final char[] DIGITS
      The Constant DIGITS.
    • EXCLAMATION_MARK

      public static final int EXCLAMATION_MARK
      The Constant EXCLAMATION_MARK.
      See Also:
    • STAR

      public static final int STAR
      The Constant STAR.
      See Also:
    • ZERO

      public static final int ZERO
      The Constant ZERO.
      See Also:
    • NINE

      public static final int NINE
      The Constant NINE.
      See Also:
    • OPEN_BRACKET

      public static final int OPEN_BRACKET
      The Constant OPEN_BRACKET.
      See Also:
    • CLOSE_BRACKET

      public static final int CLOSE_BRACKET
      The Constant CLOSE_BRACKET.
      See Also:
    • QOUTE

      public static final int QOUTE
      The Constant QOUTE.
      See Also:
    • APOSTROPHE

      public static final int APOSTROPHE
      The Constant APOSTROPHE.
      See Also:
  • Method Details

    • encode

      public static HdocUtil.DocId encode(String decoded)
      This method tooks a XHDOC (Version-specific Document ID) and encodes it, so this one can be used by the HTML-Gateway. If you want to use it with SAP, you have to convert it.
      Parameters:
      decoded - XHDOC (Version-specific Document ID)
      Returns:
      the encoded XHDOC
      See Also:
    • convert

      public static HdocUtil.SAPDocId convert(HdocUtil.DocId docId)
      This method converts an encoded XHDOC, so it can be used with SAP.
      Parameters:
      docId - encoded XHDOC
      Returns:
      converted DocID Object, so it can be used by SAP
    • decode

      public static String decode(HdocUtil.SAPDocId sapDocId) throws Exception
      This methode decodes a SAPDocId and returns the decoded XHDOC (Version-specific Document ID). It also checks if the ID starts with SAPRRXX, due the fact that this String identicates, that it is a real SAPDocId.
      Parameters:
      sapDocId - Encoded XHDOC (Version-specific Document ID)
      Returns:
      decoded XHDOC
      Throws:
      Exception - If the sapDocId is not conform
    • replaceAfterEncode

      protected static String replaceAfterEncode(String encodedUID)
      Replaces after encoding the given string.
      Parameters:
      encodedUID - The String to be encoded.
      Returns:
      The encoded and replaced string.
    • replaceBeforeDecode

      protected static String replaceBeforeDecode(String encodedUID)
      Replaces before encoding the given string.
      Parameters:
      encodedUID - The String to be encoded.
      Returns:
      The encoded and replaced string.
    • decode

      public static String decode(HdocUtil.DocId docId) throws IOException
      This method tries to decode an encoded Document ID, which is used by the HTML-Gateway.
      Parameters:
      docId - Encoded XHDOC (Version-specific Document ID)
      Returns:
      decoded XHDOC
      Throws:
      IOException - If an error occurs, while decoding (Base64)
    • bytesToHex

      protected static String bytesToHex(byte[] raw)
      Converts the given byte[] to a Hex String.
      Parameters:
      raw - The byte array to be converted to a Hex String.
      Returns:
      The converted Hex String.
    • hexToBytes

      protected static byte[] hexToBytes(String hex)
      Converts the given Hex String to a byte array.
      Parameters:
      hex - The Hex String to be converted.
      Returns:
      the converted byte[].
    • test

      public static void test() throws Exception
      Test method.
      Throws:
      Exception - if an error occurs.
    • main

      public static void main(String[] args) throws Exception
      Test driver.
      Parameters:
      args - Console arguments.
      Throws:
      Exception - if an error occurs.