writer.writeString(name, value.toString()); writer.writeString(name, value.toString()); writer.writeBoolean(name, (Boolean) value); writer.writeInt(name, (Integer) value); writer.writeDouble(name, (Double) value); writer.writeLong(name, (Long) value); writer.writeFloat(name, (Float) value); writer.writeLong(name, ((FileTime) value).toMillis()); writer.writeLong(name, ((Date) value).getTime()); writer.writeString(name, sb.toString());
public BigDecimalProtofieldAccessor(int tag, String name, boolean nullable, String columnName) { super( tag, name, nullable, columnName, (ProtoStreamWriter outProtobuf, BigDecimal value) -> outProtobuf.writeBytes( name, value.toBigInteger().toByteArray() ), (ProtoStreamReader reader) -> { byte[] readBytes = reader.readBytes( name ); if ( readBytes != null ) { BigInteger bi = new BigInteger( readBytes ); BigDecimal bd = new BigDecimal( bi ); return bd; } return null; } ); }
writer.writeString(name, value.toString()); writer.writeString(name, value.toString()); writer.writeBoolean(name, (Boolean) value); writer.writeInt(name, (Integer) value); writer.writeDouble(name, (Double) value); writer.writeLong(name, (Long) value); writer.writeFloat(name, (Float) value); writer.writeLong(name, ((FileTime) value).toMillis()); writer.writeLong(name, ((Date) value).getTime()); writer.writeString(name, sb.toString());
@Override public void writeTo(ProtoStreamWriter writer, FilterResult filterResult) throws IOException { if (filterResult.getProjection() == null) { // skip marshalling the instance if there is a projection writer.writeBytes("instance", (byte[]) filterResult.getInstance()); } else { WrappedMessage[] p = new WrappedMessage[filterResult.getProjection().length]; for (int i = 0; i < p.length; i++) { p[i] = new WrappedMessage(filterResult.getProjection()[i]); } writer.writeArray("projection", p, WrappedMessage.class); } if (filterResult.getSortProjection() != null) { WrappedMessage[] p = new WrappedMessage[filterResult.getSortProjection().length]; for (int i = 0; i < p.length; i++) { p[i] = new WrappedMessage(filterResult.getSortProjection()[i]); } writer.writeArray("sortProjection", p, WrappedMessage.class); } }
public CalendarDateProtofieldAccessor(int tag, final String name, boolean nullable, String columnName) { super( tag, name, nullable, columnName, (ProtoStreamWriter outProtobuf, Calendar value) -> outProtobuf.writeLong( name, value.getTimeInMillis() ), (ProtoStreamReader reader) -> { //TODO should we map this as a composite object, to encode both the utcTimestamp and the timezone? Long utcTimestamp = reader.readLong( name ); if ( utcTimestamp != null ) { Calendar c = Calendar.getInstance(); c.setTimeInMillis( utcTimestamp ); return c; } else { return null; } } ); }
@Override public void writeTo(ProtoStreamWriter out, InfinispanSessionData sdata) throws IOException { out.writeInt("version", VERSION); out.writeString("id", sdata.getId()); // session id out.writeString("contextPath", sdata.getContextPath()); // context path out.writeString("vhost", sdata.getVhost()); // first vhost out.writeLong("accessed", sdata.getAccessed());// accessTime out.writeLong("lastAccessed", sdata.getLastAccessed()); // lastAccessTime out.writeLong("created", sdata.getCreated()); // time created out.writeLong("cookieSet", sdata.getCookieSet());// time cookie was set out.writeString("lastNode", sdata.getLastNode()); // name of last node // managing out.writeLong("expiry", sdata.getExpiry()); out.writeLong("maxInactiveMs", sdata.getMaxInactiveMs()); sdata.serializeAttributes(); out.writeBytes("attributes", sdata.getSerializedAttributes()); } }
public ShortProtofieldAccessor(int fieldNumber, String name, boolean nullable, String columnName) { super( fieldNumber, name, nullable, columnName, (ProtoStreamWriter outProtobuf, Short value) -> outProtobuf.writeInt( name, value ), (ProtoStreamReader reader) -> { Integer readInt = reader.readInt( name ); if ( readInt != null ) { int truncated = Math.min( Math.max( readInt, Short.MIN_VALUE ), Short.MAX_VALUE ); if ( truncated != readInt ) { throw LOG.truncatingShortOnRead( readInt, name ); } return (short) truncated; } return null; } ); }
@Override public void writeTo(ProtoStreamWriter writer, User user) throws IOException { writer.writeInt("id", user.getId()); writer.writeCollection("accountIds", user.getAccountIds(), Integer.class); writer.writeString("name", user.getName()); writer.writeString("surname", user.getSurname()); writer.writeString("salutation", user.getSalutation()); writer.writeCollection("addresses", user.getAddresses(), Address.class); writer.writeInt("age", user.getAge()); writer.writeEnum("gender", user.getGender()); writer.writeString("notes", user.getNotes()); writer.writeInstant("creationDate", user.getCreationDate()); writer.writeInstant("passwordExpirationDate", user.getPasswordExpirationDate()); }
public DateProtofieldAccessor(int tag, String name, boolean nullable, String columnName) { super( tag, name, nullable, columnName, (ProtoStreamWriter outProtobuf, Date value) -> outProtobuf.writeLong( name, value.getTime() ), (ProtoStreamReader reader) -> { Long utcTimestamp = reader.readLong( name ); if ( utcTimestamp != null ) { Date d = new Date(); d.setTime( utcTimestamp ); return d; } else { return null; } } ); }
@Override public void writeTo(ProtoStreamWriter writer, ContinuousQueryResult continuousQueryResult) throws IOException { writer.writeObject("resultType", continuousQueryResult.resultType, ResultType.class); writer.writeBytes("key", continuousQueryResult.key); if (continuousQueryResult.projection == null) { // skip marshalling the instance if there is a projection writer.writeBytes("value", continuousQueryResult.value); } else { WrappedMessage[] p = new WrappedMessage[continuousQueryResult.projection.length]; for (int i = 0; i < p.length; i++) { p[i] = new WrappedMessage(continuousQueryResult.projection[i]); } writer.writeArray("projection", p, WrappedMessage.class); } }
public TimestampProtofieldAccessor(int tag, String name, boolean nullable, String columnName) { super( tag, name, nullable, columnName, (ProtoStreamWriter outProtobuf, Date value) -> outProtobuf.writeLong( name, value.getTime() ), (ProtoStreamReader reader) -> { Long utcTimestamp = reader.readLong( name ); if ( utcTimestamp != null ) { Date d = new Timestamp( utcTimestamp ); return d; } else { return null; } } ); }
public TimeProtofieldAccessor(int tag, String name, boolean nullable, String columnName) { super( tag, name, nullable, columnName, (MessageMarshaller.ProtoStreamWriter outProtobuf, Time value) -> outProtobuf.writeLong( name, value.getTime() ), (MessageMarshaller.ProtoStreamReader reader) -> { Long utcTimestamp = reader.readLong( name ); if ( utcTimestamp != null ) { Time d = new Time( utcTimestamp ); return d; } else { return null; } } ); }
@Override public void writeTo(ProtoStreamWriter outProtobuf, Enum value) throws IOException { outProtobuf.writeObject( name, value, type ); }
@Override public void writeTo(ProtoStreamWriter writer, UUID uuid) throws IOException { writer.writeString("uuid", uuid.toString()); }
@Override public void writeTo(ProtoStreamWriter writer, EntityInterface obj) throws IOException { writer.writeInt("id", obj.getId()); writer.writeString("fieldValue", obj.getFieldValue()); }
public LocalDateProtofieldAccessor(int tag, String name, boolean nullable, String columnName) { super( tag, name, nullable, columnName, (MessageMarshaller.ProtoStreamWriter outProtobuf, LocalDate value) -> outProtobuf.writeString( name, value.toString() ), (MessageMarshaller.ProtoStreamReader reader) -> { String stringValue = reader.readString( name ); return ( stringValue == null ) ? null : LocalDate.parse( stringValue ); } ); }
@Override public void writeTo(ProtoStreamWriter writer, UUID uuid) throws IOException { writer.writeString("uuid", uuid.toString()); }
public BooleanProtofieldAccessor(int tag, String name, boolean nullable, String columnName) { super( tag, name, nullable, columnName, (ProtoStreamWriter outProtobuf, Boolean value) -> outProtobuf.writeBoolean( name, value ), (ProtoStreamReader reader) -> reader.readBoolean( name ) ); }
public PrimitiveBytearrayProtofieldAccessor(int tag, String name, boolean nullable, String columnName) { super( tag, name, nullable, columnName, (ProtoStreamWriter outProtobuf, byte[] value) -> outProtobuf.writeBytes( name, value ), (ProtoStreamReader reader) -> reader.readBytes( name ) ); }
@Override public void writeTo(ProtoStreamWriter writer, DynamicEntity1 obj) throws IOException { writer.writeInt("seed", obj.seed); writer.writeString("value", obj.value); }