Class JaloTools


  • public abstract class JaloTools
    extends java.lang.Object
    tool package for useful jalo methods
    • Constructor Summary

      Constructors 
      Constructor Description
      JaloTools()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static PriceValue convertPriceIfNecessary​(PriceValue pv, boolean toNet, Currency toCurrency, java.util.Collection taxValues)
      converts a PriceValue object into a double matching the target currency and net/gross - state if necessary.
      static java.lang.String encodeJAVA​(java.lang.String input)
      Encodes JAVA entities ('\"`, '\'', '\n').
      static void exportSystem​(JaloSession session, org.znerd.xmlenc.XMLOutputter xmlDef, java.lang.String extensionName)  
      static void exportTypeLocalization​(java.util.Collection types, java.io.Writer wr, java.lang.String extensionName, boolean ignoreExtensionName)
      export all localisations for the given extension and type
      static void exportTypeLocalizations​(JaloSession jaloSession, java.io.Writer wr, java.lang.String extensionName)
      exports all type localisations (AtomicType, CollectionType, EnumerationType, MapType, RelationType, ItemTypesOrdered) for a given extension
      static boolean getTypedPrimitiveBoolean​(java.lang.Object value, boolean defValue)
      Returns primitive boolean value from Boolean value object
      static byte getTypedPrimitiveByte​(java.lang.Object value, byte defValue)
      Returns primitive byte value from Byte value object
      static char getTypedPrimitiveChar​(java.lang.Object value, char defValue)
      Returns primitive char value from Character value object
      static double getTypedPrimitiveDouble​(java.lang.Object value, double defValue)
      Returns primitive double value from Dobule value object
      static float getTypedPrimitiveFloat​(java.lang.Object value, float defValue)
      Returns primitive float value from Float value object
      static int getTypedPrimitiveInteger​(java.lang.Object value, int defValue)
      Returns primitive int value from Integer value object
      static long getTypedPrimitiveLong​(java.lang.Object value, long defValue)
      Returns primitive long value from Long value object
      static short getTypedPrimitiveShort​(java.lang.Object value, short defValue)
      Returns primitive short value from Short value object
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JaloTools

        public JaloTools()
    • Method Detail

      • getTypedPrimitiveDouble

        public static double getTypedPrimitiveDouble​(java.lang.Object value,
                                                     double defValue)
                                              throws JaloInvalidParameterException
        Returns primitive double value from Dobule value object
        Parameters:
        value - - Double object
        defValue - - if value is null then it returns this defValue
        Returns:
        double value
        Throws:
        JaloInvalidParameterException - if value object isnt't instance of Double
      • getTypedPrimitiveBoolean

        public static boolean getTypedPrimitiveBoolean​(java.lang.Object value,
                                                       boolean defValue)
                                                throws JaloInvalidParameterException
        Returns primitive boolean value from Boolean value object
        Parameters:
        value - - Boolean object
        defValue - - if value is null then it returns this defValue
        Returns:
        boolean value
        Throws:
        JaloInvalidParameterException - if value object isnt't instance of Boolean
      • getTypedPrimitiveLong

        public static long getTypedPrimitiveLong​(java.lang.Object value,
                                                 long defValue)
                                          throws JaloInvalidParameterException
        Returns primitive long value from Long value object
        Parameters:
        value - - Long object
        defValue - - if value is null then it returns this defValue
        Returns:
        long value
        Throws:
        JaloInvalidParameterException - if value object isnt't instance of Long
      • getTypedPrimitiveInteger

        public static int getTypedPrimitiveInteger​(java.lang.Object value,
                                                   int defValue)
                                            throws JaloInvalidParameterException
        Returns primitive int value from Integer value object
        Parameters:
        value - - Integer object
        defValue - - if value is null then it returns this defValue
        Returns:
        int value
        Throws:
        JaloInvalidParameterException - if value object isnt't instance of Integer
      • getTypedPrimitiveByte

        public static byte getTypedPrimitiveByte​(java.lang.Object value,
                                                 byte defValue)
                                          throws JaloInvalidParameterException
        Returns primitive byte value from Byte value object
        Parameters:
        value - - Byte object
        defValue - - if value is null then it returns this defValue
        Returns:
        byte value
        Throws:
        JaloInvalidParameterException - if value object isnt't instance of Byte
      • getTypedPrimitiveChar

        public static char getTypedPrimitiveChar​(java.lang.Object value,
                                                 char defValue)
                                          throws JaloInvalidParameterException
        Returns primitive char value from Character value object
        Parameters:
        value - - Character object
        defValue - - if value is null then it returns this defValue
        Returns:
        char value
        Throws:
        JaloInvalidParameterException - if value object isnt't instance of Character
      • getTypedPrimitiveFloat

        public static float getTypedPrimitiveFloat​(java.lang.Object value,
                                                   float defValue)
                                            throws JaloInvalidParameterException
        Returns primitive float value from Float value object
        Parameters:
        value - - Float object
        defValue - - if value is null then it returns this defValue
        Returns:
        float value
        Throws:
        JaloInvalidParameterException - if value object isnt't instance of Float
      • getTypedPrimitiveShort

        public static short getTypedPrimitiveShort​(java.lang.Object value,
                                                   short defValue)
                                            throws JaloInvalidParameterException
        Returns primitive short value from Short value object
        Parameters:
        value - - Short object
        defValue - - if value is null then it returns this defValue
        Returns:
        short value
        Throws:
        JaloInvalidParameterException - if value object isnt't instance of Short
      • convertPriceIfNecessary

        public static PriceValue convertPriceIfNecessary​(PriceValue pv,
                                                         boolean toNet,
                                                         Currency toCurrency,
                                                         java.util.Collection taxValues)
        converts a PriceValue object into a double matching the target currency and net/gross - state if necessary. this is the case when the given price value has a different net/gross flag or different currency.
        Parameters:
        pv - the base price to convert
        toNet - the target net/gross state
        toCurrency - the target currency
        taxValues - the collection of tax values which apply to this price
        Returns:
        a new PriceValue containing the converted price or pv in case no conversion was necessary
      • exportSystem

        public static void exportSystem​(JaloSession session,
                                        org.znerd.xmlenc.XMLOutputter xmlDef,
                                        java.lang.String extensionName)
      • exportTypeLocalizations

        public static void exportTypeLocalizations​(JaloSession jaloSession,
                                                   java.io.Writer wr,
                                                   java.lang.String extensionName)
        exports all type localisations (AtomicType, CollectionType, EnumerationType, MapType, RelationType, ItemTypesOrdered) for a given extension
        Parameters:
        jaloSession - the (current) jaloSession
        wr - the output writer
        extensionName - the name of the extension which should be exported, for core the String is null
      • exportTypeLocalization

        public static void exportTypeLocalization​(java.util.Collection types,
                                                  java.io.Writer wr,
                                                  java.lang.String extensionName,
                                                  boolean ignoreExtensionName)
        export all localisations for the given extension and type
        Parameters:
        types - the type
        wr - the output writer
        extensionName - the name of the extension which should be exported, for core the String is null
        ignoreExtensionName -
      • encodeJAVA

        public static final java.lang.String encodeJAVA​(java.lang.String input)
        Encodes JAVA entities ('\"`, '\'', '\n'). This prevents from java script errors.