Java Code Examples for com.caucho.hessian.io.AbstractHessianOutput#writeNull()
The following examples show how to use
com.caucho.hessian.io.AbstractHessianOutput#writeNull() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GenericClassSerializer.java From sofa-hessian with Apache License 2.0 | 6 votes |
public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { GenericClass genericClass = (GenericClass) obj; if (genericClass == null) { out.writeNull(); } else if (out.addRef(obj)) { return; } else { int ref = out.writeObjectBegin("java.lang.Class"); if (ref < -1) { out.writeString("name"); out.writeString(genericClass.getClazzName()); out.writeMapEnd(); } else { if (ref == -1) { out.writeInt(1); out.writeString("name"); out.writeObjectBegin("java.lang.Class"); } out.writeString(genericClass.getClazzName()); } } }
Example 2
Source File: Java8TimeSerializer.java From sofa-hessian with Apache License 2.0 | 6 votes |
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) { out.writeNull(); return; } T handle = null; try { Constructor<T> constructor = handleType.getConstructor(Object.class); handle = constructor.newInstance(obj); } catch (Exception e) { throw new RuntimeException("the class :" + handleType.getName() + " construct failed:" + e.getMessage(), e); } out.writeObject(handle); }
Example 3
Source File: Java8TimeSerializer.java From jvm-sandbox-repeater with Apache License 2.0 | 6 votes |
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) { out.writeNull(); return; } T handle; try { Constructor<T> constructor = this.handleType.getConstructor(Object.class); handle = constructor.newInstance(obj); } catch (Exception e) { throw new RuntimeException("the class :" + this.handleType.getName() + " construct failed:" + e.getMessage(), e); } out.writeObject(handle); }
Example 4
Source File: WeakReferenceSerializer.java From AutoLoadCache with Apache License 2.0 | 6 votes |
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (out.addRef(obj)) { return; } @SuppressWarnings("unchecked") WeakReference<Object> data = (WeakReference<Object>) obj; int refV = out.writeObjectBegin(WeakReference.class.getName()); if (refV == -1) { out.writeInt(1); out.writeString("ref"); out.writeObjectBegin(WeakReference.class.getName()); } if (data != null) { Object ref = data.get(); if (null != ref) { out.writeObject(ref); } else { out.writeNull(); } } else { out.writeNull(); } }
Example 5
Source File: SoftReferenceSerializer.java From AutoLoadCache with Apache License 2.0 | 6 votes |
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (out.addRef(obj)) { return; } @SuppressWarnings("unchecked") SoftReference<Object> data = (SoftReference<Object>) obj; int refV = out.writeObjectBegin(SoftReference.class.getName()); if (refV == -1) { out.writeInt(1); out.writeString("ref"); out.writeObjectBegin(SoftReference.class.getName()); } if (data != null) { Object ref = data.get(); if (null != ref) { out.writeObject(ref); } else { out.writeNull(); } } else { out.writeNull(); } }
Example 6
Source File: LocalTimeSerializer.java From alibaba-rsocket-broker with Apache License 2.0 | 5 votes |
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) { out.writeNull(); } else { out.writeObject(new LocalTimeHandle((LocalTime) obj)); } }
Example 7
Source File: ZoneIdSerializer.java From sofa-hessian with Apache License 2.0 | 5 votes |
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) { out.writeNull(); } else { out.writeObject(new ZoneIdHandle(obj)); } }
Example 8
Source File: LocalDateTimeSerializer.java From jvm-sandbox-repeater with Apache License 2.0 | 5 votes |
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) { out.writeNull(); } else { Class cl = obj.getClass(); if (out.addRef(obj)) { return; } // ref 返回-2 便是开始写Map int ref = out.writeObjectBegin(cl.getName()); if (ref < -1) { out.writeString("value"); out.writeUTCDate(((LocalDateTime) obj).toInstant(ZoneOffset.of("+8")).toEpochMilli()); out.writeMapEnd(); } else { if (ref == -1) { out.writeInt(1); out.writeString("value"); out.writeObjectBegin(cl.getName()); } out.writeUTCDate(((LocalDateTime) obj).toInstant(ZoneOffset.of("+8")).toEpochMilli()); } } }
Example 9
Source File: YearSerializer.java From alibaba-rsocket-broker with Apache License 2.0 | 5 votes |
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) { out.writeNull(); } else { out.writeObject(new YearHandle((Year) obj)); } }
Example 10
Source File: ZoneOffsetSerializer.java From alibaba-rsocket-broker with Apache License 2.0 | 5 votes |
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) { out.writeNull(); } else { out.writeObject(new ZoneOffsetHandle((ZoneOffset) obj)); } }
Example 11
Source File: PeriodSerializer.java From alibaba-rsocket-broker with Apache License 2.0 | 5 votes |
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) { out.writeNull(); } else { out.writeObject(new PeriodHandle((Period) obj)); } }
Example 12
Source File: OffsetDateTimeSerializer.java From alibaba-rsocket-broker with Apache License 2.0 | 5 votes |
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) { out.writeNull(); } else { out.writeObject(new OffsetDateTimeHandle((OffsetDateTime) obj)); } }
Example 13
Source File: MonthDaySerializer.java From alibaba-rsocket-broker with Apache License 2.0 | 5 votes |
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) { out.writeNull(); } else { out.writeObject(new MonthDayHandle((MonthDay) obj)); } }
Example 14
Source File: ZoneIdSerializer.java From alibaba-rsocket-broker with Apache License 2.0 | 5 votes |
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) { out.writeNull(); } else { out.writeObject(new ZoneIdHandle((ZoneId) obj)); } }
Example 15
Source File: LocalDateTimeSerializer.java From alibaba-rsocket-broker with Apache License 2.0 | 5 votes |
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) { out.writeNull(); } else { out.writeObject(new LocalDateTimeHandle((LocalDateTime) obj)); } }
Example 16
Source File: OffsetTimeSerializer.java From alibaba-rsocket-broker with Apache License 2.0 | 5 votes |
public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) { out.writeNull(); } else { out.writeObject(new OffsetTimeHandle((OffsetTime) obj)); } }
Example 17
Source File: InstantSerializer.java From alibaba-rsocket-broker with Apache License 2.0 | 5 votes |
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) { out.writeNull(); } else { out.writeObject(new InstantHandle((Instant) obj)); } }
Example 18
Source File: YearMonthSerializer.java From alibaba-rsocket-broker with Apache License 2.0 | 5 votes |
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) { out.writeNull(); } else { out.writeObject(new YearMonthHandle((YearMonth) obj)); } }
Example 19
Source File: OptionalSerializer.java From alibaba-rsocket-broker with Apache License 2.0 | 5 votes |
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) { out.writeNull(); } else { out.writeObject(new OptionalHandle((Optional<?>) obj)); } }
Example 20
Source File: ZonedDateTimeSerializer.java From alibaba-rsocket-broker with Apache License 2.0 | 5 votes |
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) { out.writeNull(); } else { out.writeObject(new ZonedDateTimeHandle((ZonedDateTime) obj)); } }