Class MCRMetaNumber

java.lang.Object
org.mycore.datamodel.metadata.MCRMetaDefault
org.mycore.datamodel.metadata.MCRMetaNumber
All Implemented Interfaces:
Cloneable, MCRMetaInterface

public final class MCRMetaNumber extends MCRMetaDefault

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 Details

  • 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 subtag
      inherted - a value >= 0
      dimension - the optional dimension string
      measurement - the optional measurement string
      number - 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 subtag
      inherted - a value >= 0
      dimension - the optional dimension string
      measurement - the optional measurement string
      number - 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

      public void setDimension(String dimension)
      This method set the dimension, if it is null, an empty string was set to the dimension element.
      Parameters:
      dimension - the dimension string
    • setMeasurement

      public void setMeasurement(String measurement)
      This method set the measurement, if it is null, an empty string was set to the measurement element.
      Parameters:
      measurement - the measurement string
    • setNumber

      public void setNumber(String number) throws MCRException
      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

      public void setNumber(BigDecimal number) throws MCRException
      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

      public String getDimension()
      This method get the dimension element.
      Returns:
      the dimension String
    • getMeasurement

      public String getMeasurement()
      This method get the measurement element.
      Returns:
      the measurement String
    • getNumberAsBigDecimal

      public BigDecimal getNumberAsBigDecimal()
      This method get the number element.
      Returns:
      the number as BigDecimal
    • getNumberAsString

      public String 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

      public void setFromDOM(Element element)
      This method read the XML input stream part from a DOM part for the metadata of the document.
      Specified by:
      setFromDOM in interface MCRMetaInterface
      Overrides:
      setFromDOM in class MCRMetaDefault
      Parameters:
      element - a relevant JDOM element for the metadata
    • createXML

      public Element createXML() throws MCRException
      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 interface MCRMetaInterface
      Overrides:
      createXML in class MCRMetaDefault
      Returns:
      a JDOM Element with the XML MCRNumber part
      Throws:
      MCRException - if the content of this instance is not valid
    • clone

      public MCRMetaNumber clone()
      clone of this instance you will get a (deep) clone of this element
      Specified by:
      clone in interface MCRMetaInterface
      Overrides:
      clone in class MCRMetaDefault
      See Also:
    • debug

      public void debug()
      Logs debug output.
      Specified by:
      debug in interface MCRMetaInterface
      Overrides:
      debug in class MCRMetaDefault
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class MCRMetaDefault