public static SoyMsgRawTextPart of ( String rawText ) { int utf8Length = Utf8 . encodedLength ( rawText ) ; // Determine whether UTF8 or UTF16 uses less memory, and choose between one of the two internal // implementations. char[] is preferred if the sizes are equal because it is faster to turn // back into a String. In a realistic application with 1 million messages in memory, using // UTF-8 saves about 35M, and dynamicaly switching encodings saves another 10M. // IMPORTANT! This choice is deterministic, so that for any particular input string the choice // of implementation class is the same. This ensures operations like equals() and hashCode() // do not have to decode the contents. if ( utf8Length < rawText . length ( ) * BYTES_PER_CHAR ) { return new Utf8SoyMsgRawTextPart ( rawText ) ; } else { return new CharArraySoyMsgRawTextPart ( rawText ) ; } }
Returns a SoyMsgRawTextPart representing the specified raw text string .