Class TypedPropertiesSource

java.lang.Object
scriptella.text.TypedPropertiesSource

public class TypedPropertiesSource extends Object
Typed view for properties.

FIXME: Extract interface

Version:
1.1
Author:
Fyodor Kupolov
  • Constructor Details

    • TypedPropertiesSource

      public TypedPropertiesSource(Map<String,?> properties)
  • Method Details

    • getKeys

      public Set<String> getKeys()
    • getProperty

      public Object getProperty(String name)
      Convenience method which returns property by name.
      Parameters:
      name - property name
      Returns:
      property value
    • getStringProperty

      public String getStringProperty(String name)
      Returns string value of the property.
      Parameters:
      name - property name.
      Returns:
      property value.
    • getNumberProperty

      public Number getNumberProperty(String name, Number defaultValue) throws ConfigurationException
      Returns numeric value of the property.

      Accepts decimal, hexadecimal, and octal numbers if property is String.

      Parameters:
      name - property name.
      defaultValue - default value to use when property omitted.
      Returns:
      numeric property value.
      Throws:
      ConfigurationException - if parsing failed.
      See Also:
    • getBooleanProperty

      public boolean getBooleanProperty(String name, boolean defaultValue) throws ConfigurationException
      Parses property value as a boolean flag.
      Parameters:
      name - property name.
      defaultValue - default value to use if connection has no such property.
      Returns:
      boolean property value.
      Throws:
      ConfigurationException - if property has unrecognized value.
    • getCharsetProperty

      public String getCharsetProperty(String name) throws ConfigurationException
      Parses property value as a charset encoding name.
      Parameters:
      name - property name.
      Returns:
      value of the property or null if connection has no such property.
      Throws:
      ConfigurationException - if charset name is unsupported.
    • getLocaleProperty

      public Locale getLocaleProperty(String name)
      Parses property value as a locale string.
      Parameters:
      name - property name.
      Returns:
      locale or null if property not found or has no value
      See Also:
    • getProperties

      public Map<String,?> getProperties()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • from

      public static TypedPropertiesSource from(ConnectionParameters connectionParameters)
      Converts connectionParameters to TypedPropertiesSource. FIXME: This method should not create a new instance, but return an internal delegate used by connection params.
      Parameters:
      connectionParameters - connection parameters
      Returns:
      connection parameters as TypedPropertiesSource