Class DataMappingUtils
- java.lang.Object
-
- com.priint.pubserver.comet.bridge.datamapping.DataMappingUtils
-
public class DataMappingUtils extends java.lang.ObjectThe type Data mapping utils.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanall(java.lang.String[] records)All boolean.static booleancheckRange(java.util.List<?> values, java.util.List<java.lang.Integer> range)Check range boolean.static java.util.List<java.lang.String>emptyList()Empty list list.static voidfailIfInputEmpty(java.lang.Object caller, java.util.List<?> in)Fail if input empty.static voidfailIfSizeDiffer(java.lang.Object caller, java.util.List<?> input, java.util.List<?> output, java.lang.String entityModelIdentifier, java.lang.String entityId, java.lang.String parentBucketId, java.lang.String recordGroupIdentifier, java.lang.String resultEntityId, Context context, java.lang.String searchStr)Fail if size differ.static <T> voidfailIfTargetEmpty(java.lang.Object caller, T target, java.lang.Class<?> clazz, java.lang.String entityModelIdentifier, java.lang.String entityId, java.lang.String parentBucketId, java.lang.String recordGroupIdentifier, java.lang.String resultEntityId, Context context, java.lang.String searchStr, int... range)Fail if target empty.static java.util.List<KeyValue>filterByKey(java.util.List<KeyValue> values, java.lang.String key)Filter by key list.static java.lang.StringgetDelimiter(java.lang.String delimiter, int pos, int size)Adds delimiter after each but not the last element of the returned stringstatic <T> TgetListElement(java.util.List<T> input, int index)Gets list element.static MediaObjectgetMediaObjectByTypeAndMedia(MediaAsset asset, java.lang.String type, java.lang.String media)Gets media object by type and media.static <T> TgetNthOf(java.util.List<T> in, int nth)Gets nth of.static <T> TgetNthOf(T[] in, int nth)Gets nth of.static java.util.List<java.lang.Integer>getRecordIndexList(java.lang.String[] record, int listSize)Returns list of indexesstatic <T> java.util.List<T>getSubList(java.util.List<T> values, java.util.List<java.lang.Integer> range)Gets sub list.static java.lang.IntegergetZBasedIndex(int pos, int listSize)Returns index of the requested recordstatic java.lang.StringlistSize(java.util.List<?> list)List size string.static java.util.List<java.lang.Integer>parseNumberList(java.lang.String input)Parse number list list.static java.util.List<java.lang.Integer>parseNumberList(java.lang.String input, char fieldSeparator)Parse number list list.static java.util.List<java.lang.String>parseQuotedList(java.lang.String input)Parse quoted list list.static java.util.List<java.lang.String>parseQuotedList(java.lang.String input, char fieldSeparator, char fieldDelimiter)Parse quoted list list.static java.lang.StringpopFront(java.lang.String from, java.lang.String prefix)Pop front string.static java.lang.StringpopTail(java.lang.String from, java.lang.String suffix)Pop tail string.static java.util.List<java.lang.Integer>processRange(java.util.List<?> values, java.lang.String input)Process range list.static java.lang.Stringrange(int... range)Range string.static <T> TrequireNthOf(java.util.List<T> in, int nth)Require nth of t.static <T> TrequireNthOf(T[] in, int nth)Require nth of t.static java.lang.String[]split(java.lang.String value, java.lang.String separator)Split string [ ].static java.util.List<java.lang.String>stringList(java.lang.String... strings)Converts a string array or several strings to a string liststatic java.lang.StringtoString(java.lang.String input)Returns the string given or empty string if null was given.static booleanvalidList(java.lang.String[] records)Validates correctness of the requested records list, list can contain positive and negative Integers, or the String 'all'
-
-
-
Field Detail
-
LAST
public static final int LAST
The constant LAST.- See Also:
- Constant Field Values
-
FIRST
public static final int FIRST
The constant FIRST.- See Also:
- Constant Field Values
-
-
Method Detail
-
emptyList
public static java.util.List<java.lang.String> emptyList()
Empty list list.- Returns:
- a String List containing one (empty) string
-
stringList
public static java.util.List<java.lang.String> stringList(java.lang.String... strings)
Converts a string array or several strings to a string list
- Parameters:
strings- zero, one or more strings- Returns:
- a string list containing all strings provided as argument
-
getListElement
public static <T> T getListElement(java.util.List<T> input, int index)Gets list element.- Type Parameters:
T- the type parameter- Parameters:
input- the inputindex- the index- Returns:
- the list element
-
processRange
public static java.util.List<java.lang.Integer> processRange(java.util.List<?> values, java.lang.String input)Process range list.- Parameters:
values- the valuesinput- the input- Returns:
- the list
-
getSubList
public static <T> java.util.List<T> getSubList(java.util.List<T> values, java.util.List<java.lang.Integer> range)Gets sub list.- Type Parameters:
T- the type parameter- Parameters:
values- the valuesrange- the range- Returns:
- the sub list
-
checkRange
public static boolean checkRange(java.util.List<?> values, java.util.List<java.lang.Integer> range)Check range boolean.- Parameters:
values- the valuesrange- the range- Returns:
- the boolean
-
getRecordIndexList
public static java.util.List<java.lang.Integer> getRecordIndexList(java.lang.String[] record, int listSize)Returns list of indexes- Parameters:
record- list of requested records, delimited by ',' (comma), can contain- string 'all' whole list will be returned
- positive numbers - returns, value decremented by one e.g 1 will return index of 0
- negative numbers - returns element count from the end of the list, e.g -1 will return index of the last element
- 0 (zero) - returns index of the first element, the same result as 1
listSize- length of list from which records are requested- Returns:
- list of indexes from the parameter list, requested by record
-
validList
public static boolean validList(java.lang.String[] records)
Validates correctness of the requested records list, list can contain positive and negative Integers, or the String 'all'- Parameters:
records- array of values to be checked- Returns:
- true if text is not null and is not empty and all values are correct
-
getDelimiter
public static java.lang.String getDelimiter(java.lang.String delimiter, int pos, int size)Adds delimiter after each but not the last element of the returned string- Parameters:
delimiter- delimiter to be addedpos- position of the element, when 0 (zero) returns empty stringsize- number of all elements in the list- Returns:
- delimiter or empty stringreturn (pos == 0 ? "" : (pos + 1 < size ? delimiter : ""));
-
parseQuotedList
public static java.util.List<java.lang.String> parseQuotedList(java.lang.String input, char fieldSeparator, char fieldDelimiter)Parse quoted list list.- Parameters:
input- the inputfieldSeparator- the field separatorfieldDelimiter- the field delimiter- Returns:
- the list
-
parseQuotedList
public static java.util.List<java.lang.String> parseQuotedList(java.lang.String input)
Parse quoted list list.- Parameters:
input- the input- Returns:
- the list
-
parseNumberList
public static java.util.List<java.lang.Integer> parseNumberList(java.lang.String input, char fieldSeparator)Parse number list list.- Parameters:
input- the inputfieldSeparator- the field separator- Returns:
- the list
-
parseNumberList
public static java.util.List<java.lang.Integer> parseNumberList(java.lang.String input)
Parse number list list.- Parameters:
input- the input- Returns:
- the list
-
toString
public static java.lang.String toString(java.lang.String input)
Returns the string given or empty string if null was given.Use this to prevent Null Pointer Exceptions.
- Parameters:
input- the input- Returns:
- string
-
getNthOf
public static <T> T getNthOf(java.util.List<T> in, int nth)Gets nth of.- Type Parameters:
T- the type parameter- Parameters:
in- the innth- the nth- Returns:
- the nth of
-
getNthOf
public static <T> T getNthOf(T[] in, int nth)Gets nth of.- Type Parameters:
T- the type parameter- Parameters:
in- the innth- the nth- Returns:
- the nth of
-
requireNthOf
public static <T> T requireNthOf(T[] in, int nth) throws PubServerExceptionRequire nth of t.- Type Parameters:
T- the type parameter- Parameters:
in- the innth- the nth- Returns:
- the t
- Throws:
PubServerException- the pub server exception
-
requireNthOf
public static <T> T requireNthOf(java.util.List<T> in, int nth) throws PubServerExceptionRequire nth of t.- Type Parameters:
T- the type parameter- Parameters:
in- the innth- the nth- Returns:
- the t
- Throws:
PubServerException- the pub server exception
-
filterByKey
public static java.util.List<KeyValue> filterByKey(java.util.List<KeyValue> values, java.lang.String key)
Filter by key list.- Parameters:
values- the valueskey- the key- Returns:
- the list
-
split
public static java.lang.String[] split(java.lang.String value, java.lang.String separator)Split string [ ].- Parameters:
value- the valueseparator- the separator- Returns:
- the string [ ]
-
popFront
public static java.lang.String popFront(java.lang.String from, java.lang.String prefix)Pop front string.- Parameters:
from- the fromprefix- the prefix- Returns:
- the string
-
popTail
public static java.lang.String popTail(java.lang.String from, java.lang.String suffix)Pop tail string.- Parameters:
from- the fromsuffix- the suffix- Returns:
- the string
-
failIfInputEmpty
public static void failIfInputEmpty(java.lang.Object caller, java.util.List<?> in) throws PubServerExceptionFail if input empty.- Parameters:
caller- the callerin- the in- Throws:
PubServerException- the pub server exception
-
failIfTargetEmpty
public static <T> void failIfTargetEmpty(java.lang.Object caller, T target, java.lang.Class<?> clazz, java.lang.String entityModelIdentifier, java.lang.String entityId, java.lang.String parentBucketId, java.lang.String recordGroupIdentifier, java.lang.String resultEntityId, Context context, java.lang.String searchStr, int... range) throws PubServerExceptionFail if target empty.- Type Parameters:
T- the type parameter- Parameters:
caller- the callertarget- the targetclazz- the clazzentityModelIdentifier- the entity model identifierentityId- the entity idparentBucketId- the parent bucket idrecordGroupIdentifier- the record group identifierresultEntityId- the result entity idcontext- the contextsearchStr- the search strrange- the range- Throws:
PubServerException- the pub server exception
-
listSize
public static java.lang.String listSize(java.util.List<?> list)
List size string.- Parameters:
list- the list- Returns:
- the string
-
failIfSizeDiffer
public static void failIfSizeDiffer(java.lang.Object caller, java.util.List<?> input, java.util.List<?> output, java.lang.String entityModelIdentifier, java.lang.String entityId, java.lang.String parentBucketId, java.lang.String recordGroupIdentifier, java.lang.String resultEntityId, Context context, java.lang.String searchStr) throws PubServerExceptionFail if size differ.- Parameters:
caller- the callerinput- the inputoutput- the outputentityModelIdentifier- the entity model identifierentityId- the entity idparentBucketId- the parent bucket idrecordGroupIdentifier- the record group identifierresultEntityId- the result entity idcontext- the contextsearchStr- the search str- Throws:
PubServerException- the pub server exception
-
range
public static java.lang.String range(int... range)
Range string.- Parameters:
range- the range- Returns:
- the string
-
all
public static boolean all(java.lang.String[] records)
All boolean.- Parameters:
records- the records- Returns:
- the boolean
-
getZBasedIndex
public static java.lang.Integer getZBasedIndex(int pos, int listSize)Returns index of the requested record- Parameters:
pos- requested position of the record- positive number - returns, value decremented by one e.g 1 will return index of 0
- negative number - returns element count from the end of the list, e.g -1 will return index of the last element
- 0 (zero) - returns index of the first element, the same result as 1
listSize- number of all elements in the array- Returns:
- index of the requested record
-
getMediaObjectByTypeAndMedia
public static MediaObject getMediaObjectByTypeAndMedia(MediaAsset asset, java.lang.String type, java.lang.String media)
Gets media object by type and media.- Parameters:
asset- the assettype- the typemedia- the media- Returns:
- the media object by type and media
-
-