public class StandardUtilities
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
StandardUtilities.StringCompare<E>
Compares objects as strings.
|
| Modifier and Type | Field and Description |
|---|---|
static java.text.DecimalFormat |
KB_FORMAT |
static java.text.DecimalFormat |
MB_FORMAT |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
charsToEscapes(java.lang.String str)
Escapes newlines, tabs, backslashes, and quotes in the specified
string.
|
static java.lang.String |
charsToEscapes(java.lang.String str,
java.lang.String toEscape)
Escapes the specified characters in the specified string.
|
static int |
compareStrings(java.lang.String str1,
java.lang.String str2,
boolean ignoreCase)
Compares two strings.
|
static java.lang.String |
createWhiteSpace(int len,
int tabSize)
Creates a string of white space with the specified length.
|
static java.lang.String |
createWhiteSpace(int len,
int tabSize,
int start)
Creates a string of white space with the specified length.
|
static java.lang.String |
formatFileSize(long length)
Formats the given file size into a nice string (123 Bytes, 10.6 kB,
1.2 MB).
|
static boolean |
getBoolean(java.lang.Object obj,
boolean def)
Returns a boolean from a given object.
|
static java.lang.String |
getIndentString(java.lang.String str) |
static int |
getLeadingWhiteSpace(java.lang.CharSequence str)
Returns the number of leading white space characters in the
specified string.
|
static int |
getLeadingWhiteSpace(java.lang.String str)
Returns the number of leading white space characters in the
specified string.
|
static int |
getLeadingWhiteSpaceWidth(java.lang.CharSequence str,
int tabSize)
Returns the width of the leading white space in the specified
string.
|
static int |
getLeadingWhiteSpaceWidth(java.lang.String str,
int tabSize)
Returns the width of the leading white space in the specified
string.
|
static int |
getOffsetOfVirtualColumn(javax.swing.text.Segment seg,
int tabSize,
int column,
int[] totalVirtualWidth)
Returns the array offset of a virtual column number (taking tabs
into account) in the segment.
|
static int |
getTrailingWhiteSpace(java.lang.String str)
Returns the number of trailing whitespace characters in the
specified string.
|
static int |
getVirtualWidth(javax.swing.text.Segment seg,
int tabSize)
Returns the virtual column number (taking tabs into account) of the
specified offset in the segment.
|
static java.lang.String |
globToRE(java.lang.String glob)
Converts a Unix-style glob to a regular expression.
|
static byte[] |
md5(java.lang.CharSequence charSequence)
Returns the md5sum for given string.
|
static boolean |
objectsEqual(java.lang.Object o1,
java.lang.Object o2)
Deprecated.
use {java.util.Objects#equals(Object, Object}
|
static boolean |
regionMatches(java.lang.CharSequence seq,
int toff,
java.lang.CharSequence other,
int ooff,
int len)
Implementation of String.regionMatches() for CharSequence.
|
static boolean |
startsWith(java.lang.CharSequence seq,
java.lang.String str)
Implementation of String.startsWith() for CharSequence.
|
static java.lang.String |
truncateWhiteSpace(int len,
int tabSize,
java.lang.String indentStr) |
public static final java.text.DecimalFormat KB_FORMAT
public static final java.text.DecimalFormat MB_FORMAT
public static java.lang.String charsToEscapes(java.lang.String str)
str - The stringpublic static java.lang.String charsToEscapes(java.lang.String str,
java.lang.String toEscape)
str - The stringtoEscape - Any characters that require escapingpublic static java.lang.String getIndentString(java.lang.String str)
str - A java stringpublic static int getLeadingWhiteSpace(java.lang.String str)
str - The stringpublic static int getLeadingWhiteSpace(java.lang.CharSequence str)
str - The stringpublic static int getTrailingWhiteSpace(java.lang.String str)
str - The stringpublic static int getLeadingWhiteSpaceWidth(java.lang.String str,
int tabSize)
str - The stringtabSize - The tab sizepublic static int getLeadingWhiteSpaceWidth(java.lang.CharSequence str,
int tabSize)
str - The stringtabSize - The tab sizepublic static java.lang.String createWhiteSpace(int len,
int tabSize)
To get a whitespace string tuned to the current buffer's settings, call this method as follows:
myWhitespace = MiscUtilities.createWhiteSpace(myLength,
(buffer.getBooleanProperty("noTabs") ? 0
: buffer.getTabSize()));len - The lengthtabSize - The tab size, or 0 if tabs are not to be usedpublic static java.lang.String truncateWhiteSpace(int len,
int tabSize,
java.lang.String indentStr)
public static java.lang.String createWhiteSpace(int len,
int tabSize,
int start)
To get a whitespace string tuned to the current buffer's settings, call this method as follows:
myWhitespace = MiscUtilities.createWhiteSpace(myLength,
(buffer.getBooleanProperty("noTabs") ? 0
: buffer.getTabSize()));len - The lengthtabSize - The tab size, or 0 if tabs are not to be usedstart - The start offset, for tab alignmentpublic static int getVirtualWidth(javax.swing.text.Segment seg,
int tabSize)
seg - The segmenttabSize - The tab sizepublic static int getOffsetOfVirtualColumn(javax.swing.text.Segment seg,
int tabSize,
int column,
int[] totalVirtualWidth)
seg - The segmenttabSize - The tab sizecolumn - The virtual column numbertotalVirtualWidth - If this array is non-null, the total
virtual width will be stored in its first location if this method
returns -1.public static int compareStrings(java.lang.String str1,
java.lang.String str2,
boolean ignoreCase)
Unlike
str1 - The first stringstr2 - The second stringignoreCase - If true, case will be ignored@Deprecated
public static boolean objectsEqual(@Nullable
java.lang.Object o1,
@Nullable
java.lang.Object o2)
o1.equals(o2).public static java.lang.String globToRE(java.lang.String glob)
? becomes ., * becomes .*, {aa,bb} becomes (aa|bb).
glob - The glob patternpublic static boolean regionMatches(java.lang.CharSequence seq,
int toff,
java.lang.CharSequence other,
int ooff,
int len)
seq - The test CharSequence.toff - Offset for the test sequence.other - The sequence to compare to.ooff - Offset of the comparison sequence.len - How many characters to compare.String.regionMatches(int,String,int,int)public static boolean startsWith(java.lang.CharSequence seq,
java.lang.String str)
seq - The CharSequence.str - String to test.public static boolean getBoolean(java.lang.Object obj,
boolean def)
obj - the objectdef - The default valuepublic static java.lang.String formatFileSize(long length)
length - The sizepublic static byte[] md5(java.lang.CharSequence charSequence)
charSequence - Given string