@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { Class cl = (Class) obj; if (cl == 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(cl.getName()); out.writeMapEnd(); } else { if (ref == -1) { out.writeInt(1); out.writeString("name"); out.writeObjectBegin("java.lang.Class"); } out.writeString(cl.getName()); } } } }
/** * Writes a complete method call. */ public void call(String method, Object[] args) throws IOException { int length = args != null ? args.length : 0; startCall(method, length); for (int i = 0; i < length; i++) writeObject(args[i]); completeCall(); }
public void writeReply(Object o) throws IOException { startReply(); writeObject(o); completeReply(); }
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { InputStream is = (InputStream) obj; if (is == null) out.writeNull(); else { byte[] buf = new byte[1024]; int len; while ((len = is.read(buf, 0, buf.length)) > 0) { out.writeByteBufferPart(buf, 0, len); } out.writeByteBufferEnd(buf, 0, 0); } } }
switch (code) { case BOOLEAN: out.writeBoolean(((Boolean) obj).booleanValue()); break; case SHORT: case INTEGER: out.writeInt(((Number) obj).intValue()); break; out.writeLong(((Number) obj).longValue()); break; out.writeDouble(((Number) obj).doubleValue()); break; out.writeString(String.valueOf(obj)); break; out.writeString((String) obj); break; out.writeUTCDate(((Date) obj).getTime()); break; if (out.addRef(obj)) return; boolean hasEnd = out.writeListBegin(data.length, "[boolean");
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (out.addRef(obj)) return; out.removeRef(obj); out.writeObject(repl); out.replaceRef(repl, obj); int ref = out.writeObjectBegin(cl.getName()); out.writeString(_names[i]); out.writeObject(value); out.writeMapEnd(); } else { if (ref == -1) { out.writeInt(_names.length); out.writeString(_names[i]); out.writeObjectBegin(cl.getName()); out.writeObject(value);
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (out.addRef(obj)) return; Object[] array = (Object[]) obj; boolean hasEnd = out.writeListBegin(array.length, getArrayType(obj.getClass())); for (int i = 0; i < array.length; i++) out.writeObject(array[i]); if (hasEnd) out.writeListEnd(); }
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (out.addRef(obj)) return; int ref = out.writeObjectBegin(cl.getName()); out.writeString("name"); out.writeString(name); out.writeMapEnd(); } else { if (ref == -1) { out.writeClassFieldLength(1); out.writeString("name"); out.writeObjectBegin(cl.getName()); out.writeString(name);
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (out.addRef(obj)) { return; repl = _writeReplace.invoke(obj); out.removeRef(obj); out.writeObject(repl); out.replaceRef(repl, obj); int ref = out.writeObjectBegin(cl.getName()); if (ref == -1) { writeDefinition20(out); out.writeObjectBegin(cl.getName());
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (out.addRef(obj)) return; Map map = (Map) obj; Class cl = obj.getClass(); if (cl.equals(HashMap.class) || !_isSendJavaType || !(obj instanceof java.io.Serializable)) out.writeMapBegin(null); else out.writeMapBegin(obj.getClass().getName()); Iterator iter = map.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); out.writeObject(entry.getKey()); out.writeObject(entry.getValue()); } out.writeMapEnd(); } }
@Override void serialize(AbstractHessianOutput out, Object obj, Field field) throws IOException { boolean value = false; try { value = field.getBoolean(obj); } catch (IllegalAccessException e) { log.log(Level.FINE, e.toString(), e); } out.writeBoolean(value); } }
switch (code) { case BOOLEAN: out.writeBoolean(((Boolean) obj).booleanValue()); break; case SHORT: case INTEGER: out.writeInt(((Number) obj).intValue()); break; out.writeLong(((Number) obj).longValue()); break; out.writeDouble(((Number) obj).doubleValue()); break; out.writeString(String.valueOf(obj)); break; out.writeString((String) obj); break; out.writeUTCDate(((Date) obj).getTime()); break; if (out.addRef(obj)) return; boolean hasEnd = out.writeListBegin(data.length, "[boolean");
public void writeObject(Object obj, AbstractHessianOutput out) throws IOException if (out.addRef(obj)) return; repl = _writeReplace.invoke(obj); out.removeRef(obj); out.writeObject(repl); out.replaceRef(repl, obj); int ref = out.writeObjectBegin(cl.getName()); out.writeString(_names[i]); out.writeObject(value); out.writeMapEnd(); out.writeInt(_names.length); out.writeString(_names[i]); out.writeObjectBegin(cl.getName()); out.writeObject(value);
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (out.addRef(obj)) return; Collection list = (Collection) obj; Class cl = obj.getClass(); boolean hasEnd; if (cl.equals(ArrayList.class) || !_sendJavaType || !Serializable.class.isAssignableFrom(cl)) hasEnd = out.writeListBegin(list.size(), null); else hasEnd = out.writeListBegin(list.size(), obj.getClass().getName()); Iterator iter = list.iterator(); while (iter.hasNext()) { Object value = iter.next(); out.writeObject(value); } if (hasEnd) out.writeListEnd(); } }
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (out.addRef(obj)) return; int ref = out.writeObjectBegin(cl.getName()); out.writeString("name"); out.writeString(name); out.writeMapEnd(); } else { if (ref == -1) { out.writeClassFieldLength(1); out.writeString("name"); out.writeObjectBegin(cl.getName()); out.writeString(name);
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (out.addRef(obj)) { return; repl = _writeReplace.invoke(obj); out.removeRef(obj); out.writeObject(repl); out.replaceRef(repl, obj); int ref = out.writeObjectBegin(cl.getName()); if (ref == -1) { writeDefinition20(out); out.writeObjectBegin(cl.getName());
public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (out.addRef(obj)) return; Map map = (Map) obj; Class cl = obj.getClass(); if (cl.equals(HashMap.class) || ! _isSendJavaType || ! (obj instanceof java.io.Serializable)) out.writeMapBegin(null); else out.writeMapBegin(obj.getClass().getName()); Iterator iter = map.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); out.writeObject(entry.getKey()); out.writeObject(entry.getValue()); } out.writeMapEnd(); } }
public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { InputStream is = (InputStream) obj; if (is == null) out.writeNull(); else { byte []buf = new byte[1024]; int len; while ((len = is.read(buf, 0, buf.length)) > 0) { out.writeByteBufferPart(buf, 0, len); } out.writeByteBufferEnd(buf, 0, 0); } } }
@Override void serialize(AbstractHessianOutput out, Object obj, Field field) throws IOException { boolean value = false; try { value = field.getBoolean(obj); } catch (IllegalAccessException e) { log.log(Level.FINE, e.toString(), e); } out.writeBoolean(value); } }
@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; int ref = out.writeObjectBegin(cl.getName()); if (ref < -1) { out.writeString("value"); out.writeUTCDate(((Date) obj).getTime()); out.writeMapEnd(); } else { if (ref == -1) { out.writeInt(1); out.writeString("value"); out.writeObjectBegin(cl.getName()); } out.writeUTCDate(((Date) obj).getTime()); } } } }