Class PatternBean

java.lang.Object
mc.core.system.base.BaseBean
mc.core.domain.base.dobj.pattern.PatternBean

@ApplicationScoped public class PatternBean extends mc.core.system.base.BaseBean
handles reading, validating and writing of pattern
  • Method Details

    • instance

      public static PatternBean instance()
      factory method for use in non-CDI classes
    • setTokens

      public void setTokens(DVPattern dataValue, List<PatternBean.TokenInfo> tokens)
    • getDisplay

      public String getDisplay(DVPattern dataValue, Locale locale)
    • validate

      public void validate(DVPattern dataValue) throws mc.core.system.validation.ValidationException
      patternValue matches dataType.pattern?
      Throws:
      mc.core.system.validation.ValidationException
    • validatePatternString

      public void validatePatternString(String patternString, String dtPatternDisplay) throws mc.core.system.validation.ValidationException
      check if the given patternString (DTPattern.getPattern()) has a valid format.
      Parameters:
      patternString - mandatory
      dtPatternDisplay - mandatory, display of DTPattern to which given patternString belongs, for error messages
      Throws:
      mc.core.system.validation.ValidationException
    • isBoundariesType

      public DTPattern isBoundariesType(Attribute attribute)
      Parameters:
      attribute - mandatory
      Returns:
      DTPattern if attribute's datatype is DTPattern and if it has a boundaries pattern, otherwise null
    • getBoundariesValueClass

      public Class<? extends Number> getBoundariesValueClass(DTPattern dtPattern)
      Boundaries types must have 2 numeric tokens, with formatting that makes them either both Integer or both Double
      Returns:
      Integer.class or Double.class if prerequisites are fulfilled, otherwise null
    • getTokens

      public List<DTPattern.PatternToken> getTokens(DTPattern dtPattern)
      Parameters:
      dtPattern - mandatory
      Returns:
      the list of tokens that make up this DTPattern's pattern
    • getTokenValues

      public List<PatternBean.TokenInfo> getTokenValues(DVPattern dvPattern, Locale locale)
      Parameters:
      dvPattern - mandatory
      locale - optional, default is content locale
      Returns:
      list of TokenInfo containing the token and the corresponding value. Use methods PatternBean.TokenInfo.getValueString(), PatternBean.TokenInfo.getValueDouble() and PatternBean.TokenInfo.getValueUnit(List) to retrieve the value by type. For use in GUI
    • getNumericValues

      public List<Double> getNumericValues(DVPattern dvPattern)
    • setValues

      public void setValues(DVPattern dvPattern, Attribute attribute, List<Object> values) throws mc.core.system.validation.ValidationException
      creates the patternValue-String that holds the tokens and the dynamic values and sets it to given dvPattern. Static values are only set in pattern or DTPattern.
      Parameters:
      dvPattern - must contain dataType DTPattern with pattern fitting with given values
      attribute - for which DVPattern is set, for display of error message
      values - list containing the non-static values (T,N,U) in the order given by pattern. Null values are not allowed.
      Throws:
      mc.core.system.validation.ValidationException