Class DescriptorUtil


  • public class DescriptorUtil
    extends java.lang.Object
    Utility class for parsing and combining descriptor settings.

    Created at 31.12.2008 09:28:28
    Since:
    0.5.7
    Author:
    Volker Bergmann
    • Method Detail

      • convertType

        public static java.lang.Object convertType​(java.lang.Object sourceValue,
                                                   SimpleTypeDescriptor targetType)
        Convert type object.
        Parameters:
        sourceValue - the source value
        targetType - the target type
        Returns:
        the object
      • isWrappedSimpleType

        public static boolean isWrappedSimpleType​(ComplexTypeDescriptor complexType)
        Is wrapped simple type boolean.
        Parameters:
        complexType - the complex type
        Returns:
        the boolean
      • createConvertingGenerator

        public static Generator<?> createConvertingGenerator​(TypeDescriptor descriptor,
                                                             Generator<?> generator,
                                                             BeneratorContext context)
        Create converting generator generator.
        Parameters:
        descriptor - the descriptor
        generator - the generator
        context - the context
        Returns:
        the generator
      • getGeneratorByName

        public static Generator<?> getGeneratorByName​(TypeDescriptor descriptor,
                                                      BeneratorContext context)
        Gets generator by name.
        Parameters:
        descriptor - the descriptor
        context - the context
        Returns:
        the generator by name
      • getValidator

        public static com.rapiddweller.common.Validator getValidator​(java.lang.String validatorSpec,
                                                                     BeneratorContext context)
        Gets validator.
        Parameters:
        validatorSpec - the validator spec
        context - the context
        Returns:
        the validator
      • getConverter

        public static com.rapiddweller.common.Converter getConverter​(java.lang.String converterSpec,
                                                                     BeneratorContext context)
        Gets converter.
        Parameters:
        converterSpec - the converter spec
        context - the context
        Returns:
        the converter
      • getPatternAsDateFormat

        public static java.text.DateFormat getPatternAsDateFormat​(TypeDescriptor descriptor)
        Gets pattern as date format.
        Parameters:
        descriptor - the descriptor
        Returns:
        the pattern as date format
      • getUniqueness

        public static Uniqueness getUniqueness​(InstanceDescriptor descriptor,
                                               BeneratorContext context)
        Gets uniqueness.
        Parameters:
        descriptor - the descriptor
        context - the context
        Returns:
        the uniqueness
      • isUnique

        public static boolean isUnique​(InstanceDescriptor descriptor,
                                       BeneratorContext context)
        Is unique boolean.
        Parameters:
        descriptor - the descriptor
        context - the context
        Returns:
        the boolean
      • getSeparator

        public static char getSeparator​(TypeDescriptor descriptor,
                                        BeneratorContext context)
        Gets separator.
        Parameters:
        descriptor - the descriptor
        context - the context
        Returns:
        the separator
      • getCount

        public static com.rapiddweller.script.Expression<java.lang.Long> getCount​(InstanceDescriptor descriptor)
        Calculates the 'count' value.
        Parameters:
        descriptor - the descriptor
        Returns:
        the 'count' value. If a global 'maxCount' was set too, it returns the minimum of 'count' and 'maxCount'. If no 'count' value was specified, it returns null.
      • getMinCount

        public static com.rapiddweller.script.Expression<java.lang.Long> getMinCount​(InstanceDescriptor descriptor)
        Gets min count.
        Parameters:
        descriptor - the descriptor
        Returns:
        the min count
      • getMinCount

        public static com.rapiddweller.script.Expression<java.lang.Long> getMinCount​(InstanceDescriptor descriptor,
                                                                                     java.lang.Long defaultMin)
        Gets min count.
        Parameters:
        descriptor - the descriptor
        defaultMin - the default min
        Returns:
        the min count
      • getMaxCount

        public static com.rapiddweller.script.Expression<java.lang.Long> getMaxCount​(InstanceDescriptor descriptor,
                                                                                     java.lang.Long defaultMax)
        Gets max count.
        Parameters:
        descriptor - the descriptor
        defaultMax - the default max
        Returns:
        the max count
      • getCountGranularity

        public static com.rapiddweller.script.Expression<java.lang.Long> getCountGranularity​(InstanceDescriptor descriptor)
        Gets count granularity.
        Parameters:
        descriptor - the descriptor
        Returns:
        the count granularity
      • createStringScriptConverter

        public static com.rapiddweller.common.Converter<java.lang.String,​java.lang.String> createStringScriptConverter​(BeneratorContext context)
        Create string script converter converter.
        Parameters:
        context - the context
        Returns:
        the converter
      • createDynamicCountGenerator

        public static Generator<java.lang.Long> createDynamicCountGenerator​(InstanceDescriptor descriptor,
                                                                            java.lang.Long defaultMin,
                                                                            java.lang.Long defaultMax,
                                                                            boolean resetToMin,
                                                                            BeneratorContext context)
        Create dynamic count generator generator.
        Parameters:
        descriptor - the descriptor
        defaultMin - the default min
        defaultMax - the default max
        resetToMin - the reset to min
        context - the context
        Returns:
        the generator
      • getNumberDetail

        public static <T extends java.lang.Number> T getNumberDetail​(SimpleTypeDescriptor descriptor,
                                                                     java.lang.String detailName,
                                                                     java.lang.Class<T> targetType)
        Gets number detail.
        Type Parameters:
        T - the type parameter
        Parameters:
        descriptor - the descriptor
        detailName - the detail name
        targetType - the target type
        Returns:
        the number detail
      • parseComponentConfig

        public static void parseComponentConfig​(org.w3c.dom.Element element,
                                                TypeDescriptor type,
                                                BeneratorContext context)
        Parse component config.
        Parameters:
        element - the element
        type - the type
        context - the context
      • isNullable

        public static boolean isNullable​(InstanceDescriptor descriptor,
                                         BeneratorContext context)
        Is nullable boolean.
        Parameters:
        descriptor - the descriptor
        context - the context
        Returns:
        the boolean
      • shouldNullifyEachNullable

        public static boolean shouldNullifyEachNullable​(InstanceDescriptor descriptor,
                                                        BeneratorContext context)
        Should nullify each nullable boolean.
        Parameters:
        descriptor - the descriptor
        context - the context
        Returns:
        the boolean
      • wrapWithProxy

        protected static <T> Generator<T> wrapWithProxy​(Generator<T> generator,
                                                        TypeDescriptor descriptor)
        Wrap with proxy generator.
        Type Parameters:
        T - the type parameter
        Parameters:
        generator - the generator
        descriptor - the descriptor
        Returns:
        the generator
      • processCyclic

        public static <T> Generator<T> processCyclic​(Generator<T> generator,
                                                     TypeDescriptor descriptor)
        Process cyclic generator.
        Type Parameters:
        T - the type parameter
        Parameters:
        generator - the generator
        descriptor - the descriptor
        Returns:
        the generator
      • processOffset

        public static <T> Generator<T> processOffset​(Generator<T> generator,
                                                     TypeDescriptor descriptor)
        Process offset generator.
        Type Parameters:
        T - the type parameter
        Parameters:
        generator - the generator
        descriptor - the descriptor
        Returns:
        the generator
      • getOffset

        protected static int getOffset​(TypeDescriptor descriptor)
        Gets offset.
        Parameters:
        descriptor - the descriptor
        Returns:
        the offset
      • getMinLength

        protected static java.lang.Integer getMinLength​(SimpleTypeDescriptor descriptor)
        Gets min length.
        Parameters:
        descriptor - the descriptor
        Returns:
        the min length
      • getMaxLength

        protected static java.lang.Integer getMaxLength​(SimpleTypeDescriptor descriptor,
                                                        DefaultsProvider defaultsProvider)
        Gets max length.
        Parameters:
        descriptor - the descriptor
        defaultsProvider - the defaults provider
        Returns:
        the max length
      • createNullQuotaOneGenerator

        public static Generator<?> createNullQuotaOneGenerator​(InstanceDescriptor descriptor,
                                                               BeneratorContext context)
        Create null quota one generator generator.
        Parameters:
        descriptor - the descriptor
        context - the context
        Returns:
        the generator
      • deriveType

        public static TypeDescriptor deriveType​(java.lang.String name,
                                                TypeDescriptor parentType)
        Derive type type descriptor.
        Parameters:
        name - the name
        parentType - the parent type
        Returns:
        the type descriptor