Package com.independentsoft.office
Class Util
java.lang.Object
com.independentsoft.office.Util
The Class Util.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringconvertColumnIndex(int column)Convert column index.static intconvertColumnIndex(String column)Convert column index.static StringdecodeEscapeCharacters(String input)Decode escape characters.static StringencodeEscapeCharacters(String input)Encode escape characters.static StringEncode escape characters with special characters.static StringformatVmlNumber(double value)Formats a VML numeric value, omitting a redundant trailing ".0" for whole numbers (e.g.static intGets the next random.static StringgetRelationshipFilePath(String filePath)Gets the relationship file path.static StringgetRootExtraNamespacesAndIgnorable(XMLStreamReader reader, Set<String> skipPrefixes)Captures, from a part's root start element, the namespace declarations (excluding the default namespace and any prefix inskipPrefixesthe caller already emits) plus anmc:Ignorableattribute, as a string to append to the re-emitted root tag.static StringhashPassword(String password)Hash password.static booleanparseBoolean(String input)Parses the boolean.static DateParses the date.static DateParses the date.static intParses an integer attribute value tolerantly: tries a plain integer first, then falls back to parsing a decimal (e.g.static intParses an integer attribute value in the given radix (e.g.static intparseInteger(String input)Parses the integer.static intparseIntegerPercent(String input)Parses the integer percent.static StringreplaceFileNameEscapeCharacters(String fileName)Replace file name escape characters.static StringtoLocalTime(Date date)To local time.static StringtoUniversalTime(Date date)To universal time.static StringTrim.
-
Field Details
-
S
-
W
-
P
-
P14
-
MC
-
-
Constructor Details
-
Util
public Util()
-
-
Method Details
-
formatVmlNumber
Formats a VML numeric value, omitting a redundant trailing ".0" for whole numbers (e.g. the integer-valued o:spt shape-type id).Double.toStringwould 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 inskipPrefixesthe caller already emits) plus anmc:Ignorableattribute, 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 asx14ac:knownFonts/x14ac:dyDescentstay well-formed.- Parameters:
reader- positioned on the root start elementskipPrefixes- 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
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
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 valueradix- the radix- Returns:
- the parsed integer, or 0 if it cannot be parsed
-
encodeEscapeCharacters
Encode escape characters.- Parameters:
input- the input- Returns:
- the string
-
replaceFileNameEscapeCharacters
Replace file name escape characters.- Parameters:
fileName- the file name- Returns:
- the string
-
encodeEscapeCharactersWithSpecialCharacters
Encode escape characters with special characters.- Parameters:
input- the input- Returns:
- the string
-
decodeEscapeCharacters
Decode escape characters.- Parameters:
input- the input- Returns:
- the string
-
convertColumnIndex
Convert column index.- Parameters:
column- the column- Returns:
- the string
-
convertColumnIndex
Convert column index.- Parameters:
column- the column- Returns:
- the int
-
trim
Trim.- Parameters:
input- the inputcharacter- the character- Returns:
- the string
-
parseDate
Parses the date.- Parameters:
utcDate- the utc date- Returns:
- the date
-
parseDate
Parses the date.- Parameters:
utcDate- the utc dateformat- the format- Returns:
- the date
-
toUniversalTime
To universal time.- Parameters:
date- the date- Returns:
- the string
-
toLocalTime
To local time.- Parameters:
date- the date- Returns:
- the string
-
getNextRandom
public static int getNextRandom()Gets the next random.- Returns:
- the next random
-
getRelationshipFilePath
Gets the relationship file path.- Parameters:
filePath- the file path- Returns:
- the relationship file path
-
hashPassword
Hash password.- Parameters:
password- the password- Returns:
- the string
-
parseBoolean
Parses the boolean.- Parameters:
input- the input- Returns:
- true, if successful
-
parseInteger
Parses the integer.- Parameters:
input- the input- Returns:
- the int
-
parseIntegerPercent
Parses the integer percent.- Parameters:
input- the input- Returns:
- the int
-