Package dap4.dap4lib

Class DMRPrinter


  • public class DMRPrinter
    extends Object
    DMR Printer. Given a constraint and a Dataset, print the constrained subset of the dataset.

    WARNING: the printDMR code in some cases duplicates code in dap4.dap4.Dap4Print; so changes here should be propagated.

    • Field Detail

      • GROUPSPECIAL

        protected static final String[] GROUPSPECIAL
      • VARSPECIAL

        protected static final String[] VARSPECIAL
      • RESERVEDTAGS

        protected static final String[] RESERVEDTAGS
      • printer

        protected dap4.core.util.IndentWriter printer
      • dmr

        protected dap4.core.dmr.DapDataset dmr
      • ce

        protected dap4.core.ce.CEConstraint ce
      • format

        protected dap4.core.util.ResponseFormat format
      • testing

        protected boolean testing
    • Constructor Detail

      • DMRPrinter

        protected DMRPrinter()
      • DMRPrinter

        public DMRPrinter​(dap4.core.dmr.DapDataset dmr,
                          PrintWriter writer)
      • DMRPrinter

        public DMRPrinter​(dap4.core.dmr.DapDataset dmr,
                          dap4.core.ce.CEConstraint ce,
                          PrintWriter writer,
                          dap4.core.util.ResponseFormat format)
    • Method Detail

      • flush

        public void flush()
      • close

        public void close()
      • print

        public void print()
                   throws IOException
        Print a DapDataset: - as DMR - optionally constrained
        Throws:
        IOException
      • testprint

        public void testprint()
                       throws IOException
        Same as print() except certain items of information are suppressed.
        Throws:
        IOException
      • printNode

        public void printNode​(dap4.core.dmr.DapNode node)
                       throws IOException
        Print an arbitrary DapNode and its subnodes as if it is being sent to a client with optional constraint; inclusions are determined by the view.

        Handling newlines is a bit tricky because they may be embedded for e.g. groups, enums, etc. So the rule is that the last newline is elided and left for the caller to print. Exceptions: printMetadata printDimrefs, printMaps

        Parameters:
        node - - the node to print
        Throws:
        IOException - Note that the PrintWriter is global.
      • printXMLAttribute

        protected void printXMLAttribute​(String name,
                                         String value,
                                         int flags)
                                  throws dap4.core.util.DapException
        PrintXMLAttributes helper function
        Parameters:
        name -
        value -
        flags -
        Throws:
        dap4.core.util.DapException
      • printReserved

        protected void printReserved​(dap4.core.dmr.DapNode node)
                              throws dap4.core.util.DapException
        Throws:
        dap4.core.util.DapException
      • printMetadata

        protected void printMetadata​(dap4.core.dmr.DapNode node)
                              throws IOException
        Throws:
        IOException
      • printContainerAttribute

        protected void printContainerAttribute​(dap4.core.dmr.DapAttribute attr)
      • printOtherXML

        protected void printOtherXML​(dap4.core.dmr.DapAttribute attr)
      • fqnXMLEscape

        public static String fqnXMLEscape​(String fqn)
        XML escape a dap fqn and converting '"' to " Assumes backslash escapes are in effect for '/' and '.'
        Parameters:
        fqn - the backslash escaped fqn
        Returns:
        escaped string
      • getPrintValue

        protected static String getPrintValue​(Object value)
      • hasMetadata

        protected boolean hasMetadata​(dap4.core.dmr.DapNode node)
      • hasMaps

        protected static boolean hasMaps​(dap4.core.dmr.DapVariable var)
      • hasDimensions

        protected static boolean hasDimensions​(dap4.core.dmr.DapVariable var)