Package com.saperion.ngc.util
Class FieldUtil
- java.lang.Object
-
- com.saperion.ngc.util.FieldUtil
-
public final class FieldUtil extends java.lang.Object
Utility class for common operations on fields.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FieldUtil.ResolvedFieldLink
A resolved field-link.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
copyValue(IntelligentField fromField, IntelligentField toField)
Copies the value from one field to another.static java.lang.String
generateId(com.saperion.ngc.iform.xml.EditFieldType field)
Generates a unique id for anEditFieldType
.static java.lang.Object
getFieldValue(IntelligentField fromField)
Returns the value from the specified field as object.static java.lang.String
getFormatPatternForDecimalFields(com.saperion.ngc.iform.xml.EditFieldType field)
Returns a pattern-string that can be used to format a ZK NumberInputElement.static java.text.DecimalFormat
getFormatterForDecimalFields(com.saperion.ngc.iform.xml.EditFieldType field)
Creates a newDecimalFormat
instance for use in the specified field.static com.saperion.jni.SaJNIValue
getJniValueFromLookupField(LookupTextField field)
Create a SaJNIValue from the value that is entered in the specified lookup-field.static com.saperion.jni.SaJNIValue[]
getJniValuesFromLookupField(LookupTextField field)
Create a SaJNIValue from the value that is entered in the specified lookup-field.static java.lang.Object
getLookupValue(LookupTextField field, java.lang.String column)
Gets the value of the specified column of the specified lookup-field..static IntelligentFormView
getParentForm(org.zkoss.zk.ui.Component formComponent)
Returns the parent form of the specified component or null, if the component is not part of a form.static boolean
isBooleanField(IntelligentField field)
static boolean
isDateField(IntelligentField field)
static boolean
isDoubleField(IntelligentField field)
static boolean
isIntegerField(IntelligentField field)
static boolean
isMultivalueField(IntelligentField field)
static boolean
isStringField(IntelligentField field)
static FieldUtil.ResolvedFieldLink
resolveFieldLink(java.lang.String link, IntelligentFormView form)
Resolves a field link.
-
-
-
Method Detail
-
copyValue
public static void copyValue(IntelligentField fromField, IntelligentField toField)
Copies the value from one field to another. This method throws an IllegalArgumentException if the field-types of the two fields do not match.- Parameters:
fromField
- source-fieldtoField
- target-field
-
getFieldValue
public static java.lang.Object getFieldValue(IntelligentField fromField)
Returns the value from the specified field as object.- Parameters:
fromField
- source-field- Returns:
- field value as object
-
getJniValueFromLookupField
public static com.saperion.jni.SaJNIValue getJniValueFromLookupField(LookupTextField field)
Create a SaJNIValue from the value that is entered in the specified lookup-field. Will throw an IllegalArgumentException if the value could not be handled.- Parameters:
field
- the field- Returns:
- SaJNIValue with proper type and value
-
getJniValuesFromLookupField
public static com.saperion.jni.SaJNIValue[] getJniValuesFromLookupField(LookupTextField field)
Create a SaJNIValue from the value that is entered in the specified lookup-field. Will throw an IllegalArgumentException if the value could not be handled.- Parameters:
field
- the field- Returns:
- SaJNIValue with proper type and value
-
getLookupValue
public static java.lang.Object getLookupValue(LookupTextField field, java.lang.String column)
Gets the value of the specified column of the specified lookup-field..- Parameters:
field
- the fieldcolumn
- the column- Returns:
- the lookup value
-
resolveFieldLink
public static FieldUtil.ResolvedFieldLink resolveFieldLink(java.lang.String link, IntelligentFormView form)
Resolves a field link.- Parameters:
link
- the link as Stringform
- the form parent form of the field that contains the link- Returns:
- the resolved field link
-
generateId
public static java.lang.String generateId(com.saperion.ngc.iform.xml.EditFieldType field)
Generates a unique id for anEditFieldType
.- Parameters:
field
- the field to generate an id for- Returns:
- a unique id for field
-
getParentForm
public static IntelligentFormView getParentForm(org.zkoss.zk.ui.Component formComponent)
Returns the parent form of the specified component or null, if the component is not part of a form.- Parameters:
formComponent
- component to get the parent form for- Returns:
- parent form or null
-
getFormatterForDecimalFields
public static java.text.DecimalFormat getFormatterForDecimalFields(com.saperion.ngc.iform.xml.EditFieldType field)
Creates a newDecimalFormat
instance for use in the specified field. The formatter will be localized for the current locale and will contain the currency- symbol for the specified field (if the field is a currency-field).
This method can only be used from within ZK-context.- Parameters:
field
- field to create the formatterfor- Returns:
- new
DecimalFormat
-
getFormatPatternForDecimalFields
public static java.lang.String getFormatPatternForDecimalFields(com.saperion.ngc.iform.xml.EditFieldType field)
Returns a pattern-string that can be used to format a ZK NumberInputElement. The pattern is based on aDecimalFormat
but uses the actual currency-symbol instead of the currency-symbol-placeholder ยค (seeDecimalFormat
).- Parameters:
field
- field to create the pattern for- Returns:
- pattern-string
-
isDateField
public static boolean isDateField(IntelligentField field)
- Parameters:
field
- field to check- Returns:
- true if this field contains values of type
Date
.
-
isStringField
public static boolean isStringField(IntelligentField field)
- Parameters:
field
- field to check- Returns:
- true if this field contains values of type
String
.
-
isIntegerField
public static boolean isIntegerField(IntelligentField field)
- Parameters:
field
- field to check- Returns:
- true if this field contains values of type
Integer
.
-
isBooleanField
public static boolean isBooleanField(IntelligentField field)
- Parameters:
field
- field to check- Returns:
- true if this field contains values of type
Boolean
.
-
isDoubleField
public static boolean isDoubleField(IntelligentField field)
- Parameters:
field
- field to check- Returns:
- true if this field contains values of type
Double
.
-
isMultivalueField
public static boolean isMultivalueField(IntelligentField field)
- Parameters:
field
- field to check- Returns:
- true if this field is a multivalue-field
-
-