Package com.google.javascript.jscomp
Class VariableMap
- java.lang.Object
-
- com.google.javascript.jscomp.VariableMap
-
- All Implemented Interfaces:
java.io.Serializable
@Immutable public final class VariableMap extends java.lang.Object implements java.io.Serializable
Stores the mapping from original variable name to new variable names.- See Also:
RenameVars
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description VariableMap(java.util.Map<java.lang.String,java.lang.String> map)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static VariableMap
fromBytes(byte[] bytes)
Deserializes the variable map from a byte array returned bytoBytes()
.static VariableMap
fromMap(java.util.Map<java.lang.String,java.lang.String> map)
Initializes the variable map from an existing map.com.google.common.collect.ImmutableMap<java.lang.String,java.lang.String>
getNewNameToOriginalNameMap()
Returns an immutable mapping from new names to original names.com.google.common.collect.ImmutableMap<java.lang.String,java.lang.String>
getOriginalNameToNewNameMap()
Returns an immutable mapping from original names to new names.static VariableMap
load(java.lang.String filename)
Reads the variable map from a file written viasave(String)
.java.lang.String
lookupNewName(java.lang.String sourceName)
Given an original variable name, look up new name, may return null if it's not found.java.lang.String
lookupSourceName(java.lang.String newName)
Given a new variable name, lookup the source name, may return null if it's not found.void
save(java.lang.String filename)
Saves the variable map to a file.byte[]
toBytes()
Serializes the variable map to a byte array.
-
-
-
Method Detail
-
lookupNewName
public java.lang.String lookupNewName(java.lang.String sourceName)
Given an original variable name, look up new name, may return null if it's not found.
-
lookupSourceName
public java.lang.String lookupSourceName(java.lang.String newName)
Given a new variable name, lookup the source name, may return null if it's not found.
-
getOriginalNameToNewNameMap
public com.google.common.collect.ImmutableMap<java.lang.String,java.lang.String> getOriginalNameToNewNameMap()
Returns an immutable mapping from original names to new names.
-
getNewNameToOriginalNameMap
public com.google.common.collect.ImmutableMap<java.lang.String,java.lang.String> getNewNameToOriginalNameMap()
Returns an immutable mapping from new names to original names.
-
save
@GwtIncompatible("com.google.io.Files") public void save(java.lang.String filename) throws java.io.IOException
Saves the variable map to a file.- Throws:
java.io.IOException
-
load
@GwtIncompatible("java.io.File") public static VariableMap load(java.lang.String filename) throws java.io.IOException
Reads the variable map from a file written viasave(String)
.- Throws:
java.io.IOException
-
toBytes
@GwtIncompatible("java.io.ByteArrayOutputStream") public byte[] toBytes()
Serializes the variable map to a byte array.
-
fromBytes
@GwtIncompatible("com.google.common.base.Splitter.onPattern()") public static VariableMap fromBytes(byte[] bytes) throws java.text.ParseException
Deserializes the variable map from a byte array returned bytoBytes()
.- Throws:
java.text.ParseException
-
fromMap
public static VariableMap fromMap(java.util.Map<java.lang.String,java.lang.String> map)
Initializes the variable map from an existing map.- Parameters:
map
- The map to use from original names to generated names. It is copied and changes to the specified map will not affect the returned object.
-
-