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

📄 classstreamhandler.java

📁 Wicket一个开发Java Web应用程序框架。它使得开发web应用程序变得容易而轻松。 Wicket利用一个POJO data beans组件使得它可以与任何持久层技术相结合。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		{			return meth;		}		else if ((mods & Modifier.PRIVATE) != 0)		{			return (cl == defCl) ? meth : null;		}		else		{			return packageEquals(cl, defCl) ? meth : null;		}	}	private static boolean packageEquals(Class cl1, Class cl2)	{		return (cl1.getClassLoader() == cl2.getClassLoader() && getPackageName(cl1).equals(				getPackageName(cl2)));	}	/**	 * Returns package name of given class.	 */	private static String getPackageName(Class cl)	{		String s = cl.getName();		int i = s.lastIndexOf('[');		if (i >= 0)		{			s = s.substring(i + 2);		}		i = s.lastIndexOf('.');		return (i >= 0) ? s.substring(0, i) : "";	}	private abstract class FieldAndIndex	{		final Field field;		final long index;		FieldAndIndex(Field field)		{			this.field = field;			this.index = unsafe.objectFieldOffset(field);		}		public abstract void writeField(Object object, WicketObjectOutputStream dos)				throws IOException;		public abstract void readField(Object object, WicketObjectInputStream dos)				throws IOException, ClassNotFoundException;	}	private final class BooleanFieldAndIndex extends FieldAndIndex	{		BooleanFieldAndIndex(Field field)		{			super(field);		}		/**		 * @throws IOException		 * @see org.apache.wicket.util.io.ClassStreamHandler.FieldAndIndex#writeField(Object,		 *      WicketObjectOutputStream)		 */		public void writeField(Object object, WicketObjectOutputStream dos) throws IOException		{			dos.writeBoolean(unsafe.getBoolean(object, index));		}		/**		 * @see org.apache.wicket.util.io.ClassStreamHandler.FieldAndIndex#readField(Object,		 *      WicketObjectInputStream)		 */		public void readField(Object object, WicketObjectInputStream dos) throws IOException		{			unsafe.putBoolean(object, index, dos.readBoolean());		}	}	private final class ByteFieldAndIndex extends FieldAndIndex	{		ByteFieldAndIndex(Field field)		{			super(field);		}		/**		 * @throws IOException		 * @see org.apache.wicket.util.io.ClassStreamHandler.FieldAndIndex#writeField(Object,		 *      WicketObjectOutputStream)		 */		public void writeField(Object object, WicketObjectOutputStream dos) throws IOException		{			dos.writeByte(unsafe.getByte(object, index));		}		/**		 * @see org.apache.wicket.util.io.ClassStreamHandler.FieldAndIndex#readField(Object,		 *      WicketObjectInputStream)		 */		public void readField(Object object, WicketObjectInputStream dos) throws IOException		{			unsafe.putByte(object, index, dos.readByte());		}	}	private final class ShortFieldAndIndex extends FieldAndIndex	{		ShortFieldAndIndex(Field field)		{			super(field);		}		/**		 * @throws IOException		 * @see org.apache.wicket.util.io.ClassStreamHandler.FieldAndIndex#writeField(Object,		 *      WicketObjectOutputStream)		 */		public void writeField(Object object, WicketObjectOutputStream dos) throws IOException		{			dos.writeShort(unsafe.getShort(object, index));		}		/**		 * @see org.apache.wicket.util.io.ClassStreamHandler.FieldAndIndex#readField(Object,		 *      WicketObjectInputStream)		 */		public void readField(Object object, WicketObjectInputStream dos) throws IOException		{			unsafe.putShort(object, index, dos.readShort());		}	}	private final class CharFieldAndIndex extends FieldAndIndex	{		CharFieldAndIndex(Field field)		{			super(field);		}		/**		 * @throws IOException		 * @see org.apache.wicket.util.io.ClassStreamHandler.FieldAndIndex#writeField(Object,		 *      WicketObjectOutputStream)		 */		public void writeField(Object object, WicketObjectOutputStream dos) throws IOException		{			dos.writeChar(unsafe.getChar(object, index));		}		/**		 * @see org.apache.wicket.util.io.ClassStreamHandler.FieldAndIndex#readField(java.lang.Object,		 *      WicketObjectInputStream)		 */		public void readField(Object object, WicketObjectInputStream dos) throws IOException		{			unsafe.putChar(object, index, dos.readChar());		}	}	private final class IntFieldAndIndex extends FieldAndIndex	{		IntFieldAndIndex(Field field)		{			super(field);		}		/**		 * @throws IOException		 * @see org.apache.wicket.util.io.ClassStreamHandler.FieldAndIndex#writeField(Object,		 *      WicketObjectOutputStream)		 */		public void writeField(Object object, WicketObjectOutputStream dos) throws IOException		{			dos.writeInt(unsafe.getInt(object, index));		}		/**		 * @see org.apache.wicket.util.io.ClassStreamHandler.FieldAndIndex#readField(java.lang.Object,		 *      WicketObjectInputStream)		 */		public void readField(Object object, WicketObjectInputStream dos) throws IOException		{			unsafe.putInt(object, index, dos.readInt());		}	}	private final class LongFieldAndIndex extends FieldAndIndex	{		LongFieldAndIndex(Field field)		{			super(field);		}		/**		 * @throws IOException		 * @see org.apache.wicket.util.io.ClassStreamHandler.FieldAndIndex#writeField(Object,		 *      WicketObjectOutputStream)		 */		public void writeField(Object object, WicketObjectOutputStream dos) throws IOException		{			dos.writeLong(unsafe.getLong(object, index));		}		/**		 * @see org.apache.wicket.util.io.ClassStreamHandler.FieldAndIndex#readField(java.lang.Object,		 *      WicketObjectInputStream)		 */		public void readField(Object object, WicketObjectInputStream dos) throws IOException		{			unsafe.putLong(object, index, dos.readLong());		}	}	private final class FloatFieldAndIndex extends FieldAndIndex	{		FloatFieldAndIndex(Field field)		{			super(field);		}		/**		 * @throws IOException		 * @see org.apache.wicket.util.io.ClassStreamHandler.FieldAndIndex#writeField(Object,		 *      WicketObjectOutputStream)		 */		public void writeField(Object object, WicketObjectOutputStream dos) throws IOException		{			dos.writeFloat(unsafe.getFloat(object, index));		}		/**		 * @see org.apache.wicket.util.io.ClassStreamHandler.FieldAndIndex#readField(java.lang.Object,		 *      WicketObjectInputStream)		 */		public void readField(Object object, WicketObjectInputStream dos) throws IOException		{			unsafe.putFloat(object, index, dos.readFloat());		}	}	private final class DoubleFieldAndIndex extends FieldAndIndex	{		DoubleFieldAndIndex(Field field)		{			super(field);		}		/**		 * @throws IOException		 * @see org.apache.wicket.util.io.ClassStreamHandler.FieldAndIndex#writeField(Object,		 *      WicketObjectOutputStream)		 */		public void writeField(Object object, WicketObjectOutputStream dos) throws IOException		{			dos.writeDouble(unsafe.getDouble(object, index));		}		/**		 * @see org.apache.wicket.util.io.ClassStreamHandler.FieldAndIndex#readField(java.lang.Object,		 *      WicketObjectInputStream)		 */		public void readField(Object object, WicketObjectInputStream dos) throws IOException		{			unsafe.putDouble(object, index, dos.readDouble());		}	}	private final class ObjectFieldAndIndex extends FieldAndIndex	{		ObjectFieldAndIndex(Field field)		{			super(field);		}		/**		 * @throws IOException		 * @see org.apache.wicket.util.io.ClassStreamHandler.FieldAndIndex#writeField(Object,		 *      WicketObjectOutputStream)		 */		public void writeField(Object object, WicketObjectOutputStream dos) throws IOException		{			dos.writeObject(unsafe.getObject(object, index));		}		/**		 * @throws ClassNotFoundException		 * @see org.apache.wicket.util.io.ClassStreamHandler.FieldAndIndex#readField(java.lang.Object,		 *      WicketObjectInputStream)		 */		public void readField(Object object, WicketObjectInputStream dos) throws IOException,				ClassNotFoundException		{			unsafe.putObject(object, index, dos.readObject());		}	}	private abstract class PrimitiveArray	{		public abstract void writeArray(Object object, WicketObjectOutputStream dos)				throws IOException;		public abstract Object readArray(WicketObjectInputStream dos) throws IOException;	}	private final class BooleanPrimitiveArray extends PrimitiveArray	{		/**		 * @throws IOException		 * @see org.apache.wicket.util.io.ClassStreamHandler.PrimitiveArray#writeArray(Object,		 *      WicketObjectOutputStream)		 */		public void writeArray(Object object, WicketObjectOutputStream dos) throws IOException		{			int length = Array.getLength(object);			dos.writeInt(length);			for (int i = 0; i < length; i++)			{				dos.writeBoolean(Array.getBoolean(object, i));			}		}		/**		 * @see org.apache.wicket.util.io.ClassStreamHandler.PrimitiveArray#readArray(WicketObjectInputStream)		 */		public Object readArray(WicketObjectInputStream dos) throws IOException		{			int length = dos.readInt();			Object array = Array.newInstance(getStreamClass(), length);			for (int i = 0; i < length; i++)			{				Array.setBoolean(array, i, dos.readBoolean());			}			return array;		}	}	private final class BytePrimitiveArray extends PrimitiveArray	{		/**		 * @throws IOException		 * @see org.apache.wicket.util.io.ClassStreamHandler.PrimitiveArray#writeArray(Object,		 *      WicketObjectOutputStream)		 */		public void writeArray(Object object, WicketObjectOutputStream dos) throws IOException		{			int length = Array.getLength(object);			dos.writeInt(length);			for (int i = 0; i < length; i++)			{				dos.writeByte(Array.getByte(object, i));			}		}		/**		 * @see org.apache.wicket.util.io.ClassStreamHandler.PrimitiveArray#readArray(WicketObjectInputStream)		 */		public Object readArray(WicketObjectInputStream dos) throws IOException		{			int length = dos.readInt();			Object array = Array.newInstance(getStreamClass(), length);			for (int i = 0; i < length; i++)			{				Array.setByte(array, i, dos.readByte());			}			return array;		}	}	private final class ShortPrimitiveArray extends PrimitiveArray	{		/**		 * @throws IOException		 * @see org.apache.wicket.util.io.ClassStreamHandler.PrimitiveArray#writeArray(Object,		 *      WicketObjectOutputStream)		 */		public void writeArray(Object object, WicketObjectOutputStream dos) throws IOException		{			int length = Array.getLength(object);			dos.writeInt(length);			for (int i = 0; i < length; i++)			{				dos.writeShort(Array.getShort(object, i));			}		}		/**		 * @see org.apache.wicket.util.io.ClassStreamHandler.PrimitiveArray#readArray(WicketObjectInputStream)		 */		public Object readArray(WicketObjectInputStream dos) throws IOException		{			int length = dos.readInt();			Object array = Array.newInstance(getStreamClass(), length);			for (int i = 0; i < length; i++)			{				Array.setShort(array, i, dos.readShort());			}			return array;		}	}	private final class CharPrimitiveArray extends PrimitiveArray	{		/**		 * @throws IOException		 * @see org.apache.wicket.util.io.ClassStreamHandler.PrimitiveArray#writeArray(Object,		 *      WicketObjectOutputStream)		 */		public void writeArray(Object object, WicketObjectOutputStream dos) throws IOException		{			int length = Array.getLength(object);			dos.writeInt(length);			for (int i = 0; i < length; i++)			{				dos.writeChar(Array.getChar(object, i));			}		}		/**		 * @see org.apache.wicket.util.io.ClassStreamHandler.PrimitiveArray#readArray(WicketObjectInputStream)		 */		public Object readArray(WicketObjectInputStream dos) throws IOException		{			int length = dos.readInt();			Object array = Array.newInstance(getStreamClass(), length);			for (int i = 0; i < length; i++)			{				Array.setChar(array, i, dos.readChar());			}			return array;		}	}	private final class IntPrimitiveArray extends PrimitiveArray	{		/**		 * @throws IOException		 * @see org.apache.wicket.util.io.ClassStreamHandler.PrimitiveArray#writeArray(Object,		 *      WicketObjectOutputStream)		 */		public void writeArray(Object object, WicketObjectOutputStream dos) throws IOException		{			int length = Array.getLength(object);			dos.writeInt(length);			for (int i = 0; i < length; i++)			{				dos.writeInt(Array.getInt(object, i));			}		}		/**		 * @see org.apache.wicket.util.io.ClassStreamHandler.PrimitiveArray#readArray(WicketObjectInputStream)		 */		public Object readArray(WicketObjectInputStream dos) throws IOException		{			int length = dos.readInt();			Object array = Array.newInstance(getStreamClass(), length);			for (int i = 0; i < length; i++)			{				Array.setInt(array, i, dos.readInt());			}			return array;		}	}	private final class LongPrimitiveArray extends PrimitiveArray	{		/**		 * @throws IOException		 * @see org.apache.wicket.util.io.ClassStreamHandler.PrimitiveArray#writeArray(Object,		 *      WicketObjectOutputStream)		 */		public void writeArray(Object object, WicketObjectOutputStream dos) throws IOException		{			int length = Array.getLength(object);			dos.writeInt(length);			for (int i = 0; i < length; i++)			{				dos.writeLong(Array.getLong(object, i));			}		}		/**		 * @see org.apache.wicket.util.io.ClassStreamHandler.PrimitiveArray#readArray(WicketObjectInputStream)		 */		public Object readArray(WicketObjectInputStream dos) throws IOException		{			int length = dos.readInt();			Object array = Array.newInstance(getStreamClass(), length);			for (int i = 0; i < length; i++)			{				Array.setLong(array, i, dos.readLong());			}			return array;		}	}	private final class FloatPrimitiveArray extends PrimitiveArray	{		/**		 * @throws IOException		 * @see org.apache.wicket.util.io.ClassStreamHandler.PrimitiveArray#writeArray(Object,		 *      WicketObjectOutputStream)		 */		public void writeArray(Object object, WicketObjectOutputStream dos) throws IOException		{			int length = Array.getLength(object);			dos.writeInt(length);			for (int i = 0; i < length; i++)			{				dos.writeFloat(Array.getFloat(object, i));			}		}		/**		 * @see org.apache.wicket.util.io.ClassStreamHandler.PrimitiveArray#readArray(WicketObjectInputStream)		 */		public Object readArray(WicketObjectInputStream dos) throws IOException		{			int length = dos.readInt();			Object array = Array.newInstance(getStreamClass(), length);			for (int i = 0; i < length; i++)			{				Array.setFloat(array, i, dos.readFloat());			}			return array;		}	}	private final class DoublePrimitiveArray extends PrimitiveArray	{		/**		 * @throws IOException		 * @see org.apache.wicket.util.io.ClassStreamHandler.PrimitiveArray#writeArray(Object,		 *      WicketObjectOutputStream)		 */		public void writeArray(Object object, WicketObjectOutputStream dos) throws IOException		{			int length = Array.getLength(object);			dos.writeInt(length);			for (int i = 0; i < length; i++)			{				dos.writeDouble(Array.getDouble(object, i));			}		}		/**		 * @see org.apache.wicket.util.io.ClassStreamHandler.PrimitiveArray#readArray(WicketObjectInputStream)		 */		public Object readArray(WicketObjectInputStream dos) throws IOException		{			int length = dos.readInt();			Object array = Array.newInstance(getStreamClass(), length);			for (int i = 0; i < length; i++)			{				Array.setDouble(array, i, dos.readDouble());			}			return array;		}	}	/**	 * @return	 * @throws NotSerializableException	 */	public Object writeReplace(Object o) throws NotSerializableException	{		if (writeReplaceMethod != null)		{			try			{				return writeReplaceMethod.invoke(o, null);			}			catch (Exception ex)			{				throw new NotSerializableException(ex.getMessage());			}		}		return null;	}	public Object readResolve(Object o) throws NotSerializableException	{		if (readResolveMethod != null)		{			try			{				return readResolveMethod.invoke(o, null);			}			catch (Exception ex)			{				throw new NotSerializableException(ex.getMessage());			}		}		return o;	}}

⌨️ 快捷键说明

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