Package org.apache.logging.log4j.util
Class StringBuilders
- java.lang.Object
-
- org.apache.logging.log4j.util.StringBuilders
-
public final class StringBuilders extends java.lang.ObjectConsider this class private.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.Class<?>timeClass
-
Constructor Summary
Constructors Modifier Constructor Description privateStringBuilders()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringBuilderappendDqValue(java.lang.StringBuilder sb, java.lang.Object value)Appends in the following format: double quoted value.static java.lang.StringBuilderappendKeyDqValue(java.lang.StringBuilder sb, java.lang.String key, java.lang.Object value)Appends in the following format: key=double quoted value.static java.lang.StringBuilderappendKeyDqValue(java.lang.StringBuilder sb, java.util.Map.Entry<java.lang.String,java.lang.String> entry)Appends in the following format: key=double quoted value.static booleanappendSpecificTypes(java.lang.StringBuilder stringBuilder, java.lang.Object obj)static voidappendValue(java.lang.StringBuilder stringBuilder, java.lang.Object obj)Appends a text representation of the specified object to the specified StringBuilder, if possible without allocating temporary objects.static booleanequals(java.lang.CharSequence left, int leftOffset, int leftLength, java.lang.CharSequence right, int rightOffset, int rightLength)Returns true if the specified section of the left CharSequence equals the specified section of the right CharSequence.static booleanequalsIgnoreCase(java.lang.CharSequence left, int leftOffset, int leftLength, java.lang.CharSequence right, int rightOffset, int rightLength)Returns true if the specified section of the left CharSequence equals, ignoring case, the specified section of the right CharSequence.private static intescapeAndDecrement(java.lang.StringBuilder toAppendTo, int lastPos, char c)static voidescapeJson(java.lang.StringBuilder toAppendTo, int start)static voidescapeXml(java.lang.StringBuilder toAppendTo, int start)private static booleanisTime(java.lang.Object obj)static voidtrimToMaxSize(java.lang.StringBuilder stringBuilder, int maxSize)Ensures that the char[] array of the specified StringBuilder does not exceed the specified number of characters.
-
-
-
Method Detail
-
appendDqValue
public static java.lang.StringBuilder appendDqValue(java.lang.StringBuilder sb, java.lang.Object value)Appends in the following format: double quoted value.- Parameters:
sb- a string buildervalue- a value- Returns:
"value"
-
appendKeyDqValue
public static java.lang.StringBuilder appendKeyDqValue(java.lang.StringBuilder sb, java.util.Map.Entry<java.lang.String,java.lang.String> entry)Appends in the following format: key=double quoted value.- Parameters:
sb- a string builderentry- a map entry- Returns:
key="value"
-
appendKeyDqValue
public static java.lang.StringBuilder appendKeyDqValue(java.lang.StringBuilder sb, java.lang.String key, java.lang.Object value)Appends in the following format: key=double quoted value.- Parameters:
sb- a string builderkey- a keyvalue- a value- Returns:
- the specified StringBuilder
-
appendValue
public static void appendValue(java.lang.StringBuilder stringBuilder, java.lang.Object obj)Appends a text representation of the specified object to the specified StringBuilder, if possible without allocating temporary objects.- Parameters:
stringBuilder- the StringBuilder to append the value toobj- the object whose text representation to append to the StringBuilder
-
appendSpecificTypes
public static boolean appendSpecificTypes(java.lang.StringBuilder stringBuilder, java.lang.Object obj)
-
isTime
private static boolean isTime(java.lang.Object obj)
-
equals
public static boolean equals(java.lang.CharSequence left, int leftOffset, int leftLength, java.lang.CharSequence right, int rightOffset, int rightLength)Returns true if the specified section of the left CharSequence equals the specified section of the right CharSequence.- Parameters:
left- the left CharSequenceleftOffset- start index in the left CharSequenceleftLength- length of the section in the left CharSequenceright- the right CharSequence to compare a section ofrightOffset- start index in the right CharSequencerightLength- length of the section in the right CharSequence- Returns:
- true if equal, false otherwise
-
equalsIgnoreCase
public static boolean equalsIgnoreCase(java.lang.CharSequence left, int leftOffset, int leftLength, java.lang.CharSequence right, int rightOffset, int rightLength)Returns true if the specified section of the left CharSequence equals, ignoring case, the specified section of the right CharSequence.- Parameters:
left- the left CharSequenceleftOffset- start index in the left CharSequenceleftLength- length of the section in the left CharSequenceright- the right CharSequence to compare a section ofrightOffset- start index in the right CharSequencerightLength- length of the section in the right CharSequence- Returns:
- true if equal ignoring case, false otherwise
-
trimToMaxSize
public static void trimToMaxSize(java.lang.StringBuilder stringBuilder, int maxSize)Ensures that the char[] array of the specified StringBuilder does not exceed the specified number of characters. This method is useful to ensure that excessively long char[] arrays are not kept in memory forever.- Parameters:
stringBuilder- the StringBuilder to checkmaxSize- the maximum number of characters the StringBuilder is allowed to have- Since:
- 2.9
-
escapeJson
public static void escapeJson(java.lang.StringBuilder toAppendTo, int start)
-
escapeAndDecrement
private static int escapeAndDecrement(java.lang.StringBuilder toAppendTo, int lastPos, char c)
-
escapeXml
public static void escapeXml(java.lang.StringBuilder toAppendTo, int start)
-
-