|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jmythapi.protocol.utils.CommandUtils
public class CommandUtils
This class provides protocol command related utility functions.
This class can be used to:
link
)link
)link
)link
)link
)
IMythCommand
,
MythProtoVersionAnnotation
Field Summary | |
---|---|
static LinkedHashMap<String,Object[]> |
COMMANDS
A list of known MythTV-protocol commands. |
static String |
DELIM
|
Constructor Summary | |
---|---|
CommandUtils()
|
Method Summary | |
---|---|
static MythProtocolCmd |
getCommandDeclaration(String commandName,
String subCommandName)
|
static ProtocolVersionRange |
getCommandVersionRange(String commandName)
Returns the version-range the given command is supported in. |
static boolean |
isKnownCommand(IMythCommand command)
Checks if the command is known to be supported by any supported MythTV version. |
static boolean |
isKnownCommand(IMythRequest request)
Checks if the command of a request is known to be supported by any supported MythTV version. |
static boolean |
isKnownCommand(String commandName)
Checks if a command is known to be supported by any supported MythTV version. |
static void |
printCommands(ProtocolVersion protoVersion)
Prints all MythTV-protocol-commands that are supported by the given protocol-version to stdout. |
static IMythCommand |
readFrom(ProtocolVersion protoVersion,
String commandString)
Reads a MythTV protocol command from a string. |
static void |
writeTo(IMythCommand command,
OutputStream output)
Writes the given command object to an output stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DELIM
public static final LinkedHashMap<String,Object[]> COMMANDS
Field
defined in IMythCommand
, the second is a LinkedHashMap
containing all sub-commands that belong to the command.
Constructor Detail |
---|
public CommandUtils()
Method Detail |
---|
public static void printCommands(ProtocolVersion protoVersion)
protoVersion
- the version for which a commandlist should be printed.
Use ProtocolVersion.PROTO_VERSION_LATEST
for the current trunk
version or null
to print all known commands independently of the
protocol version.public static boolean isKnownCommand(IMythRequest request)
request
- the request whose command should be checked
true
if the given command is supported or false
otherwise.public static boolean isKnownCommand(IMythCommand command)
command
- the command to check
true
if the given command is supported or false
otherwise.public static boolean isKnownCommand(String commandName)
commandName
- the name of the command, e.g. QUERY_RECORDER
true
if the given command is supported or false
otherwise.public static ProtocolVersionRange getCommandVersionRange(String commandName) throws UnknownCommandException
A command can only be used in the version range returned by this method. Otherwise an
UnsupportedCommandException
will be thrown by the backend-connection.
Usage example:
// the following will return the version range [9,-1) ProtocolVersionRange versionRange = CommandUtils.getCommandVersionRange(IMythCommand.GET_FREE_RECORDER_COUNT); System.out.println(versionRange);
GET_FREE_RECORDER_COUNT
was introduced in protocol version 09
and is supported up to the current protocol version.
commandName
- the command name
UnknownCommandException
- if the command is not supported by any known protocol-version.public static MythProtocolCmd getCommandDeclaration(String commandName, String subCommandName) throws UnknownCommandException
UnknownCommandException
public static final IMythCommand readFrom(ProtocolVersion protoVersion, String commandString) throws IllegalArgumentException
The given command string is splitted into parts (using the separator DELIM
) and thereafter
a IMythCommand
object is created with the extracted command-name and -arguments.
String commandString = "ANN Monitor MythClient 0"; IMythCommand command = CommandUtils.readFrom(PROTO_VERSION_56, commandString);
protoVersion
- the protocol version of the commandcommandString
- the command string, e.g. ANN Monitor MythClient 0
IllegalArgumentException
- if the given command string is invalidpublic static final void writeTo(IMythCommand command, OutputStream output) throws UnsupportedEncodingException, IOException
command
- the command to write outoutput
- the output stream.
UnsupportedEncodingException
- on encoding errors
IOException
- on communication errors
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |