Class SmapUtil


  • public class SmapUtil
    extends java.lang.Object
    Contains static utilities for generating SMAP data based on the current version of Jasper.
    • Constructor Summary

      Constructors 
      Constructor Description
      SmapUtil()
      Default constructor.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void evaluateNodes​(Node.Nodes nodes, SmapStratum s, java.util.HashMap<java.lang.String,​SmapStratum> innerClassMap, boolean breakAtLF)
      Traverses the JSP AST nodes and populates the given SmapStratum with line mapping data.
      static java.util.Map<java.lang.String,​SmapStratum> generateSmap​(JspCompilationContext ctxt, Node.Nodes pageNodes)
      Generates an appropriate SMAP representing the current compilation context.
      static void installSmap​(java.util.Map<java.lang.String,​SmapStratum> smapInfo)
      Installs SMAP data into the compiled class files by writing the SourceDebugExtension attribute.
      static SmapStratum loadSmap​(java.lang.String className, java.lang.ClassLoader cl)
      Loads SMAP data for the given class by reading the embedded SourceDebugExtension attribute from the class file or an external .smap resource.
      • Methods inherited from class java.lang.Object

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

      • SmapUtil

        public SmapUtil()
        Default constructor.
    • Method Detail

      • generateSmap

        public static java.util.Map<java.lang.String,​SmapStratum> generateSmap​(JspCompilationContext ctxt,
                                                                                     Node.Nodes pageNodes)
                                                                              throws java.io.IOException
        Generates an appropriate SMAP representing the current compilation context. (JSR-045.)
        Parameters:
        ctxt - Current compilation context
        pageNodes - The current JSP page
        Returns:
        a SMAP for the page
        Throws:
        java.io.IOException - Error writing SMAP
      • installSmap

        public static void installSmap​(java.util.Map<java.lang.String,​SmapStratum> smapInfo)
                                throws java.io.IOException
        Installs SMAP data into the compiled class files by writing the SourceDebugExtension attribute.
        Parameters:
        smapInfo - the SMAP data keyed by fully qualified class name
        Throws:
        java.io.IOException - if an I/O error occurs while writing class files
      • evaluateNodes

        public static void evaluateNodes​(Node.Nodes nodes,
                                         SmapStratum s,
                                         java.util.HashMap<java.lang.String,​SmapStratum> innerClassMap,
                                         boolean breakAtLF)
        Traverses the JSP AST nodes and populates the given SmapStratum with line mapping data.
        Parameters:
        nodes - the root JSP AST nodes
        s - the stratum to populate with line mappings
        innerClassMap - map to collect SMAP data for inner classes
        breakAtLF - whether to generate a mapping for each line feed in template text
      • loadSmap

        public static SmapStratum loadSmap​(java.lang.String className,
                                           java.lang.ClassLoader cl)
        Loads SMAP data for the given class by reading the embedded SourceDebugExtension attribute from the class file or an external .smap resource.
        Parameters:
        className - the fully qualified class name
        cl - the class loader to use for loading the resource
        Returns:
        the parsed SmapStratum, or null if no or invalid SMAP data is found