Class JCoHelper
- java.lang.Object
-
- de.hybris.platform.sap.core.bol.backend.jco.JCoHelper
-
public class JCoHelper extends java.lang.ObjectConvenience class for the management of JCo. The implementation of JCo is sometimes a little bit low level for the purposes of the internet sales application. Because of this theJCoHelperclass provides some helper classes and convenience methods to simplify the handling of JCo and especially its data structures.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJCoHelper.RecordWrapperWraps around a JCo record and decorates the record with convenient methods to set the record's data.static classJCoHelper.ReturnValueRepresents the data returned by a call to the function module.
-
Constructor Summary
Constructors Constructor Description JCoHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleangetBoolean(com.sap.conn.jco.JCoField field)Converts the ABAP logic for booleans,"" = false,"X" = trueinto a Java boolean.static booleangetBoolean(com.sap.conn.jco.JCoRecord record, java.lang.String field)Converts the ABAP logic for booleans,"" = false,"X" = trueinto a Java boolean.static booleangetBoolean(java.lang.String string)Converts the ABAP logic for booleans,"" = false,"X" = trueinto a Java boolean.static java.util.DategetDate(com.sap.conn.jco.JCoRecord record, java.lang.String field)Returns the specified field of a JCo record converted to a date.static java.lang.StringgetExceptionGroupAsString(com.sap.conn.jco.JCoException jcoEx)Returns the group of the JCOException as a String.static java.lang.StringgetString(com.sap.conn.jco.JCoRecord record, java.lang.String field)Returns the specified field of a JCo record converted to a string.static java.lang.StringgetStringFromNUMC(com.sap.conn.jco.JCoRecord record, java.lang.String field)Converts an ABAP NUMC data type to an String which means it's trims all leading zeros.static java.lang.StringgetStringFromRaw(com.sap.conn.jco.JCoRecord record, java.lang.String field)Returns the specified raw field of a JCo record converted to a string.static java.lang.StringgetStringPerfOpt(com.sap.conn.jco.JCoRecord jcoRecord, java.lang.String arg0)This methods avoids creation of independent copies of "" in order to save memory.static TechKeygetTechKey(com.sap.conn.jco.JCoRecord record, java.lang.String field)Converts a technical key stored in a JCo record into an object of typeTechKey.static TechKeygetTechKeyFromRaw(com.sap.conn.jco.JCoRecord record, java.lang.String field)Converts a technical key stored in a JCo record as raw value into an object of typeTechKey.static java.lang.StringlFillStr(java.lang.String src, java.lang.String filler, int len)Helper for String-formatting Returns a String filled up to the left with filler up to the length len.protected static voidlogCall(java.lang.String functionName, com.sap.conn.jco.JCoRecord input, com.sap.conn.jco.JCoRecord output)Logs a RFC-call into the log file of the application.static voidlogCall(java.lang.String functionName, com.sap.conn.jco.JCoRecord input, com.sap.conn.jco.JCoRecord output, org.apache.log4j.Logger log)Logs a RFC-call into the log file of the application.protected static voidlogCall(java.lang.String functionName, com.sap.conn.jco.JCoTable input, com.sap.conn.jco.JCoTable output)Logs a RFC-call into the log file of the application.static voidlogCall(java.lang.String functionName, com.sap.conn.jco.JCoTable input, com.sap.conn.jco.JCoTable output, Log4JWrapper log)Logs a RFC-call into the log file of the application.protected static voidlogCall(java.lang.String functionName, JCoHelper.RecordWrapper input, JCoHelper.RecordWrapper output)Logs a RFC-call into the log file of the application.static voidlogCall(java.lang.String functionName, JCoHelper.RecordWrapper input, JCoHelper.RecordWrapper output, org.apache.log4j.Logger log)Logs a RFC-call into the log file of the application.static voidlogCall(java.lang.String functionName, java.lang.String marker, com.sap.conn.jco.JCoTable table, java.lang.String[] obfuscatedColumns, org.apache.log4j.Logger log)Logs a RFC-call into the log file of the application.protected static voidlogException(java.lang.String functionName, com.sap.conn.jco.JCoException ex)Log an exception with level ERROR.static java.lang.Stringobfuscate(java.lang.String value)Obfuscate string value.static voidsetValue(com.sap.conn.jco.JCoRecord record, boolean value, java.lang.String field)Sets the given field of the JCo structure to the provided value.static voidsetValue(com.sap.conn.jco.JCoRecord record, double value, java.lang.String field)Sets the given field of the JCo structure to the provided value.static voidsetValue(com.sap.conn.jco.JCoRecord record, int value, java.lang.String field)Sets the given field of the JCo structure to the provided value.static voidsetValue(com.sap.conn.jco.JCoRecord record, TechKey value, java.lang.String field)Sets the given field of the JCo structure to the provided value.static voidsetValue(com.sap.conn.jco.JCoRecord record, java.lang.String value, java.lang.String field)Sets the given field of the JCo structure to the provided value.static voidsetValueAsRaw(com.sap.conn.jco.JCoRecord record, TechKey value, java.lang.String field)Sets the given string field of the JCo structure to the provided value as Raw, that means the value is converted into a byte Array.static voidsetValueAsRaw(com.sap.conn.jco.JCoRecord record, java.lang.String value, java.lang.String field)Sets the given string field of the JCo structure to the provided value as Raw, that means the value is converted into a byte Array.
-
-
-
Method Detail
-
lFillStr
public static java.lang.String lFillStr(java.lang.String src, java.lang.String filler, int len)Helper for String-formatting Returns a String filled up to the left with filler up to the length len.- Parameters:
src- the sourcefiller- the fillerlen- the length- Returns:
- newStr
-
getExceptionGroupAsString
public static java.lang.String getExceptionGroupAsString(com.sap.conn.jco.JCoException jcoEx)
Returns the group of the JCOException as a String.- Parameters:
jcoEx- the JCO exception- Returns:
- string describing the group of the exception
-
getBoolean
public static boolean getBoolean(java.lang.String string)
Converts the ABAP logic for booleans,"" = false,"X" = trueinto a Java boolean. Instead of using this method, you may want to use theWrapperclass. The use of this method is only helpful, if you want to convert a limited amount of fields, mostly booleans.- Parameters:
string- String to be converted into a boolean- Returns:
falseif the string is empty, otherwisetrue.
-
getBoolean
public static boolean getBoolean(com.sap.conn.jco.JCoField field)
Converts the ABAP logic for booleans,"" = false,"X" = trueinto a Java boolean. Instead of using this method, you may want to use theWrapperclass. The use of this method is only helpful, if you want to convert a limited amount of fields, mostly booleans.- Parameters:
field- JCO.Field to be converted into a boolean- Returns:
falseif the string is empty, otherwisetrue.
-
getBoolean
public static boolean getBoolean(com.sap.conn.jco.JCoRecord record, java.lang.String field)Converts the ABAP logic for booleans,"" = false,"X" = trueinto a Java boolean. Instead of using this method, you may want to use theWrapperclass. The use of this method is only helpful, if you want to convert a limited amount of fields, mostly booleans.- Parameters:
record- JCO.Record containing the column to be converted into a booleanfield- Name of the column to be converted- Returns:
falseif the string is empty, otherwisetrue.
-
getString
public static java.lang.String getString(com.sap.conn.jco.JCoRecord record, java.lang.String field)Returns the specified field of a JCo record converted to a string.- Parameters:
record- JCO.Record containing the column to be converted into a Stringfield- Name of the column to be converted- Returns:
- The value as String
-
getStringFromRaw
public static java.lang.String getStringFromRaw(com.sap.conn.jco.JCoRecord record, java.lang.String field)Returns the specified raw field of a JCo record converted to a string.- Parameters:
record- JCO.Record containing the column to be converted into a Stringfield- Name of the column to be converted- Returns:
- The value as String
-
getDate
public static java.util.Date getDate(com.sap.conn.jco.JCoRecord record, java.lang.String field)Returns the specified field of a JCo record converted to a date.- Parameters:
record- JCO.Record containing the column to be converted into a Datefield- Name of the column to be converted- Returns:
- The value as Date
-
getTechKey
public static TechKey getTechKey(com.sap.conn.jco.JCoRecord record, java.lang.String field)
Converts a technical key stored in a JCo record into an object of typeTechKey. The use of this method is only helpful, if you want to convert a limited amount of fields, mostly booleans.- Parameters:
record- JCO.Record containing the column to be converted into a technical key. If this parameter isnullthe method returnsnullfield- Name of the column to be converted- Returns:
- a technical key for the specified column.
-
getTechKeyFromRaw
public static TechKey getTechKeyFromRaw(com.sap.conn.jco.JCoRecord record, java.lang.String field)
Converts a technical key stored in a JCo record as raw value into an object of typeTechKey. T- Parameters:
record- JCO.Record containing the column to be converted into a technical key. If this parameter isnullthe method returnsnullfield- Name of the column to be converted- Returns:
- a technical key for the specified column.
-
setValue
public static void setValue(com.sap.conn.jco.JCoRecord record, int value, java.lang.String field)Sets the given field of the JCo structure to the provided value.- Parameters:
record- The JCo record to work withvalue- Value to be setfield- JCo field to be filled with the value
-
setValue
public static void setValue(com.sap.conn.jco.JCoRecord record, java.lang.String value, java.lang.String field)Sets the given field of the JCo structure to the provided value.- Parameters:
record- The JCo record to work withvalue- Value to be setfield- JCo field to be filled with the value
-
setValueAsRaw
public static void setValueAsRaw(com.sap.conn.jco.JCoRecord record, java.lang.String value, java.lang.String field)Sets the given string field of the JCo structure to the provided value as Raw, that means the value is converted into a byte Array.- Parameters:
record- The JCo record to work withvalue- Value to be setfield- JCo field to be filled with the value
-
setValue
public static void setValue(com.sap.conn.jco.JCoRecord record, double value, java.lang.String field)Sets the given field of the JCo structure to the provided value.- Parameters:
record- The JCo record to work withvalue- Value to be setfield- JCo field to be filled with the value
-
setValue
public static void setValue(com.sap.conn.jco.JCoRecord record, boolean value, java.lang.String field)Sets the given field of the JCo structure to the provided value.- Parameters:
record- The JCo record to work withvalue- Value to be setfield- JCo field to be filled with the value
-
setValue
public static void setValue(com.sap.conn.jco.JCoRecord record, TechKey value, java.lang.String field)Sets the given field of the JCo structure to the provided value. If the provided tech key isnullnothing is done and the method returns immediately.- Parameters:
record- The JCo record to work withvalue- Value to be setfield- JCo field to be filled with the value
-
setValueAsRaw
public static void setValueAsRaw(com.sap.conn.jco.JCoRecord record, TechKey value, java.lang.String field)Sets the given string field of the JCo structure to the provided value as Raw, that means the value is converted into a byte Array. If the provided tech key isnullnothing is done and the method returns immediately.- Parameters:
record- The JCo record to work withvalue- Value to be setfield- JCo field to be filled with the value
-
getStringFromNUMC
public static java.lang.String getStringFromNUMC(com.sap.conn.jco.JCoRecord record, java.lang.String field)Converts an ABAP NUMC data type to an String which means it's trims all leading zeros.- Parameters:
record- the JCo record to extract field fromfield- the name of the field that should be extracted from the record- Returns:
- the trimed string
-
logCall
public static void logCall(java.lang.String functionName, com.sap.conn.jco.JCoRecord input, com.sap.conn.jco.JCoRecord output, org.apache.log4j.Logger log)Logs a RFC-call into the log file of the application.- Parameters:
functionName- the name of the JCo function that was executedinput- input data for the function module. You may set this parameter tonullif you don't have any data to be logged.output- output data for the function module. You may set this parameter tonullif you don't have any data to be logged.log- the logging context to be used
-
logCall
public static void logCall(java.lang.String functionName, JCoHelper.RecordWrapper input, JCoHelper.RecordWrapper output, org.apache.log4j.Logger log)Logs a RFC-call into the log file of the application.- Parameters:
functionName- the name of the JCo function that was executedinput- input data for the function module. You may set this parameter tonullif you don't have any data to be logged.output- output data for the function module. You may set this parameter tonullif you don't have any data to be logged.log- the logging context to be used
-
logCall
public static void logCall(java.lang.String functionName, com.sap.conn.jco.JCoTable input, com.sap.conn.jco.JCoTable output, Log4JWrapper log)Logs a RFC-call into the log file of the application.- Parameters:
functionName- the name of the JCo function that was executedinput- input data for the function module. You may set this parameter tonullif you don't have any data to be logged.output- output data for the function module. You may set this parameter tonullif you don't have any data to be logged.log- the logging context to be used
-
logCall
protected static void logCall(java.lang.String functionName, com.sap.conn.jco.JCoRecord input, com.sap.conn.jco.JCoRecord output)Logs a RFC-call into the log file of the application.- Parameters:
functionName- the function name to be loggedinput- input recordoutput- output record
-
logCall
protected static void logCall(java.lang.String functionName, JCoHelper.RecordWrapper input, JCoHelper.RecordWrapper output)Logs a RFC-call into the log file of the application.- Parameters:
functionName- the function name to be loggedinput- input record wrapperoutput- output record wrapper
-
logCall
protected static void logCall(java.lang.String functionName, com.sap.conn.jco.JCoTable input, com.sap.conn.jco.JCoTable output)Logs a RFC-call into the log file of the application.- Parameters:
functionName- the function name to be loggedinput- input JCo tableoutput- output JCo table
-
logException
protected static void logException(java.lang.String functionName, com.sap.conn.jco.JCoException ex)Log an exception with level ERROR.- Parameters:
functionName- the function name to be loggedex- the Exception to be logged
-
getStringPerfOpt
public static java.lang.String getStringPerfOpt(com.sap.conn.jco.JCoRecord jcoRecord, java.lang.String arg0)This methods avoids creation of independent copies of "" in order to save memory.- Parameters:
jcoRecord- the JCo recordarg0- argument- Returns:
- result
-
obfuscate
public static java.lang.String obfuscate(java.lang.String value)
Obfuscate string value. String is replaced with a list of "*".- Parameters:
value- the value to be obfuscated- Returns:
- obfuscated value
-
logCall
public static void logCall(java.lang.String functionName, java.lang.String marker, com.sap.conn.jco.JCoTable table, java.lang.String[] obfuscatedColumns, org.apache.log4j.Logger log)Logs a RFC-call into the log file of the application.- Parameters:
functionName- the name of the JCo function that was executedmarker- textual maker to identify a particular loggingtable- input data for the function module. You may set this parameter tonullif you don't have any data to be logged.obfuscatedColumns- columns, values of this columns will be obfuscatedlog- the logging context to be used
-
-