Package org.apache.juneau.marshall.jcs
Class JcsSerializerSession
java.lang.Object
- All Implemented Interfaces:
BeanSession,ConverterSession,ArrayRecordWritable,RecordWritable,TokenWritable
Session object for
JcsSerializer that produces RFC 8785 canonical JSON.
See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.apache.juneau.marshall.json.JsonSerializerSession
JsonSerializerSession.DefaultBuilder -
Field Summary
Fields inherited from class org.apache.juneau.marshall.MarshallingTraverseSession
indentFields inherited from class org.apache.juneau.marshall.MarshallingSession
NAME_PROPERTY_NAME -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic JcsSerializerSession.Buildercreate(JcsSerializer ctx) Creates a new builder for this object.protected JsonWriter<?>Converts the specified output target object to anJsonWriter.booleanStreaming-quality signal queryable before opening a cursor.static intjcsCompare(String a, String b) JCS key comparison: UTF-16 code unit ordering per RFC 8785.static StringConverts a number to ECMAScript-compatible JSON string per RFC 8785.protected SerializerWriter<?>writeBeanMap(JsonWriter<?> out, BeanMap<?> m, String typeName) protected SerializerWriter<?>writeMap(JsonWriter<?> out, Map m, ClassMeta<?> type) writeRecords(Object output) Returns a record writer that emits canonical JCS for each value passed towrite(...)(delegates to this session'sSerializerSession.write(Object, Object)).writeTokens(Object output) Opens a low-level push generator that emits raw JSON (NOT canonical JCS) one structural event at a time, with theTokenWriter.object(Object)POJO bridge disabled (the walker would emit ordinary JSON, not canonical JCS).Methods inherited from class org.apache.juneau.marshall.json.JsonSerializerSession
create, doWrite, getJsonClassMeta, isAddBeanTypes, isEscapeSolidus, isSimpleAttrs, writeAnything, writeArrayRecords, writeJsonMethods inherited from class org.apache.juneau.marshall.serializer.WriterSerializerSession
create, createPipe, getMaxIndent, getQuoteChar, getStreamCharset, isUseWhitespace, isWriterSerializer, properties, write, writeToStringMethods inherited from class org.apache.juneau.marshall.serializer.SerializerSession
addVarBean, canIgnoreValue, canIgnoreValue, create, createBeanTypeNameProperty, createDefaultVarResolverSession, forEachEntry, forEachEntry, forEachStreamableEntry, generalize, getBeanTypeName, getCalendarFormat, getDateFormat, getDurationFormat, getExpectedRootType, getJavaMethod, getListener, getListener, getLocaleFormat, getPeriodFormat, getResponseHeaders, getSchema, getTemporalFormat, getTimeZoneFormat, getUriContext, getUriRelativity, getUriResolution, getUriResolver, getVarResolver, handleThrown, isAddRootType, isKeepNullProperties, isNonDefault, isSortCollections, isSortMaps, isTrimEmptyCollections, isTrimEmptyMaps, isTrimStrings, onBeanGetterException, onError, push2, relativizeUri, resolve, resolveUri, sort, sort, sort, swap, toList, toListFromStreamable, toString, trim, unwrapSupplier, write, writeCalendar, writeDate, writeDuration, writePeriod, writeTemporalMethods inherited from class org.apache.juneau.marshall.MarshallingTraverseSession
getInitialDepth, getLastLocation, getMaxDepth, getOptionalType, getOptionalValue, getStack, isDetectRecursions, isIgnoreRecursions, isOptional, isRoot, pop, push, setCurrentClass, setCurrentProperty, willExceedDepth, willRecurseMethods inherited from class org.apache.juneau.marshall.MarshallingSession
addWarning, convertToMemberType, convertToMemberType, convertToMemberType, convertToType, convertToType, convertToType, convertToType, create, get, getActiveView, getAnnotationProvider, getArgsClassMeta, getBeanClassVisibility, getBeanConstructorVisibility, getBeanDictionary, getBeanFieldVisibility, getBeanMeta, getBeanMethodVisibility, getBeanRegistry, getBeanTypePropertyName, getBeanTypePropertyName, getClassLoader, getClassMeta, getClassMeta, getClassMetaForObject, getClassMetaForObject, getLocale, getMarshallingContext, getMediaType, getNotBeanClasses, getNotBeanPackagesNames, getPropertyNamer, getSwaps, getTimeZone, getTimeZoneId, isBean, isBean, isBeanMapPutReturnsOldValue, isBeansRequireDefaultConstructor, isBeansRequireSerializable, isBeansRequireSettersForGetters, isBeansRequireSomeProperties, isFindFluentSetters, isIgnoreInvocationExceptionsOnGetters, isIgnoreInvocationExceptionsOnSetters, isIgnoreMissingSetters, isIgnoreUnknownBeanProperties, isIgnoreUnknownNullBeanProperties, isPropertyInActiveView, isRecordComponentOrder, isUnsortedProperties, isUseInterfaceProxies, isUseJavaBeanIntrospector, isValidateSchema, newBean, newBean, newBeanMap, newBeanMap, newGenericList, newGenericMap, newGenericMap, object, parseToList, parseToMap, string, toArray, toBeanMap, toBeanMap, toBeanMapMethods inherited from class org.apache.juneau.marshall.ContextSession
checkForWarnings, getContext, getSessionProperties, getWarnings, isDebug, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.juneau.marshall.stream.ArrayRecordWritable
isArrayRecordStreaming, writeArrayRecordsMethods inherited from interface org.apache.juneau.commons.conversion.ConverterSession
get
-
Constructor Details
-
JcsSerializerSession
Constructor.- Parameters:
builder- The builder for this object.
-
-
Method Details
-
create
Creates a new builder for this object.- Parameters:
ctx- The context creating this session.
Cannot benull .- Returns:
- A new builder.
-
toEcmaNumber
Converts a number to ECMAScript-compatible JSON string per RFC 8785.- Parameters:
n- The number.
Must not benull .- Returns:
- The serialized string.
- Throws:
SerializeException- If the number is NaN or Infinity.
-
jcsCompare
JCS key comparison: UTF-16 code unit ordering per RFC 8785.Null keys (e.g., from
HashMapwith null key) sort before non-null.- Parameters:
a- First string.b- Second string.- Returns:
- Comparison result (negative, zero, or positive).
-
writeTokens
Opens a low-level push generator that emits raw JSON (NOT canonical JCS) one structural event at a time, with theTokenWriter.object(Object)POJO bridge disabled (the walker would emit ordinary JSON, not canonical JCS). UsewriteRecords(Object)orSerializerSession.write(Object, Object)for canonical output.- Specified by:
writeTokensin interfaceTokenWritable- Overrides:
writeTokensin classJsonSerializerSession- Parameters:
output- The output.- Returns:
- A new
JsonTokenWriterwithobject(...)disabled. - Throws:
IOException- If the output type is not supported or could not be opened.
-
writeRecords
Returns a record writer that emits canonical JCS for each value passed towrite(...)(delegates to this session'sSerializerSession.write(Object, Object)).- Parameters:
output- The output.- Returns:
- A new
RecordWriter. - Throws:
IOException- If the output type is not supported or could not be opened.
-
isRecordStreaming
Description copied from interface:RecordWritableStreaming-quality signal queryable before opening a cursor.- Returns:
true ifRecordWritable.writeRecords(Object)returns an O(1)-memory streaming cursor;false for buffered (whole-value) formats backed byRecordAdapter.
-
getJsonWriter
Description copied from class:JsonSerializerSessionConverts the specified output target object to anJsonWriter.- Overrides:
getJsonWriterin classJsonSerializerSession- Parameters:
out- The output target object.
Must not benull .- Returns:
- The output target object wrapped in an
JsonWriter.
-
writeMap
protected SerializerWriter<?> writeMap(JsonWriter<?> out, Map m, ClassMeta<?> type) throws SerializeException - Overrides:
writeMapin classJsonSerializerSession- Throws:
SerializeException
-
writeBeanMap
protected SerializerWriter<?> writeBeanMap(JsonWriter<?> out, BeanMap<?> m, String typeName) throws SerializeException - Overrides:
writeBeanMapin classJsonSerializerSession- Throws:
SerializeException
-