Class LinearUnit

    • Field Detail

      • unitId

        private final java.lang.String unitId
      • idSuffix

        private final java.lang.String idSuffix
      • unitSymbol

        private final java.lang.String unitSymbol
      • nonBreakingSuffix

        private final java.lang.String nonBreakingSuffix
      • breakingSuffix

        private final java.lang.String breakingSuffix
      • unitDescription

        private final java.lang.String unitDescription
      • altNames

        private final java.lang.String[] altNames
      • parseMap

        private final java.util.Map<java.lang.String,​? extends LinearUnit> parseMap
    • Constructor Detail

      • LinearUnit

        public LinearUnit​(LinearKindOfQuantity kindOfQuantity,
                          java.lang.String unitId,
                          ScaleFactor factorToAtom,
                          java.lang.String unitSymbol,
                          java.lang.String unitDesc,
                          java.lang.String... altNames)
    • Method Detail

      • getUnitClass

        protected final java.lang.Class<LinearUnit> getUnitClass()
        Description copied from class: TypedUnit
        Get the typed Class object of the actual TypedUnit subclass U. This method is intended to simplify generic code, written in TypedUnit, to go from loosely typed arguments into stricter parameterized arguments.
        Specified by:
        getUnitClass in class TypedUnit<LinearUnit>
      • getDeltaUnit

        public LinearUnit getDeltaUnit()
        Description copied from interface: IUnit
        Get the unit that the difference between two quantities in this unit will have. For linear units, this is always the unit itself.
        Specified by:
        getDeltaUnit in interface IUnit
        Returns:
        the linear unit in which deltas of this unit is expressed
      • getAppendableSuffix

        public java.lang.String getAppendableSuffix​(boolean useBreakingSpace)
        Description copied from interface: IUnit
        Convenience method for (localized) formatters, to prepend a space to IUnit.getLocalizedSymbol(), if needed.
        Specified by:
        getAppendableSuffix in interface IUnit
        Parameters:
        useBreakingSpace - to use breaking space instead of the default, non-breaking space (only for edit)
        Returns:
        a localized string to be appended to a number when displaying a quantity (including space, if non-empty).
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • compareTo

        public int compareTo​(LinearUnit other)
        Specified by:
        compareTo in interface java.lang.Comparable<LinearUnit>
      • valueTransformTo

        public ScaleFactor valueTransformTo​(LinearUnit targetUnit)
        Description copied from class: TypedUnit
        Get a transform for transforming numerical quantity values expressed in this unit to numerical quantity values expressed in targetUnit. This method is typically only used internally by the quantity implementations. Note that this method differs from TypedUnit.valueTransformTo(IUnit) only by stricter typing.
        Specified by:
        valueTransformTo in class TypedUnit<LinearUnit>
      • valueFactorToAtom

        private ScaleFactor valueFactorToAtom()
      • isLinear

        public boolean isLinear()
        Description copied from interface: IUnit
        If this unit is linear. That is, if quantities expressed in this unit and in units of the same kind can be added to and subtracted from each other, and the resulting quantity remains of the same kind.
        Specified by:
        isLinear in interface IUnit
        Returns:
        true if and only if the unit is linear
      • floorQuantize

        private long floorQuantize​(long value,
                                   long alignment)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getIdentifier

        public java.lang.String getIdentifier()
        Description copied from interface: IUnit
        Persistable identifier, not to show interactively.
        Specified by:
        getIdentifier in interface IUnit
        Returns:
        the persistable (locale independent) identifier, or (possibly) null if this unit isn't persistable.
      • getLocalizedSymbol

        public java.lang.String getLocalizedSymbol()
        Description copied from interface: IUnit
        Symbols for units are most often not locale dependent, but there are exceptions (like in French). Also, besides real persistable units, temporary units are sometimes constructed for display purposes, and they might vary due to internationalization, and conceivably language.

        While symbols normally don't contain any white space, spacing occur in circumstances like custom units. In this case, it is important that they are non-breaking spaces ( ).

        Specified by:
        getLocalizedSymbol in interface IUnit
        Returns:
        the localized symbol of this unit.
      • getLocalizedDescription

        public java.lang.String getLocalizedDescription()
        Description copied from interface: IUnit
        In the real world, units are sometimes used ambiguously (like MB). This description is intended to remove such ambiguity where needed.
        Specified by:
        getLocalizedDescription in interface IUnit
        Returns:
        a (possibly) localized unambiguous description of this unit
      • getAltLocalizedNames

        public java.lang.String[] getAltLocalizedNames()
        Description copied from interface: IUnit
        Get alternate names for content assist matching. Note that these should never contain non-breaking spaces, only regular (breaking) spaces.
        Specified by:
        getAltLocalizedNames in interface IUnit
        Returns:
        an array, possibly empty, of names with which to match for content assist, never null.
      • isCustom

        protected boolean isCustom()
      • asWellKnownQuantity

        public ITypedQuantity<LinearUnit> asWellKnownQuantity()
        Returns:
        a quantity with the same magnitude as this unit, defined in a non-custom unit (possibly itself)
      • localizedFormatFor

        protected java.lang.String localizedFormatFor​(java.lang.Number numericalValue,
                                                      boolean useBreakingSpace,
                                                      boolean allowCustomUnit)
        Specified by:
        localizedFormatFor in class TypedUnit<LinearUnit>