Package com.cedarsoftware.io
Class Writers.PrimitiveTypeWriter
java.lang.Object
com.cedarsoftware.io.Writers.PrimitiveTypeWriter
- All Implemented Interfaces:
JsonClassWriter
- Direct Known Subclasses:
AtomicIntegerArrayWriter,AtomicLongArrayWriter,BitSetWriter,LongWriter,Writers.BigDecimalWriter,Writers.BigIntegerWriter,Writers.CharacterWriter,Writers.CurrencyWriter,Writers.DurationWriter,Writers.FloatingPointWriter,Writers.InstantWriter,Writers.LocalDateAsLong,Writers.LocalDateTimeWriter,Writers.LocalDateWriter,Writers.LocaleWriter,Writers.LocalTimeWriter,Writers.MonthDayWriter,Writers.OffsetDateTimeWriter,Writers.OffsetTimeWriter,Writers.PatternWriter,Writers.PeriodWriter,Writers.PrimitiveUtf8StringWriter,Writers.PrimitiveValueWriter,Writers.TimestampWriter,Writers.UUIDWriter,Writers.YearMonthWriter,Writers.YearWriter,Writers.ZonedDateTimeWriter,Writers.ZoneOffsetWriter
- Enclosing class:
- Writers
Used as a template to write out types that will have a primitive form.
Uses the default key of "value" unless overridden
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringgetKey()booleanhasPrimitiveForm(WriterContext writerContext) Indicates whether this class has a primitive (non-object) JSON form.voidwrite(Object obj, boolean showType, Writer output, WriterContext context) Write the object in JSON format to the output Writer.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.cedarsoftware.io.JsonClassWriter
getTypeName, writePrimitiveForm
-
Constructor Details
-
PrimitiveTypeWriter
public PrimitiveTypeWriter()
-
-
Method Details
-
getKey
-
write
public void write(Object obj, boolean showType, Writer output, WriterContext context) throws IOException Description copied from interface:JsonClassWriterWrite the object in JSON format to the output Writer.- Specified by:
writein interfaceJsonClassWriter- Parameters:
obj- Object to be written in JSON formatshowType- boolean indicating whether to include @type in the outputoutput- Writer destination where the JSON is writtencontext- WriterContext providing access to WriteOptions and other write utilities- Throws:
IOException- if an I/O error occurs during writing
-
hasPrimitiveForm
Description copied from interface:JsonClassWriterIndicates whether this class has a primitive (non-object) JSON form. Most custom writers will not have a primitive form, so the default is false.- Specified by:
hasPrimitiveFormin interfaceJsonClassWriter- Parameters:
writerContext- WriterContext providing access to WriteOptions- Returns:
- true if this class can be written as a JSON primitive value
-