public void applyTranslations(TokenRewriteStream tokenRewriteStream, String programName) {
    for (Map.Entry<Integer, Translation> entry : translations.entrySet()) {
      if (entry.getKey() > 0) { // negative means the key didn't exist in the original
                                // stream (i.e.: we changed the tree)
        tokenRewriteStream.replace(
           programName,
           entry.getKey(),
           entry.getValue().tokenStopIndex,
           entry.getValue().replacementText);
      }
    }
    for (CopyTranslation copyTranslation : copyTranslations) {
      String replacementText = tokenRewriteStream.toString(
        programName,
        copyTranslation.sourceNode.getTokenStartIndex(),
        copyTranslation.sourceNode.getTokenStopIndex());
      String currentText = tokenRewriteStream.toString(
        programName,
        copyTranslation.targetNode.getTokenStartIndex(),
        copyTranslation.targetNode.getTokenStopIndex());
      if (currentText.equals(replacementText)) {
        // copy is a nop, so skip it--this is important for avoiding
        // spurious overlap assertions
        continue;
      }
      // Call addTranslation just to get the assertions for overlap
      // checking.
      addTranslation(copyTranslation.targetNode, replacementText);
      tokenRewriteStream.replace(
        programName,
        copyTranslation.targetNode.getTokenStartIndex(),
        copyTranslation.targetNode.getTokenStopIndex(),
        replacementText);
    }
  }
Apply all translations on the given token stream.

@param tokenRewriteStream
         rewrite-capable stream
ql/src/java/org/apache/hadoop/hive/ql/parse/UnparseTranslator.java