Class Utils

java.lang.Object
ucar.unidata.util.Utils

public class Utils extends Object
A collection of utilities
Author:
Jeff McWhirter
  • Field Details

    • JGREG

      public static int JGREG
      Returns the Julian day number that begins at noon of this day, Positive year signifies A.D., negative year B.C. Remember that the year after 1 B.C. was 1 A.D. ref : Numerical Recipes in C, 2nd ed., Cambridge University Press 1992
    • HALFSECOND

      public static double HALFSECOND
      _more_
  • Constructor Details

    • Utils

      public Utils()
  • Method Details

    • append

      public static Appendable append(Appendable sb, String s)
      _more_
      Parameters:
      sb - _more_
      s - _more_
      Returns:
      _more_
    • stringDefined

      public static boolean stringDefined(String s)
      _more_
      Parameters:
      s - _more_
      Returns:
      _more_
    • modifiedJulianToJulian

      public static double modifiedJulianToJulian(double modifiedJulian)
      _more_
      Parameters:
      modifiedJulian - _more_
      Returns:
      _more_
    • toJulian

      public static double toJulian(int[] ymd)
      _more_
      Parameters:
      ymd - _more_
      Returns:
      _more_
    • fromJulian

      public static int[] fromJulian(double injulian)
      Converts a Julian day to a calendar date ref : Numerical Recipes in C, 2nd ed., Cambridge University Press 1992
      Parameters:
      injulian - _more_
      Returns:
      _more_
    • fromJulian

      public static int[] fromJulian(double injulian, int[] src)
      _more_
      Parameters:
      injulian - _more_
      src - _more_
      Returns:
      _more_
    • testJulian

      public static void testJulian(String[] args)
      _more_
      Parameters:
      args - _more_
    • getArticle

      public static String getArticle(String s)
      _more_
      Parameters:
      s - _more_
      Returns:
      _more_
    • extractDate

      public static Date extractDate(String s)
      _more_
      Parameters:
      s - _more_
      Returns:
      _more_
    • findConstructor

      public static Constructor findConstructor(Class c, Class[] paramTypes)
      _more_
      Parameters:
      c - _more_
      paramTypes - _more_
      Returns:
      _more_
    • typesMatch

      public static boolean typesMatch(Class[] formals, Class[] actuals)
      _more_
      Parameters:
      formals - _more_
      actuals - _more_
      Returns:
      _more_
    • main

      public static void main(String[] args)
      _more_
      Parameters:
      args - _more_
    • findPatterns

      public static String[] findPatterns(String s, String regexp) throws Exception
      _more_
      Parameters:
      s - _more_
      regexp - _more_
      Returns:
      _more_
      Throws:
      Exception - _more_
    • findDate

      public static Date findDate(String source, String[] datePatterns, String[] dateFormats) throws Exception
      _more_
      Parameters:
      source - _more_
      datePatterns - _more_
      dateFormats - _more_
      Returns:
      _more_
      Throws:
      Exception - _more_
    • makeDateFormat

      public static SimpleDateFormat makeDateFormat(String format)
      _more_
      Parameters:
      format - _more_
      Returns:
      _more_
    • getYear

      public static int getYear(Date date)
      _more_
      Parameters:
      date - _more_
      Returns:
      _more_
    • getMonth

      public static int getMonth(Date date)
      _more_
      Parameters:
      date - _more_
      Returns:
      _more_
    • removeNonAscii

      public static String removeNonAscii(String s)
      _more_
      Parameters:
      s - _more_
      Returns:
      _more_
    • getAttributeOrTag

      public static String getAttributeOrTag(Element node, String attrOrTag, String dflt) throws Exception
      _more_
      Parameters:
      node - _more_
      attrOrTag - _more_
      dflt - _more_
      Returns:
      _more_
      Throws:
      Exception - _more_
    • getAttributeOrTag

      public static boolean getAttributeOrTag(Element node, String attrOrTag, boolean dflt) throws Exception
      _more_
      Parameters:
      node - _more_
      attrOrTag - _more_
      dflt - _more_
      Returns:
      _more_
      Throws:
      Exception - _more_
    • getAttributeOrTag

      public static int getAttributeOrTag(Element node, String attrOrTag, int dflt) throws Exception
      _more_
      Parameters:
      node - _more_
      attrOrTag - _more_
      dflt - _more_
      Returns:
      _more_
      Throws:
      Exception - _more_
    • getAttributeOrTag

      public static double getAttributeOrTag(Element node, String attrOrTag, double dflt) throws Exception
      _more_
      Parameters:
      node - _more_
      attrOrTag - _more_
      dflt - _more_
      Returns:
      _more_
      Throws:
      Exception - _more_
    • makeProperties

      public static String makeProperties(Hashtable properties)
      _more_
      Parameters:
      properties - _more_
      Returns:
      _more_
    • makeMap

      public static Hashtable<String,String> makeMap(String... args)
      _more_
      Parameters:
      args - _more_
      Returns:
      _more_
    • getProperties

      public static Hashtable getProperties(String s)
      _more_
      Parameters:
      s - _more_
      Returns:
      _more_
    • hexEncode

      public static String hexEncode(String s)
      _more_
      Parameters:
      s - _more_
      Returns:
      _more_
    • isImage

      public static boolean isImage(String path)
      _more_
      Parameters:
      path - _more_
      Returns:
      _more_
    • sortFilesOnSize

      public static File[] sortFilesOnSize(File[] files, boolean ascending)
      _more_
      Parameters:
      files - _more_
      ascending - _more_
      Returns:
      _more_
    • extractPatternNames

      public static String extractPatternNames(String filePatternString, List<String> patternNames)
      _more_
      Parameters:
      filePatternString - _more_
      patternNames - _more_
      Returns:
      _more_
    • readImage

      public static Image readImage(String file)
      _more_
      Parameters:
      file - _more_
      Returns:
      _more_
    • decodeLatLon

      public static double decodeLatLon(String latlon)
      This method is taken from Unidatas ucar.unidata.util.Misc method. I moved it here to not have it use the parseNumber because that would use a DecimalFormat which was picking up the Locale Decodes a string representation of a latitude or longitude and returns a double version (in degrees). Acceptible formats are:
       +/-  ddd:mm, ddd:mm:, ddd:mm:ss, ddd::ss, ddd.fffff ===>   [+/-] ddd.fffff
       +/-  ddd, ddd:, ddd::                               ===>   [+/-] ddd
       +/-  :mm, :mm:, :mm:ss, ::ss, .fffff                ===>   [+/-] .fffff
       +/-  :, ::                                          ===>       0.0
       Any of the above with N,S,E,W appended
       
      Parameters:
      latlon - string representation of lat or lon
      Returns:
      the decoded value in degrees
    • safeGet

      public static Object safeGet(List list, int index)
      _more_
      Parameters:
      list - _more_
      index - _more_
      Returns:
      _more_