Package com.saperion.util
Class HdocUtil
- java.lang.Object
-
- com.saperion.util.HdocUtil
-
public final class HdocUtil extends java.lang.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HdocUtil.DocId
This class represents a DocId.static class
HdocUtil.SAPDocId
This class represents a SAP DocId.
-
Field Summary
Fields Modifier and Type Field Description static int
APOSTROPHE
The Constant APOSTROPHE.static int
CLOSE_BRACKET
The Constant CLOSE_BRACKET.static char[]
DIGITS
The Constant DIGITS.static int
EXCLAMATION_MARK
The Constant EXCLAMATION_MARK.static int
NINE
The Constant NINE.static int
OPEN_BRACKET
The Constant OPEN_BRACKET.static int
QOUTE
The Constant QOUTE.static int
STAR
The Constant STAR.static int
ZERO
The Constant ZERO.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static java.lang.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 java.lang.String
decode(HdocUtil.DocId docId)
This method tries to decode an encoded Document ID, which is used by the HTML-Gateway.static java.lang.String
decode(HdocUtil.SAPDocId sapDocId)
This methode decodes a SAPDocId and returns the decoded XHDOC (Version-specific Document ID).static HdocUtil.DocId
encode(java.lang.String decoded)
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(java.lang.String hex)
Converts the given Hex String to a byte array.static void
main(java.lang.String[] args)
Test driver.protected static java.lang.String
replaceAfterEncode(java.lang.String encodedUID)
Replaces after encoding the given string.protected static java.lang.String
replaceBeforeDecode(java.lang.String encodedUID)
Replaces before encoding the given string.static void
test()
Test method.
-
-
-
Field Detail
-
DIGITS
public static final char[] DIGITS
The Constant DIGITS.
-
EXCLAMATION_MARK
public static final int EXCLAMATION_MARK
The Constant EXCLAMATION_MARK.- See Also:
- Constant Field Values
-
STAR
public static final int STAR
The Constant STAR.- See Also:
- Constant Field Values
-
ZERO
public static final int ZERO
The Constant ZERO.- See Also:
- Constant Field Values
-
NINE
public static final int NINE
The Constant NINE.- See Also:
- Constant Field Values
-
OPEN_BRACKET
public static final int OPEN_BRACKET
The Constant OPEN_BRACKET.- See Also:
- Constant Field Values
-
CLOSE_BRACKET
public static final int CLOSE_BRACKET
The Constant CLOSE_BRACKET.- See Also:
- Constant Field Values
-
QOUTE
public static final int QOUTE
The Constant QOUTE.- See Also:
- Constant Field Values
-
APOSTROPHE
public static final int APOSTROPHE
The Constant APOSTROPHE.- See Also:
- Constant Field Values
-
-
Method Detail
-
encode
public static HdocUtil.DocId encode(java.lang.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(DocId)
-
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 java.lang.String decode(HdocUtil.SAPDocId sapDocId) throws java.lang.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:
java.lang.Exception
- If the sapDocId is not conform
-
replaceAfterEncode
protected static java.lang.String replaceAfterEncode(java.lang.String encodedUID)
Replaces after encoding the given string.- Parameters:
encodedUID
- The String to be encoded.- Returns:
- The encoded and replaced string.
-
replaceBeforeDecode
protected static java.lang.String replaceBeforeDecode(java.lang.String encodedUID)
Replaces before encoding the given string.- Parameters:
encodedUID
- The String to be encoded.- Returns:
- The encoded and replaced string.
-
decode
public static java.lang.String decode(HdocUtil.DocId docId) throws java.io.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:
java.io.IOException
- If an error occurs, while decoding (Base64)
-
bytesToHex
protected static java.lang.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(java.lang.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 java.lang.Exception
Test method.- Throws:
java.lang.Exception
- if an error occurs.
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception
Test driver.- Parameters:
args
- Console arguments.- Throws:
java.lang.Exception
- if an error occurs.
-
-