Package dap4.core.dmr
Class DMRPrinter
- java.lang.Object
-
- dap4.core.dmr.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DMRPrinter.Controls
-
Field Summary
Fields Modifier and Type Field Description static boolean
ALLOWFIELDMAPS
protected CEConstraint
ce
protected EnumSet<DMRPrinter.Controls>
controls
protected DapContext
cxt
protected DapDataset
dmr
protected ResponseFormat
format
protected static String[]
GROUPSPECIAL
protected Map<DapVariable,Long>
localchecksummap
protected static int
NILFLAGS
protected static int
NONAME
protected static int
NONNIL
protected ByteOrder
order
protected static int
PERLINE
protected IndentWriter
printer
protected static String[]
RESERVEDTAGS
protected static String[]
VARSPECIAL
protected PrintWriter
writer
static String
XMLDOCUMENTHEADER
protected static int
XMLESCAPED
-
Constructor Summary
Constructors Modifier Constructor Description protected
DMRPrinter()
DMRPrinter(DapDataset dmr, CEConstraint ce, PrintWriter writer, ResponseFormat format)
DMRPrinter(DapDataset dmr, CEConstraint ce, PrintWriter writer, ResponseFormat format, DapContext cxt)
DMRPrinter(DapDataset dmr, PrintWriter writer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
flush()
static String
fqnXMLEscape(String fqn)
XML escape a dap fqn and converting '"' to " Assumes backslash escapes are in effect for '/' and '.'protected static String
getPrintValue(Object value)
protected boolean
hasDimensions(DapVariable var)
protected boolean
hasMaps(DapVariable var)
protected boolean
hasMetadata(DapNode node)
protected boolean
hasRequestData(DapVariable var)
void
print()
Print a DapDataset: - as DMR - optionally constrainedstatic void
print(DapDataset dmr, PrintStream stream)
static String
printAsString(DapDataset dmr)
protected void
printContainerAttribute(DapAttribute attr)
protected void
printMetadata(DapNode node)
boolean
printNode(DapNode node)
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.protected void
printOtherXML(DapAttribute attr)
protected void
printRequestData(DapVariable var)
Print request-specific per-variable data Like printRequestMetaData, this is nasty hack to avoid modifying the DMR.protected void
printReserved(DapNode node)
protected void
printXMLAttribute(String name, String value, int flags)
PrintXMLAttributes helper functionvoid
setControl(DMRPrinter.Controls ctl)
-
-
-
Field Detail
-
NILFLAGS
protected static final int NILFLAGS
- See Also:
- Constant Field Values
-
PERLINE
protected static final int PERLINE
- See Also:
- Constant Field Values
-
NONAME
protected static final int NONAME
- See Also:
- Constant Field Values
-
NONNIL
protected static final int NONNIL
- See Also:
- Constant Field Values
-
XMLESCAPED
protected static final int XMLESCAPED
- See Also:
- Constant Field Values
-
GROUPSPECIAL
protected static final String[] GROUPSPECIAL
-
VARSPECIAL
protected static final String[] VARSPECIAL
-
RESERVEDTAGS
protected static final String[] RESERVEDTAGS
-
ALLOWFIELDMAPS
public static final boolean ALLOWFIELDMAPS
- See Also:
- Constant Field Values
-
XMLDOCUMENTHEADER
public static final String XMLDOCUMENTHEADER
- See Also:
- Constant Field Values
-
writer
protected PrintWriter writer
-
printer
protected IndentWriter printer
-
dmr
protected DapDataset dmr
-
ce
protected CEConstraint ce
-
format
protected ResponseFormat format
-
cxt
protected DapContext cxt
-
order
protected ByteOrder order
-
localchecksummap
protected Map<DapVariable,Long> localchecksummap
-
controls
protected EnumSet<DMRPrinter.Controls> controls
-
-
Constructor Detail
-
DMRPrinter
protected DMRPrinter()
-
DMRPrinter
public DMRPrinter(DapDataset dmr, PrintWriter writer)
-
DMRPrinter
public DMRPrinter(DapDataset dmr, CEConstraint ce, PrintWriter writer, ResponseFormat format)
-
DMRPrinter
public DMRPrinter(DapDataset dmr, CEConstraint ce, PrintWriter writer, ResponseFormat format, DapContext cxt)
-
-
Method Detail
-
print
public static void print(DapDataset dmr, PrintStream stream)
-
printAsString
public static String printAsString(DapDataset dmr)
-
flush
public void flush()
-
close
public void close()
-
setControl
public void setControl(DMRPrinter.Controls ctl)
-
print
public void print() throws IOException
Print a DapDataset: - as DMR - optionally constrained- Throws:
IOException
-
printNode
public boolean printNode(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- Returns:
- true if anything was printed -- needed to control eol output
- Throws:
IOException
- Note that the PrintWriter is global.
-
printXMLAttribute
protected void printXMLAttribute(String name, String value, int flags) throws DapException
PrintXMLAttributes helper function- Parameters:
name
-value
-flags
-- Throws:
DapException
-
printReserved
protected void printReserved(DapNode node) throws DapException
- Throws:
DapException
-
printMetadata
protected void printMetadata(DapNode node) throws IOException
- Throws:
IOException
-
printContainerAttribute
protected void printContainerAttribute(DapAttribute attr)
-
printOtherXML
protected void printOtherXML(DapAttribute attr)
-
printRequestData
protected void printRequestData(DapVariable var) throws DapException
Print request-specific per-variable data Like printRequestMetaData, this is nasty hack to avoid modifying the DMR.- Parameters:
var
-- Throws:
DapException
-
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
-
hasMetadata
protected boolean hasMetadata(DapNode node)
-
hasMaps
protected boolean hasMaps(DapVariable var)
-
hasDimensions
protected boolean hasDimensions(DapVariable var)
-
hasRequestData
protected boolean hasRequestData(DapVariable var)
-
-