Class Helper

java.lang.Object
com.graphhopper.util.Helper

public class Helper extends Object
Author:
Peter Karich
  • Field Details

  • Method Details

    • getLocale

      public static Locale getLocale(String param)
    • toLowerCase

      public static String toLowerCase(String string)
    • toUpperCase

      public static String toUpperCase(String string)
    • saveProperties

      public static void saveProperties(Map<String,String> map, Writer tmpWriter) throws IOException
      Throws:
      IOException
    • readJSONFileWithoutComments

      public static String readJSONFileWithoutComments(String file) throws IOException
      Throws:
      IOException
    • readJSONFileWithoutComments

      public static String readJSONFileWithoutComments(InputStreamReader reader) throws IOException
      Throws:
      IOException
    • readFile

      public static List<String> readFile(String file) throws IOException
      Throws:
      IOException
    • readFile

      public static List<String> readFile(Reader simpleReader) throws IOException
      Throws:
      IOException
    • isToString

      public static String isToString(InputStream inputStream) throws IOException
      Throws:
      IOException
    • idealIntArraySize

      public static int idealIntArraySize(int need)
    • idealByteArraySize

      public static int idealByteArraySize(int need)
    • removeDir

      public static boolean removeDir(File file)
    • getTotalMB

      public static long getTotalMB()
    • getUsedMB

      public static long getUsedMB()
    • getMemInfo

      public static String getMemInfo()
    • getSizeOfObjectRef

      public static int getSizeOfObjectRef(int factor)
    • getSizeOfLongArray

      public static int getSizeOfLongArray(int length, int factor)
    • getSizeOfObjectArray

      public static int getSizeOfObjectArray(int length, int factor)
    • close

      public static void close(Closeable cl)
    • isEmpty

      public static boolean isEmpty(String str)
    • isFileMapped

      public static boolean isFileMapped(ByteBuffer bb)
      Determines if the specified ByteBuffer is one which maps to a file!
    • pruneFileEnd

      public static String pruneFileEnd(String file)
    • createDoubleList

      public static List<Double> createDoubleList(double[] values)
    • createPointList

      public static PointList createPointList(double... list)
    • createPointList3D

      public static PointList createPointList3D(double... list)
    • degreeToInt

      public static int degreeToInt(double deg)
      Converts into an integer to be compatible with the still limited DataAccess class (accepts only integer values). But this conversion also reduces memory consumption where the precision loss is acceptable. As +- 180° and +-90° are assumed as maximum values.
      Returns:
      the integer of the specified degree
    • intToDegree

      public static double intToDegree(int storedInt)
      Converts back the integer value.
      Returns:
      the degree value of the specified integer
    • eleToUInt

      public static int eleToUInt(double ele)
      Converts elevation value (in meters) into integer for storage.
    • uIntToEle

      public static double uIntToEle(int integEle)
      Converts the integer value retrieved from storage into elevation (in meters). Do not expect more precision than meters although it currently is!
    • nf

      public static String nf(long no)
    • firstBig

      public static String firstBig(String sayText)
    • keepIn

      public static double keepIn(double value, double min, double max)
      This methods returns the value or min if too small or max if too big.
    • round

      public static double round(double value, int decimalPlaces)
      Round the value to the specified number of decimal places, i.e. decimalPlaces=2 means we round to two decimal places. Using negative values like decimalPlaces=-2 means we round to two places before the decimal point.
    • round6

      public static double round6(double value)
    • round4

      public static double round4(double value)
    • round2

      public static double round2(double value)
    • createFormatter

      public static DateFormat createFormatter()
      This creates a date formatter for yyyy-MM-dd'T'HH:mm:ss'Z' which is has to be identical to buildDate used in pom.xml
    • createFormatter

      public static DateFormat createFormatter(String str)
      Creates a SimpleDateFormat with ENGLISH locale.
    • toObject

      public static Object toObject(String string)
      This method probes the specified string for a boolean, int, long, float and double. If all this fails it returns the unchanged string.
    • camelCaseToUnderScore

      public static String camelCaseToUnderScore(String key)
    • underScoreToCamelCase

      public static String underScoreToCamelCase(String key)
    • parseList

      public static List<String> parseList(String listStr)
      parses a string like [a,b,c]
    • staticHashCode

      public static int staticHashCode(String str)
      Produces a static hashcode for a string that is platform independent and still compatible to the default of openjdk. Do not use for performance critical applications.
      See Also: