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 DatecreateDate(long timeInMillis)Creates a date from the given time in milliseconds, i.e.static DateFormatcreateDateFormat()Returns a newDateFormatto handle dates (w/o time) in the formatyyyy-MM-dd.static DateFormatcreateDisplayTimestampFormat(TimeZone tz)Returns a newDateFormatto handle date + time (= timestamp) in the formatyyyy-MM-dd HH:mm:ss.static DatecreateTime(long timeInMillis)Creates a time from the given time in milliseconds, i.e.static DateFormatcreateTimeFormat()Returns a newDateFormatto handle times (w/o date) in the formatHH:mm:ss.static DatecreateTimestamp(long timeInMillis)Creates a timestamp from the given time in milliseconds, i.e.static DateFormatcreateTimestampFormat()Returns a newDateFormatto handle date + time (= timestamp) in the formatyyyy-MM-dd HH:mm:ss.static booleanisValidAttributeName(String attrName)Returns whether the given string is a valid attribute name for entity types.static booleanparameterUsedAsValue(ParameterRefReplacer replacer)Returns if the current parameter reference in the specified replacer is used as placeholder for a value.static StringtoPolicyToken(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 newDateFormatto handle dates (w/o time) in the formatyyyy-MM-dd. The assumed time zone is UTC.- Returns:
- a new
DateFormatto handle dates (w/o time)
-
createTimeFormat
public static DateFormat createTimeFormat()
Returns a newDateFormatto handle times (w/o date) in the formatHH:mm:ss. The assumed time zone is UTC.- Returns:
- a new
DateFormatto handle times (w/o date)
-
createTimestampFormat
public static DateFormat createTimestampFormat()
Returns a newDateFormatto handle date + time (= timestamp) in the formatyyyy-MM-dd HH:mm:ss. The assumed time zone is UTC.- Returns:
- a new
DateFormatto handle date + time
-
createDisplayTimestampFormat
public static DateFormat createDisplayTimestampFormat(TimeZone tz)
Returns a newDateFormatto handle date + time (= timestamp) in the formatyyyy-MM-dd HH:mm:ss.- Parameters:
tz- the time zone to be used- Returns:
- a new
DateFormatto 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_stringwill 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:
trueif the current parameter reference in the specified formatter is used as a value;falseif it's used as an entity expression
-
-