Top Description Inners Fields Constructors Methods
jakarta.activation

public Class CommandInfo

extends Object
Class Inheritance
Imports
java.io.*, java.lang.reflect.InvocationTargetException, .Method, java.security.AccessController, .PrivilegedAction

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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
CommandInfo.Beans

Helper class to invoke Beans.instantiate reflectively or the equivalent with core reflection when module java.desktop is not readable.

Field Summary

Modifier and TypeField and Description
private String
private String

Constructor Summary

AccessConstructor and Description
public
CommandInfo(String
The command verb this CommandInfo decribes.
verb
,
String
The command's fully qualified class name.
className
)

The Constructor for CommandInfo.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

The class name of the command, or null
getCommandClass
()

Return the command's class name.

public String

Returns:

the command verb.
getCommandName
()

Return the command verb.

public Object

Returns:

The bean
getCommandObject
(DataHandler
The DataHandler that describes the data to be passed to the command.
dh
,
ClassLoader
The ClassLoader to be used to instantiate the bean.
loader
)

Return the instantiated JavaBean component.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classNameback to summary
private String className
verbback to summary
private String verb

Constructor Detail

CommandInfoback to summary
public CommandInfo(String verb, String className)

The Constructor for CommandInfo.

Parameters
verb:String

The command verb this CommandInfo decribes.

className:String

The command's fully qualified class name.

Method Detail

getCommandClassback to summary
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:String

The class name of the command, or null

getCommandNameback to summary
public String getCommandName()

Return the command verb.

Returns:String

the command verb.

getCommandObjectback to summary
public Object getCommandObject(DataHandler dh, ClassLoader loader) throws IOException, ClassNotFoundException

Return the instantiated JavaBean component.

If the current runtime environment supports Beans.instantiate, use it to instantiate the JavaBeans component. Otherwise, use Class.forName.

The component class needs to be public. On Java SE 9 and newer, if the component class is in a named module, it needs to be in an exported package.

If the bean implements the jakarta.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:DataHandler

The DataHandler that describes the data to be passed to the command.

loader:ClassLoader

The ClassLoader to be used to instantiate the bean.

Returns:Object

The bean

Exceptions
IOException:
for failures reading data
ClassNotFoundException:
if command object class can't be found
See Also
jakarta.activation.CommandObject
jakarta.activation back to summary

private final Class CommandInfo.Beans

extends Object
Class Inheritance

Helper class to invoke Beans.instantiate reflectively or the equivalent with core reflection when module java.desktop is not readable.

Field Summary

Modifier and TypeField and Description
pack-priv static final Method

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static Object
instantiate(ClassLoader loader, String cn)

Equivalent to invoking java.beans.Beans.instantiate(loader, cn)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

instantiateMethodback to summary
pack-priv static final Method instantiateMethod

Constructor Detail

Beansback to summary
private Beans()

Method Detail

instantiateback to summary
pack-priv static Object instantiate(ClassLoader loader, String cn) throws IOException, ClassNotFoundException

Equivalent to invoking java.beans.Beans.instantiate(loader, cn)