Class Utils


  • public class Utils
    extends java.lang.Object
    Contains some useful methods...
    Version:
    1.0, 02.09.2007
    Author:
    ...
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  Utils.SpiralVisitor<T>
      Helper class for spiralPattern
    • Constructor Summary

      Constructors 
      Constructor Description
      Utils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String decimalToHexadecimal​(long decimal)
      Returns the hex value of a decimal number
      static java.lang.String escapeXML​(java.lang.Object xmlString)
      Diese Methode ersetzt in einem XML String alle < und > durch &lt; und &gt;.
      static java.lang.String escapeXML​(java.lang.String xmlString)
      Diese Methode ersetzt in einem XML String alle < und > durch &lt; und &gt;.
      static boolean getBoolValue​(java.lang.String value, boolean defaultValue)
      Returns the boolean value of a string.
      static java.lang.String getCData​(org.w3c.dom.Element root)
      Returns al character data inside a root element
      static org.w3c.dom.Element getChildNode​(org.w3c.dom.Element root)
      Returns the first child node of a root node
      static org.w3c.dom.Element getChildNode​(org.w3c.dom.Element root, java.lang.String name)
      Returns the first child node of a root node with the given name
      static java.util.List<org.w3c.dom.Element> getChildNodes​(org.w3c.dom.Element root)
      Returns all XML child nodes of a root node.
      static java.util.List<org.w3c.dom.Element> getChildNodes​(org.w3c.dom.Element root, java.lang.String name)
      Returns all XML child nodes of a root node with the given name
      static java.lang.String getColor​(java.awt.Color color)
      This method returns a String object coresponding to the format: #RRGGBB oder RRGGBB
      static java.awt.Color getColor​(java.lang.String colorAsString)
      This method returns a Color object coresponding to the format: #RRGGBB oder RRGGBB
      static int getIntValue​(java.lang.Integer integer, int defaultValue)
      Returns the value of an Integer, or a default value if it is null.
      static int getIntValue​(java.lang.String value)
      Parses a string into a int, if possible otherwise it returns 0.
      static long getLongValue​(java.lang.String value)
      Parses a string into a long, if possible otherwise it returns 0d.
      static int hexadecimalToDecimal​(java.lang.String hexadecimal)
      Returns the decimal value of a hex number
      static boolean is​(java.lang.Boolean bool)
      Checks, if a Boolean is true (and not null)
      static boolean isEmpty​(java.lang.Number[] list)  
      static boolean isEmpty​(java.lang.Object object)  
      static boolean isEmpty​(java.lang.String string)  
      static boolean isEmpty​(java.lang.String[] list)  
      static boolean isEmpty​(java.util.Date date)  
      static boolean isEmpty​(java.util.HashMap<?,​?> map)  
      static boolean isEmpty​(java.util.List<org.w3c.dom.Element> list)  
      static boolean isEmpty​(org.w3c.dom.NodeList list)  
      static boolean isNull​(java.lang.Integer number)
      Diese Methode prüft, ob eine Zahl null oder 0 ist.
      static boolean isNull​(java.lang.Long number)
      Diese Methode prüft, ob eine Zahl null oder 0 ist.
      static boolean isNull​(java.math.BigDecimal number)
      Diese Methode prüft, ob eine Zahl null oder 0 ist.
      static boolean isNull​(java.util.Date date)
      Diese Methode prüft, ob eine Zahl null oder 0 ist.
      static java.lang.String notNullString​(java.lang.Object string)
      Returns a never null string.
      static java.lang.String notNullString​(java.lang.Object object, java.lang.String nullString)
      Returns a never null string.
      static <T> T spiralPattern​(CoordinateID center, int maxDist, Utils.SpiralVisitor<T> visitor)
      Create hexagonal coordinates in a spiral pattern around center.
      static java.util.Date toDate​(java.lang.String date)
      Returns the date in the form "yyyy-MM-dd HH:mm:ss"
      static java.lang.String toDayAndTime​(java.util.Date date)
      Returns the date in the form "DD.MM.YYYY HH:MM:ss"
      • Methods inherited from class java.lang.Object

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

      • Utils

        public Utils()
    • Method Detail

      • is

        public static boolean is​(java.lang.Boolean bool)
        Checks, if a Boolean is true (and not null)
      • getIntValue

        public static int getIntValue​(java.lang.String value)
        Parses a string into a int, if possible otherwise it returns 0.
      • getLongValue

        public static long getLongValue​(java.lang.String value)
        Parses a string into a long, if possible otherwise it returns 0d.
      • getIntValue

        public static int getIntValue​(java.lang.Integer integer,
                                      int defaultValue)
        Returns the value of an Integer, or a default value if it is null.
        Parameters:
        integer -
        defaultValue -
        Returns:
        defaultValue if integer==0, otherwise integer.intValue()
      • getBoolValue

        public static boolean getBoolValue​(java.lang.String value,
                                           boolean defaultValue)
        Returns the boolean value of a string.
      • isEmpty

        public static boolean isEmpty​(java.lang.Object object)
        Parameters:
        object -
        Returns:
        true if object is null
      • isEmpty

        public static boolean isEmpty​(java.util.Date date)
        Parameters:
        date -
        Returns:
        true if date is null or time is 0
      • isEmpty

        public static boolean isEmpty​(java.lang.String string)
        Parameters:
        string -
        Returns:
        true if string is null or equals ""
      • isEmpty

        public static boolean isEmpty​(java.util.List<org.w3c.dom.Element> list)
        Parameters:
        list -
        Returns:
        true if list is null or empty
      • isEmpty

        public static boolean isEmpty​(java.util.HashMap<?,​?> map)
        Parameters:
        map -
        Returns:
        true if map is null or empty
      • isEmpty

        public static boolean isEmpty​(org.w3c.dom.NodeList list)
        Parameters:
        list -
        Returns:
        true if list is null or empty
      • isEmpty

        public static boolean isEmpty​(java.lang.Number[] list)
        Parameters:
        list -
        Returns:
        true if list is null or empty
      • isEmpty

        public static boolean isEmpty​(java.lang.String[] list)
        Parameters:
        list -
        Returns:
        true if list is null or empty
      • isNull

        public static boolean isNull​(java.lang.Long number)
        Diese Methode prüft, ob eine Zahl null oder 0 ist.
      • isNull

        public static boolean isNull​(java.util.Date date)
        Diese Methode prüft, ob eine Zahl null oder 0 ist.
      • isNull

        public static boolean isNull​(java.lang.Integer number)
        Diese Methode prüft, ob eine Zahl null oder 0 ist.
      • isNull

        public static boolean isNull​(java.math.BigDecimal number)
        Diese Methode prüft, ob eine Zahl null oder 0 ist.
      • notNullString

        public static java.lang.String notNullString​(java.lang.Object string)
        Returns a never null string.
      • notNullString

        public static java.lang.String notNullString​(java.lang.Object object,
                                                     java.lang.String nullString)
        Returns a never null string.
      • escapeXML

        public static java.lang.String escapeXML​(java.lang.Object xmlString)
        Diese Methode ersetzt in einem XML String alle < und > durch &lt; und &gt;.
      • escapeXML

        public static java.lang.String escapeXML​(java.lang.String xmlString)
        Diese Methode ersetzt in einem XML String alle < und > durch &lt; und &gt;.
      • getChildNodes

        public static java.util.List<org.w3c.dom.Element> getChildNodes​(org.w3c.dom.Element root)
        Returns all XML child nodes of a root node.
      • getChildNodes

        public static java.util.List<org.w3c.dom.Element> getChildNodes​(org.w3c.dom.Element root,
                                                                        java.lang.String name)
        Returns all XML child nodes of a root node with the given name
      • getChildNode

        public static org.w3c.dom.Element getChildNode​(org.w3c.dom.Element root,
                                                       java.lang.String name)
        Returns the first child node of a root node with the given name
      • getChildNode

        public static org.w3c.dom.Element getChildNode​(org.w3c.dom.Element root)
        Returns the first child node of a root node
      • getCData

        public static java.lang.String getCData​(org.w3c.dom.Element root)
        Returns al character data inside a root element
      • getColor

        public static java.awt.Color getColor​(java.lang.String colorAsString)
        This method returns a Color object coresponding to the format: #RRGGBB oder RRGGBB
        Returns:
        A color oder null.
      • getColor

        public static java.lang.String getColor​(java.awt.Color color)
        This method returns a String object coresponding to the format: #RRGGBB oder RRGGBB
        Returns:
        A color oder null.
      • hexadecimalToDecimal

        public static int hexadecimalToDecimal​(java.lang.String hexadecimal)
        Returns the decimal value of a hex number
      • decimalToHexadecimal

        public static java.lang.String decimalToHexadecimal​(long decimal)
        Returns the hex value of a decimal number
      • toDayAndTime

        public static java.lang.String toDayAndTime​(java.util.Date date)
        Returns the date in the form "DD.MM.YYYY HH:MM:ss"
      • toDate

        public static java.util.Date toDate​(java.lang.String date)
        Returns the date in the form "yyyy-MM-dd HH:mm:ss"
      • spiralPattern

        public static <T> T spiralPattern​(CoordinateID center,
                                          int maxDist,
                                          Utils.SpiralVisitor<T> visitor)
        Create hexagonal coordinates in a spiral pattern around center. Call visitor.visit for each coordinate. Terminate when distance > maxDist or visitor.visit() returns true.
        Parameters:
        center -
        maxDist -
        visitor -