Class OrgModelTools
- java.lang.Object
-
- de.aristaflow.adept2.model.orgmodel.OrgModelTools
-
public final class OrgModelTools extends Object
This class contains static methods to provide some common functionality in the context of the Org Model and org policies / staff assignment rules.- Author:
- Patrick Schmidt
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Date
createDate(long timeInMillis)
Creates a date from the given time in milliseconds, i.e. hours, minutes, seconds and milliseconds will be set to0
; only year, month and day remain.static DateFormat
createDateFormat()
Returns a newDateFormat
to handle dates (w/o time) in the formatyyyy-MM-dd
.static DateFormat
createDisplayTimestampFormat(TimeZone tz)
Returns a newDateFormat
to handle date + time (= timestamp) in the formatyyyy-MM-dd HH:mm:ss
.static Date
createTime(long timeInMillis)
Creates a time from the given time in milliseconds, i.e. the year will be set to1970
, month to0
, day to1
, milliseconds to0
; while hours, minutes and seconds remain.static DateFormat
createTimeFormat()
Returns a newDateFormat
to handle times (w/o date) in the formatHH:mm:ss
.static Date
createTimestamp(long timeInMillis)
Creates a timestamp from the given time in milliseconds, i.e. milliseconds will be set to0
; all other values remain.static DateFormat
createTimestampFormat()
Returns a newDateFormat
to handle date + time (= timestamp) in the formatyyyy-MM-dd HH:mm:ss
.static boolean
isValidAttributeName(String attrName)
Returns whether the given string is a valid attribute name for entity types.static boolean
parameterUsedAsValue(ParameterRefReplacer replacer)
Returns if the current parameter reference in the specified replacer is used as placeholder for a value.static String
toPolicyToken(Object value)
Formats the value object to a string that can be used in OrgPolicies.
-
-
-
Method Detail
-
isValidAttributeName
public static boolean isValidAttributeName(String attrName)
Returns whether the given string is a valid attribute name for entity types. A valid attribute name can contain letters (a to z), number (0 to 9) and the underscore (_). However, numbers are not allowed as first character!- Parameters:
attrName
- the string to be tested- Returns:
- whether the given string is a valid attribute name
-
createDate
public static Date createDate(long timeInMillis)
Creates a date from the given time in milliseconds, i.e. hours, minutes, seconds and milliseconds will be set to0
; only year, month and day remain.- Parameters:
timeInMillis
- time in milliseconds to create the date from- Returns:
- a date from the given time in milliseconds
-
createTime
public static Date createTime(long timeInMillis)
Creates a time from the given time in milliseconds, i.e. the year will be set to1970
, month to0
, day to1
, milliseconds to0
; while hours, minutes and seconds remain.- Parameters:
timeInMillis
- time in milliseconds to create the time from- Returns:
- a time from the given time in milliseconds
-
createTimestamp
public static Date createTimestamp(long timeInMillis)
Creates a timestamp from the given time in milliseconds, i.e. milliseconds will be set to0
; all other values remain.- Parameters:
timeInMillis
- time in milliseconds to create the timestamp from- Returns:
- a timestamp from the given time in milliseconds
-
createDateFormat
public static DateFormat createDateFormat()
Returns a newDateFormat
to handle dates (w/o time) in the formatyyyy-MM-dd
. The assumed time zone is UTC.- Returns:
- a new
DateFormat
to handle dates (w/o time)
-
createTimeFormat
public static DateFormat createTimeFormat()
Returns a newDateFormat
to handle times (w/o date) in the formatHH:mm:ss
. The assumed time zone is UTC.- Returns:
- a new
DateFormat
to handle times (w/o date)
-
createTimestampFormat
public static DateFormat createTimestampFormat()
Returns a newDateFormat
to handle date + time (= timestamp) in the formatyyyy-MM-dd HH:mm:ss
. The assumed time zone is UTC.- Returns:
- a new
DateFormat
to handle date + time
-
createDisplayTimestampFormat
public static DateFormat createDisplayTimestampFormat(TimeZone tz)
Returns a newDateFormat
to handle date + time (= timestamp) in the formatyyyy-MM-dd HH:mm:ss
.- Parameters:
tz
- the time zone to be used- Returns:
- a new
DateFormat
to handle date + time
-
toPolicyToken
public static String toPolicyToken(Object value)
Formats the value object to a string that can be used in OrgPolicies. A string value e.g. will be surrounded by single quotes:s_simple_string
will result in's_simple_string'
.- Parameters:
value
- the value object to be formatted- Returns:
- the value object formatted as a string that can be used in OrgPolicies
-
parameterUsedAsValue
public static boolean parameterUsedAsValue(ParameterRefReplacer replacer)
Returns if the current parameter reference in the specified replacer is used as placeholder for a value. Otherwise it's used as placeholder for an entity expression.- Parameters:
replacer
- the used replacer- Returns:
true
if the current parameter reference in the specified formatter is used as a value;false
if it's used as an entity expression
-
-