Class MCRMetaNumber
- All Implemented Interfaces:
Cloneable
,MCRMetaInterface
Implements methods to handle MCRMetaNumber fields of a metadata object. The MCRMetaNumber class presents a number value in decimal format and optional a dimension type and a measurement. The input number can have the format like xxxx, xxxx.x or xxxx,xxx.
The length of the dimension type is limited by the property MCR.Metadata.MetaNumber.DimensionLength. The default length is defined in MAX_DIMENSION_LENGTH = 128.
The length of the measurement type is limited by the property MCR.Metadata.MetaNumber.MeasurementLength. The default length is defined in MAX_MEASURE_LENGTH = 64.
The String output format of the number is determined by the property MCR.Metadata.MetaNumber.FractionDigits, default is DEFAULT_FRACTION_DIGITS = 3, and the ENGLISH Locale. For more digits in fraction as defined in property MCR.Metadata.MetaNumber.FractionDigits will be round the output!
For transforming the dot of the ENGLISH locale to other Characters use the tools of your layout process.
<tag class="MCRMetaNumber" heritable="..."> <subtag type="..." measurement="..." dimension="..."> xxxx.xxx or xxx </subtag> </tag>
- Version:
- $Revision$ $Date$
- Author:
- Jens Kupferschmidt
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
Fields inherited from class org.mycore.datamodel.metadata.MCRMetaDefault
datapart, DEFAULT_ATTRIBUTE_INHERITED, DEFAULT_ATTRIBUTE_LANG, DEFAULT_ATTRIBUTE_SEQUENCE, DEFAULT_ATTRIBUTE_TYPE, DEFAULT_ELEMENT_DATAPART, DEFAULT_INHERITED, DEFAULT_LANG_LENGTH, DEFAULT_LANGUAGE, DEFAULT_SEQUENCE, DEFAULT_STRING_LENGTH, DEFAULT_TYPE_LENGTH, inherited, lang, NL, sequence, subtag, type
-
Constructor Summary
ConstructorDescriptionThis is the constructor.MCRMetaNumber
(String subtag, int inherted, String dimension, String measurement, String number) This is the constructor.MCRMetaNumber
(String subtag, int inherted, String dimension, String measurement, BigDecimal number) This is the constructor. -
Method Summary
Modifier and TypeMethodDescriptionclone()
clone of this instance you will get a (deep) clone of this elementThis method creates an XML element containing all data in this instance, as defined by the MyCoRe XML MCRNumber definition for the given subtag.void
debug()
Logs debug output.boolean
This method get the dimension element.This method get the measurement element.This method get the number element.This method get the number element as formatted String.void
setDimension
(String dimension) This method set the dimension, if it is null, an empty string was set to the dimension element.void
setFromDOM
(Element element) This method read the XML input stream part from a DOM part for the metadata of the document.void
setMeasurement
(String measurement) This method set the measurement, if it is null, an empty string was set to the measurement element.void
This method set the number, if it is null or not a number, a MCRException will be throw.void
setNumber
(BigDecimal number) This method set the number, if it is null a MCRException will be throw.Methods inherited from class org.mycore.datamodel.metadata.MCRMetaDefault
createJSON, debugDefault, decrementInherited, getInherited, getLang, getSequence, getSubTag, getType, hashCode, incrementInherited, isValid, setInherited, setLang, setSequence, setSubTag, setType, validate
-
Field Details
-
MAX_DIMENSION_LENGTH
public static final int MAX_DIMENSION_LENGTH- See Also:
-
MAX_MEASUREMENT_LENGTH
public static final int MAX_MEASUREMENT_LENGTH- See Also:
-
DEFAULT_FRACTION_DIGITS
public static final int DEFAULT_FRACTION_DIGITS- See Also:
-
-
Constructor Details
-
MCRMetaNumber
public MCRMetaNumber()This is the constructor.
Sets the number to zero, the measurement and the dimension to an empty string. -
MCRMetaNumber
public MCRMetaNumber(String subtag, int inherted, String dimension, String measurement, String number) throws MCRException This is the constructor.
The subtag element was set to the value of subtag. If the value of subtag is null or empty a MCRException will be thrown. The dimension element was set to the value of dimension, if it is null, an empty string was set to the dimension element. The measurement element was set to the value of measurement, if it is null, an empty string was set to the measurement element. The number string number was set to the number element, if it is null, empty or not a number, a MCRException will be thown.- Parameters:
subtag
- the name of the subtaginherted
- a value >= 0dimension
- the optional dimension stringmeasurement
- the optional measurement stringnumber
- the number string- Throws:
MCRException
- if the subtag value is null or empty or if the number string is not in a number format
-
MCRMetaNumber
public MCRMetaNumber(String subtag, int inherted, String dimension, String measurement, BigDecimal number) throws MCRException This is the constructor.
The subtag element was set to the value of subtag. If the value of subtag is null or empty a MCRException will be thrown. The dimension element was set to the value of dimension, if it is null, an empty string was set to the dimension element. The measurement element was set to the value of measurement, if it is null, an empty string was set to the measurement element. The number number was set to the number element, if it is null a MCRException will be thrown.- Parameters:
subtag
- the name of the subtaginherted
- a value >= 0dimension
- the optional dimension stringmeasurement
- the optional measurement stringnumber
- the number string- Throws:
MCRException
- if the subtag value is null or empty or if the number string is not in a number format
-
-
Method Details
-
setDimension
This method set the dimension, if it is null, an empty string was set to the dimension element.- Parameters:
dimension
- the dimension string
-
setMeasurement
This method set the measurement, if it is null, an empty string was set to the measurement element.- Parameters:
measurement
- the measurement string
-
setNumber
This method set the number, if it is null or not a number, a MCRException will be throw.- Parameters:
number
- the number string- Throws:
MCRException
- if the number string is not in a number format
-
setNumber
This method set the number, if it is null a MCRException will be throw.- Parameters:
number
- the number as BigDecimal- Throws:
MCRException
- if the number string is null
-
getDimension
This method get the dimension element.- Returns:
- the dimension String
-
getMeasurement
This method get the measurement element.- Returns:
- the measurement String
-
getNumberAsBigDecimal
This method get the number element.- Returns:
- the number as BigDecimal
-
getNumberAsString
This method get the number element as formatted String. The number of fraction digits is defined by property MCR.Metadata.MetaNumber.FractionDigits. The default is 3 fraction digits.- Returns:
- the number as formatted String
-
setFromDOM
This method read the XML input stream part from a DOM part for the metadata of the document.- Specified by:
setFromDOM
in interfaceMCRMetaInterface
- Overrides:
setFromDOM
in classMCRMetaDefault
- Parameters:
element
- a relevant JDOM element for the metadata
-
createXML
This method creates an XML element containing all data in this instance, as defined by the MyCoRe XML MCRNumber definition for the given subtag.- Specified by:
createXML
in interfaceMCRMetaInterface
- Overrides:
createXML
in classMCRMetaDefault
- Returns:
- a JDOM Element with the XML MCRNumber part
- Throws:
MCRException
- if the content of this instance is not valid
-
clone
clone of this instance you will get a (deep) clone of this element- Specified by:
clone
in interfaceMCRMetaInterface
- Overrides:
clone
in classMCRMetaDefault
- See Also:
-
debug
public void debug()Logs debug output.- Specified by:
debug
in interfaceMCRMetaInterface
- Overrides:
debug
in classMCRMetaDefault
-
equals
- Overrides:
equals
in classMCRMetaDefault
-