Main Page Cookbook/Overview ImageMeister the jcprops file Licensing Binary Installation & Configuration [ Win · Mac · Nix · OSX ] Changes Public API Source Code Main Page Java [ Common · Win · Mac · Nix ] Native Code [ Common · Win · Mac · Nix ] Manifest Native Code Overviews [ Common · Win · Mac · Nix · Strings ] Macros [ General · Native Macros ] Walkthroughs [ Java only · Java and native ] Building [ Win · Mac · Nix · OSX ] Distribution Issues

    All Packages  This Package  Class Hierarchy  Class Search  Index

Interface com.jconfig.AppCommand

Summary

    public interface  AppCommand
         extends com.jconfig.DumpInfo
    {
              // Fields 6
         public static final String copyrightString;
         public static final String kAppCommandOpenApp;
         public static final String kAppCommandOpenDoc;
         public static final String kAppCommandPlay;
         public static final String kAppCommandPrintDoc;
         public static final String kAppCommandQuit;

              // Methods 11
         public abstract void addArg(Object);
         public abstract String asString();
         public abstract void clearArgs();
         public abstract Object getArg(int);
         public abstract String getCommand();
         public abstract int getMaxNumArgs();
         public abstract int getNumArgs();
         public abstract Class[] getPermissibleArgumentType(int);
         public abstract boolean isNumArgsUnlimited();
         public abstract boolean isSingleInstanceCapable();
         public abstract AppCommand redup();
    }

Represents a command which can be sent to an application or one of its instances. After retrieving an AppCommand from an AppFile or an AppProcess, you can add arguments to it, if desired, and then tell the AppFile or AppProcess to execute the command. In the case of an AppFile, if the command succeeds, it returns an AppProcess after executing the command.

For instance:

        AppFile    appFile;
        AppCommand openCommand;

        //  first obtain the appFile, perhaps using one of the
        //  FileRegistry.getApps() methods.

        //  Then, try to get a command from the app for opening
        //  with a document.

        openCommand = appFile.getCommand( AppCommand.kAppCommandOpenDoc );

        //  If 'openCommand' is not null, this app can accept commands of
        //  this type

        if ( openCommand != null ) {
            //  Add the file we want to open to the command.

            appCommand.addArg( "c:\\myfile.txt" );

            //  Tell the app to perform the command, and spawn a new
            //  instance

            appProcess = appFile.performCommand( appCommand, 0 );

            //  if appProcess is non-null, the process was created successfully,
            //  and 'c:\myfile.txt' was used to open it
        }

Some classes which implement this interface do not take arguments; if you try to add an argument to a class of this type, an IllegalArgumentException exception will be thrown. After obtaining an AppCommand object, use the getMaxNumArgs() method to determine how many arguments the object can take.

Currently, for those classes which implement this interface and which accept arguments, 'arg' must a String, a File, or a DiskObject, which is interpreted as follows:

        if ( arg == null )
            throw an IllegalArgumentException
        else if ( arg instanceof String )
            add it to the list of arguments
        else if ( arg instanceof File )
            add ( (File) arg ).getPath() to the list of arguments;
        else if ( arg instanceof DiskObject )
            add ( ( (DiskObject) arg ).getFile() ).getPath() to the list of arguments
        else
            throw an IllegalArgumentException

IMPORTANT NOTE: The classes of objects which a specific instance's addArg() method can take is subject to change. Currently, several classes implement this interface; in the future, the objects which can be passed to the addArg() method may change. Use the getPermissibleArgumentType() method to determine exactly which type of object you can pass to the addArg() method.

WINDOWS NOTE: As of version 1.2.1, any arguments which are added to a command will be surrounded with quotes when the command line which is used to perform the command is created. The arguments will not be changed by this class, only when the command line is created.

Author:
  Copyright (c) 1997-2002 Samizdat Productions. All Rights Reserved.

Cross Reference

Returned By:
  AppCommand.redup(), AppFile.getAllCommands(), AppFile.getCommand(), AppProcess.getAllCommands(), AppProcess.getCommand()

Fields

### · copyrightString | Summary | Top

       public static final String copyrightString

### · kAppCommandOpenDoc | Summary | Top

       public static final String kAppCommandOpenDoc

> Name of command to open an application with one or more documents.

### · kAppCommandOpenApp | Summary | Top

       public static final String kAppCommandOpenApp

> Name of command to open an application with no documents.

### · kAppCommandPrintDoc | Summary | Top

       public static final String kAppCommandPrintDoc

> Name of command to tell an application to print one or more documents.

### · kAppCommandPlay | Summary | Top

       public static final String kAppCommandPlay

> Name of command to tell an application to play one or more documents.

### · kAppCommandQuit | Summary | Top

       public static final String kAppCommandQuit

> Name of command to tell an application to quit.

Methods

### · getCommand | Summary | Top

       public abstract String getCommand()

> Return the name of this command.

### · asString | Summary | Top

       public abstract String asString()

> Return the command as a string.

### · redup | Summary | Top

       public abstract AppCommand redup()

> Create a new instance of this command ( not a clone ).

### · getMaxNumArgs | Summary | Top

       public abstract int getMaxNumArgs()

> Returns the maximum number of arguments this command can take. -1 is returned if this command can take an unlimited number.

### · addArg | Summary | Top

       public abstract void addArg(Object arg)

> Adds 'arg' to the end of the list of this command's arguments.

### · getNumArgs | Summary | Top

       public abstract int getNumArgs()

> Returns the current number of arguments for this command.

### · getPermissibleArgumentType | Summary | Top

       public abstract Class[] getPermissibleArgumentType(int position)

> Returns an array containing the classes which can be used as arguments for the indicated position in the argument list. If this command does not take commands, null is returned.

### · clearArgs | Summary | Top

       public abstract void clearArgs()

> Delete any arguments previously added to the command.

### · getArg | Summary | Top

       public abstract Object getArg(int which)

> Returns the indicated argument in this command's argument list. If 'which' is out of range, null is returned.

### · isNumArgsUnlimited | Summary | Top

       public abstract boolean isNumArgsUnlimited()

> Returns whether this command can take an unlimited number of arguments.

### · isSingleInstanceCapable | Summary | Top

       public abstract boolean isSingleInstanceCapable()

> Returns whether this command can be executed without creating a new process.

    All Packages  This Package  Class Hierarchy  Class Search  Index

Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7