com.groupdocs.editor.htmlcss.css.datatypes

Class Length

  • java.lang.Object
    • com.aspose.ms.System.ValueType<T>
      • com.aspose.ms.lang.Struct<Length>
        • com.groupdocs.editor.htmlcss.css.datatypes.Length
  • All Implemented Interfaces:
    com.aspose.ms.System.ICloneable, com.aspose.ms.System.IEquatable<com.groupdocs.editor.htmlcss.css.datatypes.ICssDataType>, com.groupdocs.editor.htmlcss.css.datatypes.ICssDataType


    public class Length
    extends com.aspose.ms.lang.Struct<Length>
    implements com.groupdocs.editor.htmlcss.css.datatypes.ICssDataType, com.aspose.ms.System.ICloneable

    Represents a CSS length value in any supportable unit, including percentage and unitless type. Values may be integer or float, negative, zero and positive. Immutable structure.


    https://developer.mozilla.org/en-US/docs/Web/CSS/length https://developer.mozilla.org/en-US/docs/Web/CSS/percentage

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class and Description
      static class  Length.Unit
      All supported length units
    • Constructor Summary

      Constructors 
      Constructor and Description
      Length() 
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      Object clone() 
      Length Clone() 
      void CloneTo(Length that) 
      Length deepClone()
      Returns a full copy of this Length instance
      boolean equals(com.groupdocs.editor.htmlcss.css.datatypes.ICssDataType other) 
      boolean equals(Length other)
      Defines whether this value is equal to the other specified length
      static boolean equals(Length obj1, Length obj2) 
      boolean equals(Object obj)
      Determines whether this length is equal to specified object
      static Length fromValueWithUnit(double value, byte unit)
      Creates and returns an instance of Length type by specified double number and unit
      static Length fromValueWithUnit(float value, byte unit)
      Creates and returns an instance of Length type by specified float number and unit
      static Length fromValueWithUnit(int value, byte unit)
      Creates and returns an instance of Length type by specified integer number and unit
      float getFloatValue()
      Returns a float numeric value of the Length instance.
      int getIntegerValue()
      Returns an integer numeric value of this Length instance, if it is internally stored as an integer, or throws an exception, if it was originally stored as a float number.
      byte getNumberType() 
      static byte getUnitFromName(String unitName)
      Tries to parse specified unit name and return corresponding value of a Unit enum.
      byte getUnitType()
      Returns a unit type of this Length instance.
      int hashCode()
      Calculates and returns a hash-code of this Length instance by combining hash-codes of the value and unit type
      boolean isAbsolute()
      Gets if the length is given in absolute units.
      boolean isDefault()
      Indicates whether this Length instance has a default value — unitless zero.
      boolean isFloat()
      Indicates whether the numeric value of this Length instance was originally specified and stored as a float (FP32) number
      boolean isInteger()
      Indicates whether the numeric value of this Length instance was originally specified and stored as an integer (INT32) number
      boolean isNegative()
      Determines whether the numeric value of this length is a negative number
      boolean isPositive()
      Determines whether the numeric value of this length is a positive number
      boolean isRelative()
      Gets if the length is given in relative units.
      boolean isUnitlessNonZero()
      The value has unitless type, but is not a zero - positive or negative number
      boolean isUnitlessZero()
      Determines whether this instance is a unitless zero or not.
      boolean isZero()
      Determines whether the numeric value of this length is a zero number
      static boolean op_Equality(Length left, Length right)
      Checks the equality of the two given lengths.
      static boolean op_Inequality(Length left, Length right)
      Checks the inequality of the two given lengths.
      static Length parse(String input)
      Parses and returns specified string as a Length value, including its numeric value and unit name, or throws an exception on failure
      String serializeDefault()
      Returns a string representation of this length in its original native form (as it is stored), without converting length value to some other unit type
      float to(byte unit)
      Converts the length to the given unit, if possible.
      float toPixel()
      Converts the length to a number of pixels, if possible.
      String toStringSpecified(byte unit)
      Returns a string representation of this length in specified unit type.
      static boolean tryParse(String input, Length[] result)
      Tries to parse a specified string as a Length value, including its numeric value and unit name
    • Field Detail

      • OneHundreedPercents

        public static final Length OneHundreedPercents

        100%

      • UnitlessZero

        public static final Length UnitlessZero

        Unitless integer zero - default value, the same as default parameterless constructor

      • ZeroPercents

        public static final Length ZeroPercents

        0%

    • Constructor Detail

      • Length

        public Length()
    • Method Detail

      • Clone

        public Length Clone()
        Specified by:
        Clone in class com.aspose.ms.System.ValueType<Length>
      • CloneTo

        public void CloneTo(Length that)
        Specified by:
        CloneTo in class com.aspose.ms.System.ValueType<Length>
      • deepClone

        public final Length deepClone()

        Returns a full copy of this Length instance

        Specified by:
        deepClone in interface com.aspose.ms.System.ICloneable
        Returns:
        New separate instance of this Length, that is absolutely identical to this one
      • equals

        public final boolean equals(com.groupdocs.editor.htmlcss.css.datatypes.ICssDataType other)
      • equals

        public final boolean equals(Length other)

        Defines whether this value is equal to the other specified length

        Parameters:
        other - Other instance of Length type
        Returns:
        True if equal, otherwise false
      • equals

        public static boolean equals(Length obj1,
                     Length obj2)
      • equals

        public boolean equals(Object obj)

        Determines whether this length is equal to specified object

        Specified by:
        equals in interface com.aspose.ms.System.IEquatable<com.groupdocs.editor.htmlcss.css.datatypes.ICssDataType>
        Overrides:
        equals in class Object
        Parameters:
        obj - Other instance of Length type, that is boxed to the System.Object or any other abstract type or interface
        Returns:
        True if equal, otherwise false
      • fromValueWithUnit

        public static Length fromValueWithUnit(double value,
                               byte unit)

        Creates and returns an instance of Length type by specified double number and unit

        Parameters:
        value - Any double (FP64) number, that will be converted to float (FP32)
        unit - Any valid unit type
        Returns:
        New instance of Length type
      • fromValueWithUnit

        public static Length fromValueWithUnit(float value,
                               byte unit)

        Creates and returns an instance of Length type by specified float number and unit

        Parameters:
        value - >Any float (FP32) number
        unit - Any valid unit type
        Returns:
        New instance of Length type
      • fromValueWithUnit

        public static Length fromValueWithUnit(int value,
                               byte unit)

        Creates and returns an instance of Length type by specified integer number and unit

        Parameters:
        value - Any integer number
        unit - Any valid unit type
        Returns:
        New instance of Length type
      • getFloatValue

        public final float getFloatValue()

        Returns a float numeric value of the Length instance. Never throws an exception - converts Integer value to Float if necessary.

      • getIntegerValue

        public final int getIntegerValue()

        Returns an integer numeric value of this Length instance, if it is internally stored as an integer, or throws an exception, if it was originally stored as a float number.

        Throws:
        com.aspose.ms.System.InvalidOperationException
      • getNumberType

        public final byte getNumberType()
      • getUnitFromName

        public static byte getUnitFromName(String unitName)

        Tries to parse specified unit name and return corresponding value of a Unit enum. Returns Unit.Unitless if cannot find appropriate unit.

        Parameters:
        unitName - String, that represents a unit name
        Returns:
        Value of Unit enum in any case, Unit.Unitless when cannot find appropriate unit
      • getUnitType

        public final byte getUnitType()

        Returns a unit type of this Length instance.

      • hashCode

        public int hashCode()

        Calculates and returns a hash-code of this Length instance by combining hash-codes of the value and unit type

        Overrides:
        hashCode in class Object
        Returns:
        Integer number
      • isAbsolute

        public final boolean isAbsolute()

        Gets if the length is given in absolute units. Such a length may be converted to pixels.

      • isDefault

        public final boolean isDefault()

        Indicates whether this Length instance has a default value — unitless zero. Same as IsUnitlessZero property.

        Specified by:
        isDefault in interface com.groupdocs.editor.htmlcss.css.datatypes.ICssDataType
      • isFloat

        public final boolean isFloat()

        Indicates whether the numeric value of this Length instance was originally specified and stored as a float (FP32) number

      • isInteger

        public final boolean isInteger()

        Indicates whether the numeric value of this Length instance was originally specified and stored as an integer (INT32) number

      • isNegative

        public final boolean isNegative()

        Determines whether the numeric value of this length is a negative number

      • isPositive

        public final boolean isPositive()

        Determines whether the numeric value of this length is a positive number

      • isRelative

        public final boolean isRelative()

        Gets if the length is given in relative units. Such a length cannot be converted to pixels.

      • isUnitlessNonZero

        public final boolean isUnitlessNonZero()

        The value has unitless type, but is not a zero - positive or negative number

      • isUnitlessZero

        public final boolean isUnitlessZero()

        Determines whether this instance is a unitless zero or not. Unitless zero is default value of this type. Same as IsDefault property.

      • isZero

        public final boolean isZero()

        Determines whether the numeric value of this length is a zero number

      • op_Equality

        public static boolean op_Equality(Length left,
                          Length right)

        Checks the equality of the two given lengths.

        Parameters:
        left - The left length operand.
        right - The right length operand.
        Returns:
        True if both lengths are equal, otherwise false.
      • op_Inequality

        public static boolean op_Inequality(Length left,
                            Length right)

        Checks the inequality of the two given lengths.

        Parameters:
        left - The left length operand.
        right - The right length operand.
        Returns:
        True if both lengths are not equal, otherwise false.
      • parse

        public static Length parse(String input)

        Parses and returns specified string as a Length value, including its numeric value and unit name, or throws an exception on failure

        Parameters:
        input -
        Returns:
      • serializeDefault

        public final String serializeDefault()

        Returns a string representation of this length in its original native form (as it is stored), without converting length value to some other unit type

        Specified by:
        serializeDefault in interface com.groupdocs.editor.htmlcss.css.datatypes.ICssDataType
        Returns:
        String instance
      • to

        public final float to(byte unit)

        Converts the length to the given unit, if possible. If the current or given unit is relative, then an exception will be thrown.

        Parameters:
        unit - The unit to convert to.
        Returns:
        The value in the given unit of the current length.
      • toPixel

        public final float toPixel()

        Converts the length to a number of pixels, if possible. If the current unit is relative, then an exception will be thrown.

        Returns:
        The number of pixels represented by the current length.
      • toStringSpecified

        public final String toStringSpecified(byte unit)

        Returns a string representation of this length in specified unit type. Numeric value will be converted in corresponding to unit type change.

        Parameters:
        unit - Specified unit, to which this instance should be converted before serializing to the string. Should be valid. Cannot be unitless.
        Returns:
        String representation
        Throws:
        com.aspose.ms.System.ComponentModel.InvalidEnumArgumentException - Value is not defined
        com.aspose.ms.System.ArgumentOutOfRangeException - Unitless value is prohibited
      • tryParse

        public static boolean tryParse(String input,
                       Length[] result)

        Tries to parse a specified string as a Length value, including its numeric value and unit name

        Parameters:
        input - Input string, that should be parsed
        result - Output parameter, that contains a result of parsing. If parsing is unsuccessful, contains a default Length value — a unitless zero.
        Returns:
        True if parsing is successful, false if unsuccessful