Top Inners Fields Constructors Methods
org.apache.poi.util

public Class GenericRecordJsonWriter

extends Object
implements Closeable
Class Inheritance
All Implemented Interfaces
java.io.Closeable, java.lang.AutoCloseable
Annotations
@SuppressWarnings:UnusedReturnValue, WeakerAccess
@Beta
Imports
java.awt.Color, java.awt.geom.AffineTransform, .Dimension2D, .Path2D, .PathIterator, .Point2D, .Rectangle2D, java.awt.image.BufferedImage, .ColorModel, .ComponentColorModel, .DirectColorModel, .IndexColorModel, .PackedColorModel, java.io.Closeable, .File, .Flushable, .IOException, .OutputStream, .OutputStreamWriter, .PrintWriter, .Writer, java.lang.reflect.Array, java.nio.charset.StandardCharsets, java.nio.file.Files, java.util.AbstractMap, .ArrayList, .Arrays, .Base64, .List, .Map, java.util.function.Supplier, java.util.regex.Matcher, .Pattern, org.apache.commons.io.output.NullOutputStream, org.apache.poi.common.usermodel.GenericRecord, org.apache.poi.util.GenericRecordUtil.AnnotatedFlag

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
protected static interface

Field Summary

Modifier and TypeField and Description
protected final GenericRecordJsonWriter.AppendableWriter
protected int
private static final Pattern
protected final PrintWriter
private static final List<Map.Entry<Class<?>, GenericRecordJsonWriter.GenericRecordHandler>>
protected int
private static final String
private static final String
protected boolean
private static final String

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.

private static void
public static String
public static String
marshal(GenericRecord record, boolean withComments)

protected static boolean
matchInstanceOrArray(Class<?> key, Object instance)

protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected void
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
public void
setWithComments(boolean withComments)

protected String
tabs()

pack-priv static String
trimHex(final long l, final int size)

public void
protected boolean
writeChildren(GenericRecord record, boolean hasProperties)

public void
writeError(String errorMsg)

protected boolean
writeProp(String name, Supplier<?> value)

protected boolean
protected boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

awback to summary
protected final GenericRecordJsonWriter.AppendableWriter aw
childIndexback to summary
protected int childIndex
ESC_CHARSback to summary
private static final Pattern ESC_CHARS
fwback to summary
protected final PrintWriter fw
handlerback to summary
private static final List<Map.Entry<Class<?>, GenericRecordJsonWriter.GenericRecordHandler>> handler
indentback to summary
protected int indent
NLback to summary
private static final String NL
TABSback to summary
private static final String TABS
withCommentsback to summary
protected boolean withComments
ZEROSback to summary
private static final String ZEROS

Constructor Detail

GenericRecordJsonWriterback to summary
public GenericRecordJsonWriter(File fileName) throws IOException
GenericRecordJsonWriterback to summary
public GenericRecordJsonWriter(Appendable buffer)

Method Detail

closeback to summary
public void close() throws IOException

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
handlerback to summary
private static void handler(Class<?> c, GenericRecordJsonWriter.GenericRecordHandler printer)
marshalback to summary
public static String marshal(GenericRecord record)
marshalback to summary
public static String marshal(GenericRecord record, boolean withComments)
matchInstanceOrArrayback to summary
protected static boolean matchInstanceOrArray(Class<?> key, Object instance)
printAffineTransformback to summary
protected boolean printAffineTransform(String name, Object o)
printAnnotatedFlagback to summary
protected boolean printAnnotatedFlag(String name, Object o)
printArrayback to summary
protected boolean printArray(String name, Object o)
printBooleanback to summary
protected boolean printBoolean(String name, Object o)
printBytesback to summary
protected boolean printBytes(String name, Object o)
printColorback to summary
protected boolean printColor(String name, Object o)
printDimensionback to summary
protected boolean printDimension(String name, Object o)
printGenericRecordback to summary
protected boolean printGenericRecord(String name, Object o)
printImageback to summary
protected boolean printImage(String name, Object o)
printListback to summary
protected boolean printList(String name, Object o)
printNameback to summary
protected void printName(String name)
printNullback to summary
protected boolean printNull(String name, Object o)
printNumberback to summary
protected boolean printNumber(String name, Object o)
Annotations
@SuppressWarnings:java:S3516
printObjectback to summary
protected boolean printObject(String name, Object o)
printPathback to summary
protected boolean printPath(String name, Object o)
printPointback to summary
protected boolean printPoint(String name, Object o)
printRectangleback to summary
protected boolean printRectangle(String name, Object o)
setWithCommentsback to summary
public void setWithComments(boolean withComments)
tabsback to summary
protected String tabs()
trimHexback to summary
pack-priv static String trimHex(final long l, final int size)
writeback to summary
public void write(GenericRecord record)
writeChildrenback to summary
protected boolean writeChildren(GenericRecord record, boolean hasProperties)
writeErrorback to summary
public void writeError(String errorMsg)
writePropback to summary
protected boolean writeProp(String name, Supplier<?> value)
writePropertiesback to summary
protected boolean writeProperties(GenericRecord record)
writeValueback to summary
protected boolean writeValue(String name, Object o)
org.apache.poi.util back to summary

pack-priv Class GenericRecordJsonWriter.AppendableWriter

extends Writer
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Appendable
private String
private final Writer
Inherited from java.io.Writer:
lock

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements abstract java.io.Writer.close.

Implements java.io.Closeable.close.

Closes the stream, flushing it first.

public void
flush()

Implements abstract java.io.Writer.flush.

Implements java.io.Flushable.flush.

Flushes the stream.

pack-priv void
setHoldBack(String holdBack)

public void
write(char[]
Array of characters
cbuf
,
int
Offset from which to start writing characters
off
,
int
Number of characters to write
len
)

Implements abstract java.io.Writer.write.

Writes a portion of an array of characters.

Inherited from java.io.Writer:
appendappendappendnullWriterwritewritewritewrite

Field Detail

appenderback to summary
private final Appendable appender
holdBackback to summary
private String holdBack
writerback to summary
private final Writer writer

Constructor Detail

AppendableWriterback to summary
pack-priv AppendableWriter(Appendable buffer)
AppendableWriterback to summary
pack-priv AppendableWriter(Writer writer)

Method Detail

closeback to summary
public void close() throws IOException

Implements abstract java.io.Writer.close.

Implements java.io.Closeable.close.

Doc from java.io.Writer.close.

Closes the stream, flushing it first. Once the stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously closed stream has no effect.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
flushback to summary
public void flush() throws IOException

Implements abstract java.io.Writer.flush.

Implements java.io.Flushable.flush.

Doc from java.io.Writer.flush.

Flushes the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams.

If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
setHoldBackback to summary
pack-priv void setHoldBack(String holdBack)
writeback to summary
public void write(char[] cbuf, int off, int len) throws IOException

Implements abstract java.io.Writer.write.

Doc from java.io.Writer.write.

Writes a portion of an array of characters.

Parameters
cbuf:char[]

Array of characters

off:int

Offset from which to start writing characters

len:int

Number of characters to write

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
org.apache.poi.util back to summary

protected Interface GenericRecordJsonWriter.GenericRecordHandler

Annotations
@FunctionalInterface

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true, if the element was handled and output produced, The provided methods can be overridden and an implementation can return false, if the element hasn't been written to the stream
print
(GenericRecordJsonWriter
the parent record, applied via instance method reference
record
,
String
the name of the property
name
,
Object
the value of the property
object
)

Handler method

Method Detail

printback to summary
public boolean print(GenericRecordJsonWriter record, String name, Object object)

Handler method

Parameters
record:GenericRecordJsonWriter

the parent record, applied via instance method reference

name:String

the name of the property

object:Object

the value of the property

Returns:boolean

true, if the element was handled and output produced, The provided methods can be overridden and an implementation can return false, if the element hasn't been written to the stream