Package org.apache.logging.log4j.util
Class StringBuilders
java.lang.Object
org.apache.logging.log4j.util.StringBuilders
Consider this class private.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringBuilderappendDqValue(StringBuilder sb, Object value) Appends in the following format: double quoted value.static StringBuilderappendKeyDqValue(StringBuilder sb, String key, Object value) Appends in the following format: key=double quoted value.static StringBuilderappendKeyDqValue(StringBuilder sb, Map.Entry<String, String> entry) Appends in the following format: key=double quoted value.static booleanappendSpecificTypes(StringBuilder stringBuilder, Object obj) static voidappendValue(StringBuilder stringBuilder, Object obj) Appends a text representation of the specified object to the specified StringBuilder, if possible without allocating temporary objects.static booleanequals(CharSequence left, int leftOffset, int leftLength, 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(CharSequence left, int leftOffset, int leftLength, 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(StringBuilder toAppendTo, int lastPos, char c) static voidescapeJson(StringBuilder toAppendTo, int start) static voidescapeXml(StringBuilder toAppendTo, int start) static voidtrimToMaxSize(StringBuilder stringBuilder, int maxSize) Ensures that the char[] array of the specified StringBuilder does not exceed the specified number of characters.
-
Constructor Details
-
StringBuilders
private StringBuilders()
-
-
Method Details
-
appendDqValue
Appends in the following format: double quoted value.- Parameters:
sb- a string buildervalue- a value- Returns:
"value"
-
appendKeyDqValue
Appends in the following format: key=double quoted value.- Parameters:
sb- a string builderentry- a map entry- Returns:
key="value"
-
appendKeyDqValue
Appends in the following format: key=double quoted value.- Parameters:
sb- a string builderkey- a keyvalue- a value- Returns:
- the specified StringBuilder
-
appendValue
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
-
equals
public static boolean equals(CharSequence left, int leftOffset, int leftLength, 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(CharSequence left, int leftOffset, int leftLength, 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
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
-
escapeAndDecrement
-
escapeXml
-