Package com.google.javascript.jscomp
Class ReplacedStringsDecoder
- java.lang.Object
-
- com.google.javascript.jscomp.ReplacedStringsDecoder
-
@Immutable public final class ReplacedStringsDecoder extends java.lang.Object
A decoder for strings encoded by the ReplaceStrings JS compiler pass. This class is immutable.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ARGUMENT_PLACE_HOLDER
static ReplacedStringsDecoder
NULL_DECODER
A null decoder that does no mapping.
-
Constructor Summary
Constructors Constructor Description ReplacedStringsDecoder(VariableMap variableMap)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
decode(java.lang.String encodedStr)
Decodes an encoded string from the JS Compiler ReplaceStrings pass.
-
-
-
Field Detail
-
ARGUMENT_PLACE_HOLDER
public static final java.lang.String ARGUMENT_PLACE_HOLDER
- See Also:
- Constant Field Values
-
NULL_DECODER
public static final ReplacedStringsDecoder NULL_DECODER
A null decoder that does no mapping.
-
-
Constructor Detail
-
ReplacedStringsDecoder
public ReplacedStringsDecoder(VariableMap variableMap)
-
-
Method Detail
-
decode
public java.lang.String decode(java.lang.String encodedStr)
Decodes an encoded string from the JS Compiler ReplaceStrings pass.An original string with args might look like this:
Error('Some ' + arg1 + ' error ' + arg2 + ' message.');
Which gets replaced with:Error('key' + '`' + arg1 + '`' + arg2);
Where ` is the argument place holder. The replacement mapping would be:key → 'Some ` error ` message.'
Where key is some arbitrary replacement string. An encoded string, with args, from the client will look like:'key`arg1`arg2'
- Parameters:
encodedStr
- An encoded string.- Returns:
- The decoded string, or the encoded string if it fails to decode.
- See Also:
ReplaceStrings
-
-