Class PropertyUtils

java.lang.Object
org.archive.util.PropertyUtils

public class PropertyUtils extends Object
Utilities for dealing with Java Properties (incl. System Properties)
Version:
$Date$ $Revision$
Author:
stack, gojomo
  • Field Details

    • propRefPattern

      protected static String propRefPattern
  • Constructor Details

    • PropertyUtils

      public PropertyUtils()
  • Method Details

    • getPropertyOrNull

      public static String getPropertyOrNull(String key)
      Parameters:
      key - Property key.
      Returns:
      Named property or null if the property is null or empty.
    • getBooleanProperty

      public static boolean getBooleanProperty(String key)
      Parameters:
      key - Property key.
      Returns:
      Boolean value or false if null or unreadable.
    • getIntProperty

      public static int getIntProperty(String key, int fallback)
      Parameters:
      key - Key to use looking up system property.
      fallback - If no value found for passed key, return fallback.
      Returns:
      Value of property or fallback.
    • interpolateWithProperties

      public static String interpolateWithProperties(String original)
      Given a string which may contain expressions of the form ${key}, replace each expression with the value corresponding to the given key in System Properties. If no value is present, the expression is replaced with the empty-string.
      Parameters:
      original - String
      Returns:
      modified String
    • interpolateWithProperties

      public static String interpolateWithProperties(String original, Properties... props)
      Given a string which may contain expressions of the form ${key}, replace each expression with the value corresponding to the given key in the supplied Properties instance. If no value is present, the expression is replaced with the empty-string.
      Parameters:
      original - String
      props - Properties to try in order; first value found (if any) is used
      Returns:
      modified String