⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wicketobjectoutputstream.java

📁 Wicket一个开发Java Web应用程序框架。它使得开发web应用程序变得容易而轻松。 Wicket利用一个POJO data beans组件使得它可以与任何持久层技术相结合。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
				while (it.hasNext())				{					Map.Entry entry = (Entry)it.next();					// write the key.					writeObjectOverride(entry.getKey());					writeObjectOverride(entry.getValue());				}			}			// end byte.			writeShort(ClassStreamHandler.NULL);		}	}	private final HandleTable handledObjects = new HandleTable();	private final HandleArrayListStack defaultWrite = new HandleArrayListStack();	private final DataOutputStream out;	private ClassStreamHandler classHandler;	private PutField curPut;	private Object curObject;	/**	 * Construct.	 * 	 * @param out	 * @throws IOException	 */	public WicketObjectOutputStream(OutputStream out) throws IOException	{		super();		this.out = new DataOutputStream(out);	}	/**	 * @see java.io.ObjectOutputStream#close()	 */	public void close() throws IOException	{		classHandler = null;		curObject = null;		curPut = null;		handledObjects.clear();		defaultWrite.clear();		out.close();	}	/**	 * @see java.io.ObjectOutputStream#defaultWriteObject()	 */	public void defaultWriteObject() throws IOException	{		if (!defaultWrite.contains(curObject))		{			defaultWrite.add(curObject);			classHandler.writeFields(this, curObject);		}	}	/**	 * @see java.io.ObjectOutputStream#putFields()	 */	public PutField putFields() throws IOException	{		if (curPut == null)		{			try			{				curPut = new PutFieldImpl();			}			catch (Exception e)			{				throw new WicketSerializeableException("Error reading put fields", e);			}		}		return curPut;	}	/**	 * @see java.io.ObjectOutputStream#write(byte[])	 */	public void write(byte[] buf) throws IOException	{		out.write(buf);	}	/**	 * @see java.io.ObjectOutputStream#write(byte[], int, int)	 */	public void write(byte[] buf, int off, int len) throws IOException	{		out.write(buf, off, len);	}	/**	 * @see java.io.ObjectOutputStream#write(int)	 */	public void write(int val) throws IOException	{		out.write(val);	}	/**	 * Writes a boolean.	 * 	 * @param val	 *            the boolean to be written	 * @throws IOException	 *             if I/O errors occur while writing to the underlying stream	 */	public void writeBoolean(boolean val) throws IOException	{		out.writeBoolean(val);	}	/**	 * Writes an 8 bit byte.	 * 	 * @param val	 *            the byte value to be written	 * @throws IOException	 *             if I/O errors occur while writing to the underlying stream	 */	public void writeByte(int val) throws IOException	{		out.writeByte(val);	}	/**	 * Writes a String as a sequence of bytes.	 * 	 * @param str	 *            the String of bytes to be written	 * @throws IOException	 *             if I/O errors occur while writing to the underlying stream	 */	public void writeBytes(String str) throws IOException	{		out.writeBytes(str);	}	/**	 * Writes a 16 bit char.	 * 	 * @param val	 *            the char value to be written	 * @throws IOException	 *             if I/O errors occur while writing to the underlying stream	 */	public void writeChar(int val) throws IOException	{		out.writeChar(val);	}	/**	 * Writes a String as a sequence of chars.	 * 	 * @param str	 *            the String of chars to be written	 * @throws IOException	 *             if I/O errors occur while writing to the underlying stream	 */	public void writeChars(String str) throws IOException	{		out.writeChars(str);	}	/**	 * Writes a 64 bit double.	 * 	 * @param val	 *            the double value to be written	 * @throws IOException	 *             if I/O errors occur while writing to the underlying stream	 */	public void writeDouble(double val) throws IOException	{		out.writeDouble(val);	}	/**	 * @see java.io.ObjectOutputStream#writeFields()	 */	public void writeFields() throws IOException	{		if (curPut != null)		{			try			{				curPut.write(this);			}			catch (Exception e)			{				throw new WicketSerializeableException("Error writing put fields", e);			}		}	}	/**	 * Writes a 32 bit float.	 * 	 * @param val	 *            the float value to be written	 * @throws IOException	 *             if I/O errors occur while writing to the underlying stream	 */	public void writeFloat(float val) throws IOException	{		out.writeFloat(val);	}	/**	 * Writes a 32 bit int.	 * 	 * @param val	 *            the integer value to be written	 * @throws IOException	 *             if I/O errors occur while writing to the underlying stream	 */	public void writeInt(int val) throws IOException	{		out.writeInt(val);	}	/**	 * Writes a 64 bit long.	 * 	 * @param val	 *            the long value to be written	 * @throws IOException	 *             if I/O errors occur while writing to the underlying stream	 */	public void writeLong(long val) throws IOException	{		out.writeLong(val);	}	/**	 * Writes a 16 bit short.	 * 	 * @param val	 *            the short value to be written	 * @throws IOException	 *             if I/O errors occur while writing to the underlying stream	 */	public void writeShort(int val) throws IOException	{		out.writeShort(val);	}	/**	 * @see java.io.ObjectOutputStream#writeUTF(java.lang.String)	 */	public void writeUTF(String str) throws IOException	{		out.writeUTF(str);	}	/**	 * @see java.io.ObjectOutputStream#writeObjectOverride(java.lang.Object)	 */	protected final void writeObjectOverride(Object obj) throws IOException	{		if (obj == null)		{			out.write(ClassStreamHandler.NULL);			return;		}		int handle = handledObjects.lookup(obj);		if (handle != -1)		{			out.write(ClassStreamHandler.HANDLE);			out.writeShort(handle);		}		else		{			if (obj instanceof Class)			{				ClassStreamHandler classHandler = ClassStreamHandler.lookup((Class)obj);				out.write(ClassStreamHandler.CLASS);				out.writeShort(classHandler.getClassId());			}			else			{				Class cls = obj.getClass();				handledObjects.assign(obj);				if (cls.isArray())				{					Class componentType = cls.getComponentType();					ClassStreamHandler classHandler = ClassStreamHandler.lookup(componentType);					if (componentType.isPrimitive())					{						try						{							out.write(ClassStreamHandler.PRIMITIVE_ARRAY);							out.writeShort(classHandler.getClassId());							classHandler.writeArray(obj, this);						}						catch (WicketSerializeableException wse)						{							wse									.addTrace(componentType.getName() + "[" + Array.getLength(obj) +											"]");							throw wse;						}						catch (Exception e)						{							throw new WicketSerializeableException(									"Error writing primitive array of " + componentType.getName() +											"[" + Array.getLength(obj) + "]", e);						}					}					else					{						int length = Array.getLength(obj);						try						{							out.write(ClassStreamHandler.ARRAY);							out.writeShort(classHandler.getClassId());							out.writeInt(length);							for (int i = 0; i < length; i++)							{								writeObjectOverride(Array.get(obj, i));							}						}						catch (WicketSerializeableException wse)						{							wse.addTrace(componentType.getName() + "[" + length + "]");							throw wse;						}						catch (Exception e)						{							throw new WicketSerializeableException("Error writing array of " +									componentType.getName() + "[" + length + "]", e);						}					}					return;				}				else				{					Class realClz = cls;					classHandler = ClassStreamHandler.lookup(realClz);					Object object = classHandler.writeReplace(obj);					if (object != null)					{						obj = object;						realClz = obj.getClass();						classHandler = ClassStreamHandler.lookup(realClz);					}					out.write(ClassStreamHandler.CLASS_DEF);					out.writeShort(classHandler.getClassId());					// handle strings directly.					if (obj instanceof String)					{						out.writeUTF((String)obj);					}					else					{						PutField old = curPut;						Object oldObject = curObject;						curPut = null;						curObject = obj;						try						{							if (!classHandler.invokeWriteMethod(this, obj))							{								classHandler.writeFields(this, obj);							}						}						catch (WicketSerializeableException wse)						{							if (realClz != cls)							{								wse.addTrace(realClz.getName() + "(ReplaceOf:" + cls.getName() +										")");							}							else							{								wse.addTrace(realClz.getName());							}							throw wse;						}						catch (Exception e)						{							if (realClz != cls)							{								throw new WicketSerializeableException("Error writing fields for " +										realClz.getName() + "(ReplaceOf:" + cls.getName() + ")", e);							}							else							{								throw new WicketSerializeableException("Error writing fields for " +										realClz.getName(), e);							}						}						finally						{							curObject = oldObject;							curPut = old;						}					}				}			}		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -