Top Description Inners Constructors Methods
org.hibernate.dialect

public Class JsonHelper

extends Object
Class Inheritance
Annotations
@Internal
Imports
java.io.OutputStream, java.sql.SQLException, java.time.OffsetDateTime, java.time.format.DateTimeFormatter, org.hibernate.Internal, org.hibernate.internal.util.CharSequenceHelper, org.hibernate.metamodel.mapping.AttributeMapping, .EmbeddableMappingType, .JdbcMapping, .MappingType, .SelectableMapping, org.hibernate.metamodel.mapping.internal.EmbeddedAttributeMapping, org.hibernate.sql.ast.spi.SqlAppender, org.hibernate.type.BasicType, .SqlTypes, org.hibernate.type.descriptor.WrapperOptions, org.hibernate.type.descriptor.java.JavaType, .JdbcDateJavaType, .JdbcTimeJavaType, .JdbcTimestampJavaType, .OffsetDateTimeJavaType, .PrimitiveByteArrayJavaType, org.hibernate.type.descriptor.jdbc.AggregateJdbcType

A Helper for serializing and deserializing JSON, based on an org.hibernate.metamodel.mapping.EmbeddableMappingType.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
pack-priv static enum

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static int
consume(String string, int start, String text)

private static int
consumeExponential(String string, int start, int eIndex, Object[] values, EmbeddableMappingType embeddableMappingType, int selectableIndex, boolean returnEmbeddable, WrapperOptions options)

private static int
consumeFractional(String string, int start, int dotIndex, Object[] values, EmbeddableMappingType embeddableMappingType, int selectableIndex, boolean returnEmbeddable, WrapperOptions options)

private static int
consumeLiteral(String string, int start, Object[] values, EmbeddableMappingType embeddableMappingType, int selectableIndex, boolean returnEmbeddable, WrapperOptions options)

public static <X> X
fromString(EmbeddableMappingType embeddableMappingType, String string, boolean returnEmbeddable, WrapperOptions options)

private static int
fromString(EmbeddableMappingType embeddableMappingType, String string, int begin, int end, Object[] values, boolean returnEmbeddable, WrapperOptions options)

private static Object
fromString(EmbeddableMappingType embeddableMappingType, int selectableIndex, String string, int start, int end, boolean returnEmbeddable, WrapperOptions options)

private static Object
fromString(JdbcMapping jdbcMapping, String string, int start, int end, boolean hasEscape, boolean returnEmbeddable, WrapperOptions options)

private static Object
fromString(JdbcMapping jdbcMapping, String string, int start, int end, boolean returnEmbeddable, WrapperOptions options)

private static int
getSelectableMapping(EmbeddableMappingType embeddableMappingType, String string, int start, int end, boolean hasEscape)

private static IllegalArgumentException
syntaxError(String string, JsonHelper.State s, int charIndex)

public static String
toString(EmbeddableMappingType embeddableMappingType, Object value, WrapperOptions options)

private static void
toString(EmbeddableMappingType embeddableMappingType, Object value, WrapperOptions options, JsonHelper.JsonAppender appender)

private static void
toString(EmbeddableMappingType embeddableMappingType, WrapperOptions options, JsonHelper.JsonAppender appender, Object[] values, char separator)

private static void
toString(MappingType mappedType, Object value, WrapperOptions options, JsonHelper.JsonAppender appender)

private static String
unescape(String string, int start, int end)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

JsonHelperback to summary
public JsonHelper()

Method Detail

consumeback to summary
private static int consume(String string, int start, String text)
consumeExponentialback to summary
private static int consumeExponential(String string, int start, int eIndex, Object[] values, EmbeddableMappingType embeddableMappingType, int selectableIndex, boolean returnEmbeddable, WrapperOptions options) throws SQLException
consumeFractionalback to summary
private static int consumeFractional(String string, int start, int dotIndex, Object[] values, EmbeddableMappingType embeddableMappingType, int selectableIndex, boolean returnEmbeddable, WrapperOptions options) throws SQLException
consumeLiteralback to summary
private static int consumeLiteral(String string, int start, Object[] values, EmbeddableMappingType embeddableMappingType, int selectableIndex, boolean returnEmbeddable, WrapperOptions options) throws SQLException
fromStringback to summary
public static <X> X fromString(EmbeddableMappingType embeddableMappingType, String string, boolean returnEmbeddable, WrapperOptions options) throws SQLException
fromStringback to summary
private static int fromString(EmbeddableMappingType embeddableMappingType, String string, int begin, int end, Object[] values, boolean returnEmbeddable, WrapperOptions options) throws SQLException
fromStringback to summary
private static Object fromString(EmbeddableMappingType embeddableMappingType, int selectableIndex, String string, int start, int end, boolean returnEmbeddable, WrapperOptions options) throws SQLException
fromStringback to summary
private static Object fromString(JdbcMapping jdbcMapping, String string, int start, int end, boolean hasEscape, boolean returnEmbeddable, WrapperOptions options) throws SQLException
fromStringback to summary
private static Object fromString(JdbcMapping jdbcMapping, String string, int start, int end, boolean returnEmbeddable, WrapperOptions options) throws SQLException
getSelectableMappingback to summary
private static int getSelectableMapping(EmbeddableMappingType embeddableMappingType, String string, int start, int end, boolean hasEscape)
syntaxErrorback to summary
private static IllegalArgumentException syntaxError(String string, JsonHelper.State s, int charIndex)
toStringback to summary
public static String toString(EmbeddableMappingType embeddableMappingType, Object value, WrapperOptions options)
toStringback to summary
private static void toString(EmbeddableMappingType embeddableMappingType, Object value, WrapperOptions options, JsonHelper.JsonAppender appender)
toStringback to summary
private static void toString(EmbeddableMappingType embeddableMappingType, WrapperOptions options, JsonHelper.JsonAppender appender, Object[] values, char separator)
toStringback to summary
private static void toString(MappingType mappedType, Object value, WrapperOptions options, JsonHelper.JsonAppender appender)
unescapeback to summary
private static String unescape(String string, int start, int end)
org.hibernate.dialect back to summary

private Class JsonHelper.JsonAppender

extends OutputStream
implements SqlAppender
Class Inheritance
All Implemented Interfaces
org.hibernate.sql.ast.spi.SqlAppender, java.lang.Appendable

Field Summary

Modifier and TypeField and Description
private boolean
private static final char[]
private final StringBuilder

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public JsonHelper.JsonAppender
append(char
The character to append
fragment
)

Overrides default org.hibernate.sql.ast.spi.SqlAppender.append.

Appends the specified character to this Appendable.
public JsonHelper.JsonAppender
append(CharSequence
The character sequence to append. If csq is null, then the four characters "null" are appended to this Appendable.
csq
)

Overrides default org.hibernate.sql.ast.spi.SqlAppender.append.

Appends the specified character sequence to this Appendable.
public JsonHelper.JsonAppender
append(CharSequence
The character sequence from which a subsequence will be appended. If csq is null, then characters will be appended as if csq contained the four characters "null".
csq
,
int
The index of the first character in the subsequence
start
,
int
The index of the character following the last character in the subsequence
end
)

Overrides default org.hibernate.sql.ast.spi.SqlAppender.append.

Appends a subsequence of the specified character sequence to this Appendable.
private void
appendEscaped(char fragment)

public void
appendSql(String fragment)

Implements org.hibernate.sql.ast.spi.SqlAppender.appendSql.

Add the passed fragment into the in-flight buffer
public void
public void
public void
public void
public void
public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
write(int
the byte.
v
)

Implements abstract java.io.OutputStream.write.

Writes the specified byte to this output stream.
public void
write(byte[]
the data.
bytes
)

Overrides java.io.OutputStream.write.

Writes b.length bytes from the specified byte array to this output stream.
public void
write(byte[]
the data.
bytes
,
int
the start offset in the data.
off
,
int
the number of bytes to write.
len
)

Overrides java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.
Inherited from java.io.OutputStream:
closeflushnullOutputStream

Field Detail

escapeback to summary
private boolean escape
HEX_ARRAYback to summary
private static final char[] HEX_ARRAY
sbback to summary
private final StringBuilder sb

Constructor Detail

JsonAppenderback to summary
public JsonAppender(StringBuilder sb)

Method Detail

appendback to summary
public JsonHelper.JsonAppender append(char fragment)

Overrides default org.hibernate.sql.ast.spi.SqlAppender.append.

Doc from java.lang.Appendable.append.

Appends the specified character to this Appendable.

Parameters
fragment:char

The character to append

Returns:JsonHelper.JsonAppender

A reference to this Appendable

Annotations
@Override
appendback to summary
public JsonHelper.JsonAppender append(CharSequence csq)

Overrides default org.hibernate.sql.ast.spi.SqlAppender.append.

Doc from java.lang.Appendable.append.

Appends the specified character sequence to this Appendable.

Depending on which class implements the character sequence csq, the entire sequence may not be appended. For instance, if csq is a java.nio.CharBuffer then the subsequence to append is defined by the buffer's position and limit.

Parameters
csq:CharSequence

The character sequence to append. If csq is null, then the four characters "null" are appended to this Appendable.

Returns:JsonHelper.JsonAppender

A reference to this Appendable

Annotations
@Override
appendback to summary
public JsonHelper.JsonAppender append(CharSequence csq, int start, int end)

Overrides default org.hibernate.sql.ast.spi.SqlAppender.append.

Doc from java.lang.Appendable.append.

Appends a subsequence of the specified character sequence to this Appendable.

An invocation of this method of the form out.append(csq, start, end) when csq is not null, behaves in exactly the same way as the invocation

    out.append(csq.subSequence(start, end)) 
Parameters
csq:CharSequence

The character sequence from which a subsequence will be appended. If csq is null, then characters will be appended as if csq contained the four characters "null".

start:int

The index of the first character in the subsequence

end:int

The index of the character following the last character in the subsequence

Returns:JsonHelper.JsonAppender

A reference to this Appendable

Annotations
@Override
appendEscapedback to summary
private void appendEscaped(char fragment)
appendSqlback to summary
public void appendSql(String fragment)

Implements org.hibernate.sql.ast.spi.SqlAppender.appendSql.

Doc from org.hibernate.sql.ast.spi.SqlAppender.appendSql.

Add the passed fragment into the in-flight buffer

Annotations
@Override
appendSqlback to summary
public void appendSql(char fragment)

Overrides default org.hibernate.sql.ast.spi.SqlAppender.appendSql.

Annotations
@Override
appendSqlback to summary
public void appendSql(int value)

Overrides default org.hibernate.sql.ast.spi.SqlAppender.appendSql.

Annotations
@Override
appendSqlback to summary
public void appendSql(long value)

Overrides default org.hibernate.sql.ast.spi.SqlAppender.appendSql.

Annotations
@Override
appendSqlback to summary
public void appendSql(boolean value)

Overrides default org.hibernate.sql.ast.spi.SqlAppender.appendSql.

Annotations
@Override
endEscapingback to summary
public void endEscaping()
startEscapingback to summary
public void startEscaping()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
writeback to summary
public void write(int v)

Implements abstract java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Parameters
v:int

the byte.

Annotations
@Override
writeback to summary
public void write(byte[] bytes)

Overrides java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes b.length bytes from the specified byte array to this output stream. The general contract for write(b) is that it should have exactly the same effect as the call write(b, 0, b.length).

Parameters
bytes:byte[]

the data.

Annotations
@Override
writeback to summary
public void write(byte[] bytes, int off, int len)

Overrides java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream. The general contract for write(b, off, len) is that some of the bytes in the array b are written to the output stream in order; element b[off] is the first byte written and b[off+len-1] is the last byte written by this operation.

If b is null, a NullPointerException is thrown.

If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown.

Parameters
bytes:byte[]

the data.

off:int

the start offset in the data.

len:int

the number of bytes to write.

Annotations
@Override
org.hibernate.dialect back to summary

pack-priv final Enum JsonHelper.State

extends Enum<JsonHelper.State>
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final String
public static final JsonHelper.State
public static final JsonHelper.State
public static final JsonHelper.State
public static final JsonHelper.State
public static final JsonHelper.State
public static final JsonHelper.State

Constructor Summary

AccessConstructor and Description
private
State(String expectedChars)

Method Summary

Modifier and TypeMethod and Description
pack-priv String
public static JsonHelper.State
public static JsonHelper.State[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

expectedCharsback to summary
pack-priv final String expectedChars
KEY_ENDback to summary
public static final JsonHelper.State KEY_END
KEY_QUOTEback to summary
public static final JsonHelper.State KEY_QUOTE
KEY_STARTback to summary
public static final JsonHelper.State KEY_START
VALUE_ENDback to summary
public static final JsonHelper.State VALUE_END
VALUE_QUOTEback to summary
public static final JsonHelper.State VALUE_QUOTE
VALUE_STARTback to summary
public static final JsonHelper.State VALUE_START

Constructor Detail

Stateback to summary
private State(String expectedChars)

Method Detail

expectedCharsback to summary
pack-priv String expectedChars()
valueOfback to summary
public static JsonHelper.State valueOf(String name)
valuesback to summary
public static JsonHelper.State[] values()