private static void parseMessageTextNode ( Builder builder , Node node ) throws MalformedException { String value = extractStringFromStringExprNode ( node ) ; while ( true ) { int phBegin = value . indexOf ( PH_JS_PREFIX ) ; if ( phBegin < 0 ) { // Just a string literal builder . appendStringPart ( value ) ; return ; } else { if ( phBegin > 0 ) { // A string literal followed by a placeholder builder . appendStringPart ( value . substring ( 0 , phBegin ) ) ; } // A placeholder. Find where it ends int phEnd = value . indexOf ( PH_JS_SUFFIX , phBegin ) ; if ( phEnd < 0 ) { throw new MalformedException ( "Placeholder incorrectly formatted in: " + builder . getKey ( ) , node ) ; } String phName = value . substring ( phBegin + PH_JS_PREFIX . length ( ) , phEnd ) ; builder . appendPlaceholderReference ( phName ) ; int nextPos = phEnd + PH_JS_SUFFIX . length ( ) ; if ( nextPos < value . length ( ) ) { // Iterate on the rest of the message value value = value . substring ( nextPos ) ; } else { // The message is parsed return ; } } } }
Appends the message parts in a JS message value extracted from the given text node .