JavaTM 2 Platform
Standard Ed. 6

java.security
类 GuardedObject

java.lang.Object
  继承者 java.security.GuardedObject
所有已实现的接口:
Serializable

public class GuardedObject
extends Object
implements Serializable

GuardedObject 是一个用来保护对另一个对象的访问的对象。

GuardedObject 封装一个目标对象和一个 Guard 对象,仅当 Guard 对象允许时才可能对目标对象进行访问。一旦 GuardedObject 封装了某个对象,getObject 方法就会控制对该对象的访问,这一方法将对保护访问的 Guard 对象调用 checkGuard 方法。如果不允许访问,则抛出异常。

另请参见:
Guard, Permission, 序列化表格

构造方法摘要
GuardedObject(Object object, Guard guard)
          使用指定的对象和 guard 构造 GuardedObject。
 
方法摘要
 Object getObject()
          获取受保护对象;如果 guard 拒绝了对受保护对象的访问,则抛出异常。
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

GuardedObject

public GuardedObject(Object object,
                     Guard guard)
使用指定的对象和 guard 构造 GuardedObject。如果 Guard 对象为 null,则对于谁可以访问对象没有任何限制。

参数:
object - 要保护的对象。
guard - 保护对对象的访问的 Guard 对象。
方法详细信息

getObject

public Object getObject()
                 throws SecurityException
获取受保护对象;如果 guard 拒绝了对受保护对象的访问,则抛出异常。

返回:
受保护对象
抛出:
SecurityException - 如果拒绝对受保护对象的访问。

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见

版权所有 2008 Sun Microsystems, Inc. 保留所有权利。请遵守GNU General Public License, version 2 only