Package com.saperion.util
Class HdocUtil
java.lang.Object
com.saperion.util.HdocUtil
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
This class represents a DocId.static class
This class represents a SAP DocId. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The Constant APOSTROPHE.static final int
The Constant CLOSE_BRACKET.static final char[]
The Constant DIGITS.static final int
The Constant EXCLAMATION_MARK.static final int
The Constant NINE.static final int
The Constant OPEN_BRACKET.static final int
The Constant QOUTE.static final int
The Constant STAR.static final int
The Constant ZERO. -
Method Summary
Modifier and TypeMethodDescriptionprotected static String
bytesToHex
(byte[] raw) Converts the given byte[] to a Hex String.static HdocUtil.SAPDocId
convert
(HdocUtil.DocId docId) This method converts an encoded XHDOC, so it can be used with SAP.static String
decode
(HdocUtil.DocId docId) This method tries to decode an encoded Document ID, which is used by the HTML-Gateway.static String
decode
(HdocUtil.SAPDocId sapDocId) This methode decodes a SAPDocId and returns the decoded XHDOC (Version-specific Document ID).static HdocUtil.DocId
This method tooks a XHDOC (Version-specific Document ID) and encodes it, so this one can be used by the HTML-Gateway.protected static byte[]
hexToBytes
(String hex) Converts the given Hex String to a byte array.static void
Test driver.protected static String
replaceAfterEncode
(String encodedUID) Replaces after encoding the given string.protected static String
replaceBeforeDecode
(String encodedUID) Replaces before encoding the given string.static void
test()
Test method.
-
Field Details
-
DIGITS
public static final char[] DIGITSThe Constant DIGITS. -
EXCLAMATION_MARK
public static final int EXCLAMATION_MARKThe Constant EXCLAMATION_MARK.- See Also:
-
STAR
public static final int STARThe Constant STAR.- See Also:
-
ZERO
public static final int ZEROThe Constant ZERO.- See Also:
-
NINE
public static final int NINEThe Constant NINE.- See Also:
-
OPEN_BRACKET
public static final int OPEN_BRACKETThe Constant OPEN_BRACKET.- See Also:
-
CLOSE_BRACKET
public static final int CLOSE_BRACKETThe Constant CLOSE_BRACKET.- See Also:
-
QOUTE
public static final int QOUTEThe Constant QOUTE.- See Also:
-
APOSTROPHE
public static final int APOSTROPHEThe Constant APOSTROPHE.- See Also:
-
-
Method Details
-
encode
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
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
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
Replaces after encoding the given string.- Parameters:
encodedUID
- The String to be encoded.- Returns:
- The encoded and replaced string.
-
replaceBeforeDecode
Replaces before encoding the given string.- Parameters:
encodedUID
- The String to be encoded.- Returns:
- The encoded and replaced string.
-
decode
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
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
Converts the given Hex String to a byte array.- Parameters:
hex
- The Hex String to be converted.- Returns:
- the converted byte[].
-
test
Test method.- Throws:
Exception
- if an error occurs.
-
main
Test driver.- Parameters:
args
- Console arguments.- Throws:
Exception
- if an error occurs.
-