org.sdnplatform.sync.client
Class ShellCommand

java.lang.Object
  extended by org.sdnplatform.sync.client.ShellCommand
Direct Known Subclasses:
SyncClient.DeleteCommand, SyncClient.EntriesCommand, SyncClient.GetCommand, SyncClient.HelpCommand, SyncClient.PutCommand, SyncClient.QuitCommand, SyncClient.RegisterCommand, SyncClient.StoreCommand

public abstract class ShellCommand
extends java.lang.Object

A user command for the command line client

Author:
readams

Field Summary
protected static com.fasterxml.jackson.databind.ObjectMapper mapper
           
protected static com.fasterxml.jackson.databind.MappingJsonFactory mjf
           
 
Constructor Summary
ShellCommand()
           
 
Method Summary
abstract  boolean execute(java.lang.String[] tokens, java.lang.String line)
          Execute the command on the given tokens
protected  byte[] serializeJson(com.fasterxml.jackson.databind.JsonNode value)
          Serialize a JSON object as bytes
abstract  java.lang.String syntaxString()
          Return syntax description
protected  com.fasterxml.jackson.databind.JsonNode validateJson(com.fasterxml.jackson.core.JsonParser jp)
          Parse a JSON object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mapper

protected static final com.fasterxml.jackson.databind.ObjectMapper mapper

mjf

protected static final com.fasterxml.jackson.databind.MappingJsonFactory mjf
Constructor Detail

ShellCommand

public ShellCommand()
Method Detail

execute

public abstract boolean execute(java.lang.String[] tokens,
                                java.lang.String line)
                         throws java.lang.Exception
Execute the command on the given tokens

Parameters:
tokens - the argument tokens. The first token will be the command
line - the whole command line
Returns:
whether to exit the shell after the command
Throws:
java.lang.Exception

syntaxString

public abstract java.lang.String syntaxString()
Return syntax description

Returns:
the syntax string

validateJson

protected com.fasterxml.jackson.databind.JsonNode validateJson(com.fasterxml.jackson.core.JsonParser jp)
                                                        throws java.io.IOException
Parse a JSON object

Parameters:
jp - the JSON parse
Returns:
the JSON node
Throws:
java.io.IOException

serializeJson

protected byte[] serializeJson(com.fasterxml.jackson.databind.JsonNode value)
                        throws java.lang.Exception
Serialize a JSON object as bytes

Parameters:
value - the object to serialize
Returns:
the serialized bytes
Throws:
java.lang.Exception