com.breeweb.slimconnect.commands
Class AbstractCommand

java.lang.Object
  extended bycom.breeweb.slimconnect.commands.AbstractCommand
Direct Known Subclasses:
ControlCommand, DisplayCommand, PlayerCommand, SongCommand

public abstract class AbstractCommand
extends java.lang.Object

Author:
Bas de Bree

Constructor Summary
AbstractCommand(java.lang.String[] params)
           
 
Method Summary
 boolean expectStatus()
          Returns wether this command expects the server to return any status info.
 java.lang.String getAsLine()
          Returns the command as a String which can be send to the Squeezebox server.
 java.lang.String getResultString(java.io.InputStream aStream)
          Returns the result as String reading from the given inputstream.
abstract  ReturnData getReturnData(java.lang.String aLine, java.lang.String playerPrefix)
          Makes sure the command gets executed, the result will be returned using a ReturnData object
 void setExpectStatus(boolean expectStatus)
          Sets a boolean if a status line is expected.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCommand

public AbstractCommand(java.lang.String[] params)
Method Detail

getAsLine

public java.lang.String getAsLine()
                           throws DataException
Returns the command as a String which can be send to the Squeezebox server.

Returns:
the command as a String which can be send to the Squeezebox server.
Throws:
DataException

getReturnData

public abstract ReturnData getReturnData(java.lang.String aLine,
                                         java.lang.String playerPrefix)
Makes sure the command gets executed, the result will be returned using a ReturnData object

Parameters:
aLine - the command as line.
playerPrefix - the prefix of the player to which this command is targeted.
Returns:
a ReturnData object representing the result of the command.

getResultString

public java.lang.String getResultString(java.io.InputStream aStream)
                                 throws java.io.IOException
Returns the result as String reading from the given inputstream. should be overridden (if needed) by each command to process the output.

Parameters:
aStream - the input stream through which results can be read.
Returns:
the result as String reading from the given inputstream
Throws:
java.io.IOException

expectStatus

public boolean expectStatus()
Returns wether this command expects the server to return any status info. default is false

Returns:
wether this command expects the server to return any status info.

setExpectStatus

public void setExpectStatus(boolean expectStatus)
Sets a boolean if a status line is expected.

Parameters:
expectStatus - The expectStatus to set.