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 classDMRPrinter.Controls
-
Field Summary
Fields Modifier and Type Field Description static booleanALLOWFIELDMAPSprotected CEConstraintceprotected EnumSet<DMRPrinter.Controls>controlsprotected DapContextcxtprotected DapDatasetdmrprotected ResponseFormatformatprotected static String[]GROUPSPECIALprotected Map<DapVariable,Long>localchecksummapprotected static intNILFLAGSprotected static intNONAMEprotected static intNONNILprotected ByteOrderorderprotected static intPERLINEprotected IndentWriterprinterprotected static String[]RESERVEDTAGSprotected static String[]VARSPECIALprotected PrintWriterwriterstatic StringXMLDOCUMENTHEADERprotected static intXMLESCAPED
-
Constructor Summary
Constructors Modifier Constructor Description protectedDMRPrinter()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 voidclose()voidflush()static StringfqnXMLEscape(String fqn)XML escape a dap fqn and converting '"' to " Assumes backslash escapes are in effect for '/' and '.'protected static StringgetPrintValue(Object value)protected booleanhasDimensions(DapVariable var)protected booleanhasMaps(DapVariable var)protected booleanhasMetadata(DapNode node)protected booleanhasRequestData(DapVariable var)voidprint()Print a DapDataset: - as DMR - optionally constrainedstatic voidprint(DapDataset dmr, PrintStream stream)static StringprintAsString(DapDataset dmr)protected voidprintContainerAttribute(DapAttribute attr)protected voidprintMetadata(DapNode node)booleanprintNode(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 voidprintOtherXML(DapAttribute attr)protected voidprintRequestData(DapVariable var)Print request-specific per-variable data Like printRequestMetaData, this is nasty hack to avoid modifying the DMR.protected voidprintReserved(DapNode node)protected voidprintXMLAttribute(String name, String value, int flags)PrintXMLAttributes helper functionvoidsetControl(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 IOExceptionPrint 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)
-
-