Class SourceMapWriter


  • public class SourceMapWriter
    extends java.lang.Object
    Generates Source Map version 3. https://sourcemaps.info/spec.html
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private class  SourceMapWriter.Generator
      The generator of the source map
    • Constructor Summary

      Constructors 
      Constructor Description
      SourceMapWriter​(java.lang.String sourceRoot)
      Create a new instance of the writer for a single map file.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addMapping​(SourceMapping mapping)
      Adds a mapping for the given node.
      private static void appendJsonField​(java.lang.Appendable out, java.lang.String name, java.lang.CharSequence value)
      Write the field name to JSON source map.
      private static void appendQuoteString​(java.lang.Appendable out, java.lang.String str)
      Write a quoted string to the JSON.
      private void appendSourceFileNames​(java.lang.Appendable out)
      Write source file names.
      void generate​(java.lang.Appendable out)
      https://sourcemaps.info/spec.html
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • sourceRoot

        private final java.lang.String sourceRoot
      • sourceFileNames

        private final java.util.LinkedHashMap<java.lang.String,​java.lang.Integer> sourceFileNames
      • nextSourceFileNameIndex

        private int nextSourceFileNameIndex
    • Constructor Detail

      • SourceMapWriter

        public SourceMapWriter​(@Nullable
                               java.lang.String sourceRoot)
        Create a new instance of the writer for a single map file.
        Parameters:
        sourceRoot - optional absolute or relative path to the sources
    • Method Detail

      • addMapping

        public void addMapping​(SourceMapping mapping)
        Adds a mapping for the given node. Mappings must be added in order.
        Parameters:
        mapping - the mapping
      • generate

        public void generate​(java.lang.Appendable out)
                      throws java.io.IOException
        https://sourcemaps.info/spec.html
        Parameters:
        out - the target
        Throws:
        java.io.IOException - if any I/O error occur
      • appendSourceFileNames

        private void appendSourceFileNames​(java.lang.Appendable out)
                                    throws java.io.IOException
        Write source file names.
        Parameters:
        out - the target
        Throws:
        java.io.IOException - if any I/O error occur
      • appendJsonField

        private static void appendJsonField​(java.lang.Appendable out,
                                            java.lang.String name,
                                            java.lang.CharSequence value)
                                     throws java.io.IOException
        Write the field name to JSON source map.
        Parameters:
        out - the target
        name - the field name
        value - optional value
        Throws:
        java.io.IOException - if any I/O error occur
      • appendQuoteString

        private static void appendQuoteString​(java.lang.Appendable out,
                                              java.lang.String str)
                                       throws java.io.IOException
        Write a quoted string to the JSON.
        Parameters:
        out - the target
        str - the unquoted string
        Throws:
        java.io.IOException - if any I/O error occur