Package org.openjdk.jmc.common.unit
Class QuantityConversionException
java.lang.Object
java.lang.Throwable
java.lang.Exception
org.openjdk.jmc.common.unit.QuantityConversionException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
QuantityConversionException.Persisted,QuantityConversionException.Quantity
Exception denoting problem converting between representations of physical quantities ("numbers
with units"). Has a problem enum designating the kind of problem and is able to return a
prototype value that could be used to circumvent that problem. Has different representations for
persisting/logging (locale independent) and presenting to a human (using the default locale). Be
sure to use
getLocalizedMessage() for error dialogs.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic enumstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Stringprotected final QuantityConversionException.Problem -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedQuantityConversionException(QuantityConversionException.Problem problem, String badString) -
Method Summary
Modifier and TypeMethodDescriptionstatic <Q extends IQuantity>
QuantityConversionExceptionbelowPrecision(Q badValue, Q precisionLimit) static <T extends Comparable<T>>
QuantityConversionExceptionbelowPrecision(T badValue, T precisionLimit, IPersister<T> persister) static QuantityConversionExceptionconflictingConstraints(Object value, String key) The string where the problem was encountered, so that it might be highlighted.abstract StringPrototype value suitable to be presented to a human.abstract StringPrototype value suitable to be persisted or logged.The kind of problem encountered.static QuantityConversionExceptionstatic <T extends Comparable<T>>
QuantityConversionExceptionnoUnit(String badString, T prototype, IPersister<T> persister) static <Q extends IQuantity>
QuantityConversionExceptiontooHigh(Q badValue, Q max) static <T extends Comparable<T>>
QuantityConversionExceptiontooHigh(T badValue, T max, IPersister<T> persister) static <Q extends IQuantity>
QuantityConversionExceptiontooLow(Q badValue, Q min) static <T extends Comparable<T>>
QuantityConversionExceptiontooLow(T badValue, T min, IPersister<T> persister) toString()static QuantityConversionExceptionunknownUnit(String badString, IQuantity prototype) static <T extends Comparable<T>>
QuantityConversionExceptionunknownUnit(String badString, T prototype, IPersister<T> persister) static QuantityConversionExceptionunparsable(String badString, IQuantity prototype) static <T extends Comparable<T>>
QuantityConversionExceptionunparsable(String badString, T prototype, IPersister<T> persister) Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Field Details
-
problem
-
badString
-
-
Constructor Details
-
QuantityConversionException
protected QuantityConversionException(QuantityConversionException.Problem problem, String badString)
-
-
Method Details
-
unparsable
public static <T extends Comparable<T>> QuantityConversionException unparsable(String badString, T prototype, IPersister<T> persister) -
noUnit
public static <T extends Comparable<T>> QuantityConversionException noUnit(String badString, T prototype, IPersister<T> persister) -
unknownUnit
public static <T extends Comparable<T>> QuantityConversionException unknownUnit(String badString, T prototype, IPersister<T> persister) -
tooLow
public static <T extends Comparable<T>> QuantityConversionException tooLow(T badValue, T min, IPersister<T> persister) -
tooHigh
public static <T extends Comparable<T>> QuantityConversionException tooHigh(T badValue, T max, IPersister<T> persister) -
belowPrecision
public static <T extends Comparable<T>> QuantityConversionException belowPrecision(T badValue, T precisionLimit, IPersister<T> persister) -
unparsable
-
noUnit
-
unknownUnit
-
tooLow
-
tooHigh
-
belowPrecision
public static <Q extends IQuantity> QuantityConversionException belowPrecision(Q badValue, Q precisionLimit) -
conflictingConstraints
-
getProblem
The kind of problem encountered.- Returns:
- one of the
QuantityConversionException.Problemvalues, never null
-
getBadString
The string where the problem was encountered, so that it might be highlighted. May be the entire string on which parsing was attempted. May be null if this problem was detected after parsing, such as out of range.- Returns:
- a substring of the parser input, or null
-
getPersistablePrototype
Prototype value suitable to be persisted or logged.- Returns:
- a non-localized (English) value that will prevent this particular problem when parsed.
-
getInteractivePrototype
Prototype value suitable to be presented to a human. Must not be persisted or logged.- Returns:
- a localized value that will prevent this particular problem when parsed using interactive parsing.
-
getMessage
- Overrides:
getMessagein classThrowable
-
getLocalizedMessage
- Overrides:
getLocalizedMessagein classThrowable
-
toString
-