CommandInfo (Java EE 5)

Java EE API


javax.activation Class CommandInfo

java.lang.Object
  extended by javax.activation.CommandInfo

public class CommandInfo
extends Object


CommandMap 实现使用 CommandInfo 类描述命令请求的结果。它为请求者提供所请求的动词,以及 bean 的一个实例。还有一个方法,它将返回实现命令的类的名称,但是它不保证返回有效值。原因是允许子类化 CommandInfo 的 CommandMap 实现提供特殊行为。例如,CommandMap 能够动态生成 JavaBean。在这种情况下,不太可能仅根据类名称便创建带有全部正确状态信息的对象。
英文文档:

The CommandInfo class is used by CommandMap implementations to describe the results of command requests. It provides the requestor with both the verb requested, as well as an instance of the bean. There is also a method that will return the name of the class that implements the command but it is not guaranteed to return a valid value. The reason for this is to allow CommandMap implmentations that subclass CommandInfo to provide special behavior. For example a CommandMap could dynamically generate JavaBeans. In this case, it might not be possible to create an object with all the correct state information solely from the class name.


Constructor Summary
 
Method Summary
 String
 String
 Object
 
Methods inherited from class java.lang.Object
 

Constructor Detail

public CommandInfo(String verb, String className)
CommandInfo 的构造方法。
verb 此 CommandInfo 描述的命令动词。
className 命令的完全限定类名。
英文文档:

CommandInfo

public CommandInfo(String verb,
                   String className)
The Constructor for CommandInfo.

Parameters:
verb - The command verb this CommandInfo decribes.
className - The command's fully qualified class name.

Method Detail

public String getCommandName()
返回命令动词。
return 命令动词。
英文文档:

getCommandName

public String getCommandName()
Return the command verb.

Returns:
the command verb.

public String getCommandClass()
返回命令的类名。当 CommandMap 根据其目的子类化 CommandInfo 时,此方法可能返回 null。换句话说,仅知道其类名不太可能创建命令的正确状态。不要依赖此方法来返回有效值!
return 命令的类名,或 null
英文文档:

getCommandClass

public String getCommandClass()
Return the command's class name. This method MAY return null in cases where a CommandMap subclassed CommandInfo for its own purposes. In other words, it might not be possible to create the correct state in the command by merely knowing its class name. DO NOT DEPEND ON THIS METHOD RETURNING A VALID VALUE!

Returns:
The class name of the command, or null

public Object getCommandObject(DataHandler dh, ClassLoader loader) throws java.io.IOException, ClassNotFoundException
返回已实例化的 JavaBean 组件。

从用 Beans.instantiate() 实例化组件开始。

如果 bean 实现了 javax.activation.CommandObject 接口,则调用其 setCommandContext 方法。

如果 DataHandler 参数为 null,则 bean 被实例化,且不带任何数据。注:如果由于某种原因,此方法试图访问其 InputStream 时传入的 DataHandler 抛出 IOExceptions,那么这将很有用。它将允许调用者获取对 bean 的引用(如果它可以被实例化)。

如果 bean 不实现 CommandObject 接口,那么此方法将检查它是否实现 java.io.Externalizable 接口。如果它实现 CommandObject 接口,若可以从 DataHandler 获取 InputStream,则将调用 bean 的 readExternal 方法。

dh 描述要传递给命令的数据的 DataHandler。
loader 将用于实例化 bean 的 ClassLoader。
return bean
See also instantiate, javax.activation.CommandObject

英文文档:

getCommandObject

public Object getCommandObject(DataHandler dh,
                               ClassLoader loader)
                        throws IOException,
                               ClassNotFoundException
Return the instantiated JavaBean component.

Begin by instantiating the component with Beans.instantiate().

If the bean implements the javax.activation.CommandObject interface, call its setCommandContext method.

If the DataHandler parameter is null, then the bean is instantiated with no data. NOTE: this may be useful if for some reason the DataHandler that is passed in throws IOExceptions when this method attempts to access its InputStream. It will allow the caller to retrieve a reference to the bean if it can be instantiated.

If the bean does NOT implement the CommandObject interface, this method will check if it implements the java.io.Externalizable interface. If it does, the bean's readExternal method will be called if an InputStream can be acquired from the DataHandler.

Parameters:
dh - The DataHandler that describes the data to be passed to the command.
loader - The ClassLoader to be used to instantiate the bean.
Returns:
The bean
Throws:
IOException
ClassNotFoundException
See Also:
Beans.instantiate(java.lang.ClassLoader, java.lang.String), CommandObject


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!