Top Description Fields Constructors Methods
javax.money

public final Class MonetaryContext

extends AbstractContext
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.io.Serializable

This class models the meta data (mostly the numeric capabilities) of a MonetaryAmount in a platform independent way. It provides information about

This class is immutable, serializable and thread-safe.

Authors
Anatole Tresch, Werner Keil

Field Summary

Modifier and TypeField and Description
pack-priv static final String
AMOUNT_TYPE

Constant that defines under which key the amount type is stored in the context map.

private static final String
FIXED_SCALE

Key name for the fixed scale.

private static final String
MAX_SCALE

Key name for the max scale.

private static final String
PRECISION

Key name for the precision.

private static final long
Inherited from javax.money.AbstractContext:
dataKEY_PROVIDER

Constructor Summary

AccessConstructor and Description
pack-priv
MonetaryContext(MonetaryContextBuilder
the corresponding builder, not null.
builder
)

Constructor, used from the Builder.

Method Summary

Modifier and TypeMethod and Description
public static MonetaryContext

Returns:

a new corresponding MonetaryContext instance.
from
(MonetaryAmountFactoryQuery
the monetary amount factory query, not null.
monetaryAmountFactoryQuery
,
Class<? extends MonetaryAmount>
the targeted implementation type.
amountClass
)

This method allows to easily of a new MonetaryContext instance from a given .MonetaryAmountFactoryQuery.

public static MonetaryContext

Returns:

a new corresponding MonetaryContext instance.
from
(MonetaryContext
the base context, not null.
monetaryContext
,
Class<? extends MonetaryAmount>
the target amount class.
amountClass
)

Creates a new MonetaryContext).

public Class<? extends MonetaryAmount>

Returns:

the implementation class of the containing amount instance, never null.
getAmountType
()

Get the MonetaryAmount implementation class.

public int

Returns:

the maximal scale supported, always >= -1
getMaxScale
()

Get the maximal scale supported, always >= -1.

public int

Returns:

an int which is the value of the precision setting
getPrecision
()

Returns the precision setting.

public boolean

Returns:

true if minScale == maxScale.
isFixedScale
()

Allows to check if minScale == maxScale.

public MonetaryContextBuilder

Returns:

a new javax.money.MonetaryContextBuilder instance, never null.
toBuilder
()

Creates a new builder instances, initialized with the data from this one.

Inherited from javax.money.AbstractContext:
equalsgetgetgetBooleangetDoublegetFloatgetIntgetKeysgetLonggetProviderNamegetTextgetTypehashCodeisEmptytoString

Field Detail

AMOUNT_TYPEback to summary
pack-priv static final String AMOUNT_TYPE

Constant that defines under which key the amount type is stored in the context map.

FIXED_SCALEback to summary
private static final String FIXED_SCALE

Key name for the fixed scale.

MAX_SCALEback to summary
private static final String MAX_SCALE

Key name for the max scale.

PRECISIONback to summary
private static final String PRECISION

Key name for the precision.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides javax.money.AbstractContext.serialVersionUID.

Constructor Detail

MonetaryContextback to summary
pack-priv MonetaryContext(MonetaryContextBuilder builder)

Constructor, used from the Builder.

Parameters
builder:MonetaryContextBuilder

the corresponding builder, not null.

Method Detail

fromback to summary
public static MonetaryContext from(MonetaryAmountFactoryQuery monetaryAmountFactoryQuery, Class<? extends MonetaryAmount> amountClass)

This method allows to easily of a new MonetaryContext instance from a given .MonetaryAmountFactoryQuery.

Parameters
monetaryAmountFactoryQuery:MonetaryAmountFactoryQuery

the monetary amount factory query, not null.

amountClass:Class<? extends MonetaryAmount>

the targeted implementation type.

Returns:MonetaryContext

a new corresponding MonetaryContext instance.

fromback to summary
public static MonetaryContext from(MonetaryContext monetaryContext, Class<? extends MonetaryAmount> amountClass)

Creates a new MonetaryContext).

Parameters
monetaryContext:MonetaryContext

the base context, not null.

amountClass:Class<? extends MonetaryAmount>

the target amount class.

Returns:MonetaryContext

a new corresponding MonetaryContext instance.

getAmountTypeback to summary
public Class<? extends MonetaryAmount> getAmountType()

Get the MonetaryAmount implementation class.

Returns:Class<? extends MonetaryAmount>

the implementation class of the containing amount instance, never null.

See Also
MonetaryAmount#getContext()
getMaxScaleback to summary
public int getMaxScale()

Get the maximal scale supported, always >= -1. Fixed scaled numbers will have scale==maxScale for all values. -1 declares the maximal scale to be unlimited.

Returns:int

the maximal scale supported, always >= -1

getPrecisionback to summary
public int getPrecision()

Returns the precision setting. This value is always non-negative.

Returns:int

an int which is the value of the precision setting

isFixedScaleback to summary
public boolean isFixedScale()

Allows to check if minScale == maxScale.

Returns:boolean

true if minScale == maxScale.

toBuilderback to summary
public MonetaryContextBuilder toBuilder()

Creates a new builder instances, initialized with the data from this one.

Returns:MonetaryContextBuilder

a new javax.money.MonetaryContextBuilder instance, never null.