Class Util

java.lang.Object
com.independentsoft.office.Util

public class Util extends Object
The Class Util.
  • Field Details

  • Constructor Details

    • Util

      public Util()
  • Method Details

    • formatVmlNumber

      public static String formatVmlNumber(double value)
      Formats a VML numeric value, omitting a redundant trailing ".0" for whole numbers (e.g. the integer-valued o:spt shape-type id). Double.toString would render 202 as "202.0", which does not round-trip.
      Parameters:
      value - the value
      Returns:
      the formatted value
    • getRootExtraNamespacesAndIgnorable

      public static String getRootExtraNamespacesAndIgnorable(XMLStreamReader reader, Set<String> skipPrefixes)
      Captures, from a part's root start element, the namespace declarations (excluding the default namespace and any prefix in skipPrefixes the caller already emits) plus an mc:Ignorable attribute, as a string to append to the re-emitted root tag. Round-trips MCE markers (e.g. mc:Ignorable="x14ac") together with the namespaces they reference, so attributes such as x14ac:knownFonts / x14ac:dyDescent stay well-formed.
      Parameters:
      reader - positioned on the root start element
      skipPrefixes - prefixes already declared on the re-emitted root (may be null)
      Returns:
      the extra attribute string (each token has a leading space), or "" if none
    • parseInt

      public static int parseInt(String value)
      Parses an integer attribute value tolerantly: tries a plain integer first, then falls back to parsing a decimal (e.g. fractional twips/EMU such as "11905.511811023622") and truncating toward zero, returning 0 when neither parses. Mirrors the C# Util.ParseInt (invariant-culture). Java's Integer/Double parsing is already locale-independent.
      Parameters:
      value - the attribute value
      Returns:
      the parsed integer, or 0 if it cannot be parsed
    • parseInt

      public static int parseInt(String value, int radix)
      Parses an integer attribute value in the given radix (e.g. radix 16 for hex theme shade/tint), returning 0 when it cannot be parsed. Tolerant counterpart of Integer.parseInt(value, radix).
      Parameters:
      value - the attribute value
      radix - the radix
      Returns:
      the parsed integer, or 0 if it cannot be parsed
    • encodeEscapeCharacters

      public static String encodeEscapeCharacters(String input)
      Encode escape characters.
      Parameters:
      input - the input
      Returns:
      the string
    • replaceFileNameEscapeCharacters

      public static String replaceFileNameEscapeCharacters(String fileName)
      Replace file name escape characters.
      Parameters:
      fileName - the file name
      Returns:
      the string
    • encodeEscapeCharactersWithSpecialCharacters

      public static String encodeEscapeCharactersWithSpecialCharacters(String input)
      Encode escape characters with special characters.
      Parameters:
      input - the input
      Returns:
      the string
    • decodeEscapeCharacters

      public static String decodeEscapeCharacters(String input)
      Decode escape characters.
      Parameters:
      input - the input
      Returns:
      the string
    • convertColumnIndex

      public static String convertColumnIndex(int column)
      Convert column index.
      Parameters:
      column - the column
      Returns:
      the string
    • convertColumnIndex

      public static int convertColumnIndex(String column)
      Convert column index.
      Parameters:
      column - the column
      Returns:
      the int
    • trim

      public static String trim(String input, String character)
      Trim.
      Parameters:
      input - the input
      character - the character
      Returns:
      the string
    • parseDate

      public static Date parseDate(String utcDate)
      Parses the date.
      Parameters:
      utcDate - the utc date
      Returns:
      the date
    • parseDate

      public static Date parseDate(String utcDate, String format)
      Parses the date.
      Parameters:
      utcDate - the utc date
      format - the format
      Returns:
      the date
    • toUniversalTime

      public static String toUniversalTime(Date date)
      To universal time.
      Parameters:
      date - the date
      Returns:
      the string
    • toLocalTime

      public static String toLocalTime(Date date)
      To local time.
      Parameters:
      date - the date
      Returns:
      the string
    • getNextRandom

      public static int getNextRandom()
      Gets the next random.
      Returns:
      the next random
    • getRelationshipFilePath

      public static String getRelationshipFilePath(String filePath)
      Gets the relationship file path.
      Parameters:
      filePath - the file path
      Returns:
      the relationship file path
    • hashPassword

      public static String hashPassword(String password)
      Hash password.
      Parameters:
      password - the password
      Returns:
      the string
    • parseBoolean

      public static boolean parseBoolean(String input)
      Parses the boolean.
      Parameters:
      input - the input
      Returns:
      true, if successful
    • parseInteger

      public static int parseInteger(String input)
      Parses the integer.
      Parameters:
      input - the input
      Returns:
      the int
    • parseIntegerPercent

      public static int parseIntegerPercent(String input)
      Parses the integer percent.
      Parameters:
      input - the input
      Returns:
      the int