Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.hibernate.search.backend.configuration
Class ConfigurationParseHelper

    java.lang.Object
      org.hibernate.search.backend.configuration.ConfigurationParseHelper

    public abstract class ConfigurationParseHelper

extends java.lang.Object

Helper class to avoid managing NumberFormatException and similar code and ensure consistent error messages across Configuration parsing problems.

Author:
  Sanne Grinovero

Constructor Summary
`ConfigurationParseHelper()`

Method Summary
`static int` | `getIntValue(java.util.Properties cfg, java.lang.String key, int defValue)` Looks for a numeric value in the Properties, returning defValue if not found or if an empty string is found.
`static boolean` | `parseBoolean(java.lang.String value, java.lang.String errorMsgOnParseFailure)` Parses a string to recognize exactly either "true" or "false".
`static int` | `parseInt(java.lang.String value, int defValue, java.lang.String errorMsgOnParseFailure)` In case value is null or an empty string the defValue is returned
`static int` | `parseInt(java.lang.String value, java.lang.String errorMsgOnParseFailure)` Parses a String to get an int value.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ConfigurationParseHelper

    public ConfigurationParseHelper()

Method Detail

### parseInt

    public static final int parseInt(java.lang.String value,
                                     java.lang.String errorMsgOnParseFailure)

  Parses a String to get an int value.

  Parameters:
    `value` - A string containing an int value to parse
    `errorMsgOnParseFailure` - message being wrapped in a SearchException if value is null or not correct.
  Returns:
    the parsed value
  Throws:
    `SearchException` - both for null values and for Strings not containing a valid int.

### parseInt

    public static final int parseInt(java.lang.String value,
                                     int defValue,
                                     java.lang.String errorMsgOnParseFailure)

  In case value is null or an empty string the defValue is returned

  Parameters:
    `value` -
    `defValue` -
    `errorMsgOnParseFailure` -
  Returns:
    the converted int.
  Throws:
    `SearchException` - if value can't be parsed.

### getIntValue

    public static final int getIntValue(java.util.Properties cfg,
                                        java.lang.String key,
                                        int defValue)

  Looks for a numeric value in the Properties, returning defValue if not found or if an empty string is found. When the key the value is found but not in valid format a standard error message is generated.

  Parameters:
    `cfg` -
    `key` -
    `defValue` -
  Returns:
    the converted int.
  Throws:
    `SearchException` - for invalid format.

### parseBoolean

    public static final boolean parseBoolean(java.lang.String value,
                                             java.lang.String errorMsgOnParseFailure)

  Parses a string to recognize exactly either "true" or "false".

  Parameters:
    `value` - the string to be parsed
    `errorMsgOnParseFailure` - the message to be put in the exception if thrown
  Returns:
    true if value is "true", false if value is "false"
  Throws:
    `SearchException` - for invalid format or values.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006-2010 Hibernate. All Rights Reserved.