public class PGPropertyMaxResultBufferParser
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.util.logging.Logger |
LOGGER |
private static java.lang.String[] |
PERCENT_PHRASES |
Constructor and Description |
---|
PGPropertyMaxResultBufferParser() |
Modifier and Type | Method and Description |
---|---|
private static long |
adjustResultSize(long value)
Method to adjust result memory limit size.
|
private static long |
calculatePercentOfMemory(java.lang.String value,
int percentPhraseLength)
Method to calculate percent of given max heap memory.
|
private static boolean |
checkIfValueContainsPercent(java.lang.String value)
Method to check if given value can contain percent declaration of size of max result buffer.
|
private static boolean |
checkIfValueExistsToBeParsed(java.lang.String value)
Method to check if given value has any chars to be parsed.
|
private static int |
getPercentPhraseLengthIfContains(java.lang.String valueToCheck)
Method to get length of percent phrase existing in given string, only if one of phrases exist
on the length of string.
|
private static int |
getPhraseLengthIfContains(java.lang.String valueToCheck,
java.lang.String phrase)
Method to get length of given phrase in given string to check, method checks if phrase exist on
the end of given string.
|
private static long |
parseBytePercentValue(java.lang.String value)
Method to get percent value of max result buffer size dependable on actual free memory.
|
private static long |
parseByteValue(java.lang.String value)
Method to get size based on given string value.
|
static long |
parseProperty(java.lang.String value)
Method to parse value of max result buffer size.
|
private static void |
throwExceptionAboutParsingError(java.lang.String message,
java.lang.Object... values)
Method to throw message for parsing MaxResultBuffer.
|
private static final java.util.logging.Logger LOGGER
private static final java.lang.String[] PERCENT_PHRASES
public static long parseProperty(java.lang.String value) throws PSQLException
value
- string containing size of bytes with optional multiplier (T, G, M or K) or percent
value to declare max percent of heap memory to use.PSQLException
- Exception when given value can't be parsed.private static boolean checkIfValueContainsPercent(java.lang.String value)
value
- Value to check.private static long parseBytePercentValue(java.lang.String value) throws PSQLException
value
- string containing percent used to define max result buffer.PSQLException
- Exception when given value can't be parsed.private static int getPercentPhraseLengthIfContains(java.lang.String valueToCheck)
valueToCheck
- String which is gonna be checked if contains percent phrase.private static int getPhraseLengthIfContains(java.lang.String valueToCheck, java.lang.String phrase)
valueToCheck
- String which gonna be checked if contains phrase.phrase
- Phrase to be looked for on the end of given string.private static long calculatePercentOfMemory(java.lang.String value, int percentPhraseLength)
value
- String which contains percent + percent phrase which gonna be used
during calculations.percentPhraseLength
- Length of percent phrase inside given value.private static boolean checkIfValueExistsToBeParsed(java.lang.String value)
value
- Value to be checked.private static long parseByteValue(java.lang.String value) throws PSQLException
value
- Given string to be parsed.PSQLException
- Exception when given value can't be parsed.private static long adjustResultSize(long value)
value
- Size to be adjusted.private static void throwExceptionAboutParsingError(java.lang.String message, java.lang.Object... values) throws PSQLException
message
- Message to be added to exception.values
- Values to be put inside exception message.PSQLException
- Exception when given value can't be parsed.