pl.mbdev.openstage
Class IppCommand

java.lang.Object
  extended by pl.mbdev.openstage.Xml
      extended by pl.mbdev.openstage.IppCommand

public class IppCommand
extends Xml

Allows user's interaction with many aspects of the OpenStage phone. Commands can change behaviour of the current XML application, launch another, and enable communication with any remote server.

 Copyright 2011 Mateusz Bysiek,
     mb@mbdev.pl, http://mbdev.pl/
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
 
     http://www.apache.org/licenses/LICENSE-2.0
 
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 

Author:
Mateusz Bysiek

Nested Class Summary
static class IppCommand.Default
          Possible values of a field that indicates whether this command will be a default command in the context menu.
static class IppCommand.DisplayOn
          Defines places where the IppCommand will be displayed.
static class IppCommand.Select
          For commands added to implicit IppList Possible valued of a field that indicates whether the command is selected by default or not.
static class IppCommand.Type
          Available types of the IppCommand.
 
Field Summary
private  int auto
          This command will be executed automatically after provided number of seconds, or will not be executed automatically if zero or a negative number is provided.
private  IppCommand.DisplayOn displayOn
          Value from IppCommand.DisplayOn.
private  boolean isDefault
          This command will be the default command in the context menu.
private  boolean isSelected
          Useful only if the command is added to a implicit list.
private  java.lang.String key
          Useless unless command is of type SELECT, then it is a key from key-value pair, which is sent to the remote server.
private  int priority
          Nonnegative integer indicating position of this IppCommand on the list of commands.
private  IppCommand.Type type
          Value from IppCommand.Type.
private  java.lang.String value
          Useless unless command is of type SELECT, then it is the value from key-value pair, which is sent to the remote server.
 
Constructor Summary
IppCommand(IppCommand.Type type, IppCommand.DisplayOn displayOn)
          Creates new IppCommand, with label that is guessed according to the type argument.
IppCommand(java.lang.String label, int screenID, IppCommand.DisplayOn displayOn)
          Creates new IppCommand of type SCREEN.
IppCommand(java.lang.String label, IppCommand.Type type, int screenID, int priority, int auto, java.lang.String key, java.lang.String value, IppCommand.DisplayOn displayOn, boolean isSelected, boolean isDefault)
          Creates new IppCommand with all possible fields available to set.
IppCommand(java.lang.String label, IppCommand.Type type, java.lang.String key, java.lang.String value, IppCommand.DisplayOn displayOn, boolean isSelected)
          Creates new IppCommand with some fields set to default values.
IppCommand(java.lang.String label, java.lang.String key, java.lang.String value, IppCommand.DisplayOn displayOn)
          Creates new IppCommand of type SELECT.
 
Method Summary
protected  java.lang.StringBuffer attributesToXmlString()
          Should be overridden by classes that have some attributes.
 
Methods inherited from class pl.mbdev.openstage.Xml
add, add, addAndReturn, attributeToXml, firstAttributesToXmlString, getContents, getLogicalRoot, getParent, getSubNode, getSubNodeIndex, getSubNodes, getXmlHeader, isEmpty, logicalAdd, sendTo, setContents, setParent, subObjectsCount, subObjectsToXmlString, toXmlString, wrapWithIppItem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

private IppCommand.Type type
Value from IppCommand.Type.


priority

private int priority
Nonnegative integer indicating position of this IppCommand on the list of commands. If negative, not used.


auto

private int auto
This command will be executed automatically after provided number of seconds, or will not be executed automatically if zero or a negative number is provided.


key

private java.lang.String key
Useless unless command is of type SELECT, then it is a key from key-value pair, which is sent to the remote server.


value

private java.lang.String value
Useless unless command is of type SELECT, then it is the value from key-value pair, which is sent to the remote server.


displayOn

private IppCommand.DisplayOn displayOn
Value from IppCommand.DisplayOn.


isSelected

private boolean isSelected
Useful only if the command is added to a implicit list.


isDefault

private boolean isDefault
This command will be the default command in the context menu.

Constructor Detail

IppCommand

public IppCommand(IppCommand.Type type,
                  IppCommand.DisplayOn displayOn)
Creates new IppCommand, with label that is guessed according to the type argument. This constructor works only for the following command types: EXIT, BACK and CANCEL.

type -> label:
EXIT -> "Exit", BACK -> "Back", CANCEL -> "Cancel"

Parameters:
type - value from IppCommand.Type
displayOn - value from IppCommand.DisplayOn

IppCommand

public IppCommand(java.lang.String label,
                  int screenID,
                  IppCommand.DisplayOn displayOn)
Creates new IppCommand of type SCREEN.

Parameters:
label - label of this command
screenID - ID of the screen
displayOn - value from IppCommand.DisplayOn

IppCommand

public IppCommand(java.lang.String label,
                  java.lang.String key,
                  java.lang.String value,
                  IppCommand.DisplayOn displayOn)
Creates new IppCommand of type SELECT.

Parameters:
label - label of this command
key - the key from key-value pair, which is sent to the remote server
value - the value from key-value pair, which is sent to the remote server
displayOn - value from IppCommand.DisplayOn

IppCommand

public IppCommand(java.lang.String label,
                  IppCommand.Type type,
                  java.lang.String key,
                  java.lang.String value,
                  IppCommand.DisplayOn displayOn,
                  boolean isSelected)
Creates new IppCommand with some fields set to default values.

Parameters:
label - label of this command
type - value from IppCommand.Type, if you want to set it to SCREEN, please use a constructor that allows you to also define screen ID
key - useless unless command is of type SELECT, then it is a key from key-value pair, which is sent to the remote server
value - useless unless command is of type SELECT, then it is the value from key-value pair, which is sent to the remote server
displayOn - value from IppCommand.DisplayOn
isSelected - useful only if the command is added to a implicit list

IppCommand

public IppCommand(java.lang.String label,
                  IppCommand.Type type,
                  int screenID,
                  int priority,
                  int auto,
                  java.lang.String key,
                  java.lang.String value,
                  IppCommand.DisplayOn displayOn,
                  boolean isSelected,
                  boolean isDefault)
Creates new IppCommand with all possible fields available to set.

Parameters:
label - label of this command
type - value from IppCommand.Type
screenID - ID of the screen, used when the command is of type SCREEN
priority - priority of the command, may change order of appearance to other than "first added, first displayed"
auto - this command will be executed automatically after provided number of seconds, or will not be executed automatically if zero or a negative number is provided
key - useless unless command is of type SELECT, then it is a key from key-value pair, which is sent to the remote server
value - useless unless command is of type SELECT, then it is the value from key-value pair, which is sent to the remote server
displayOn - value from IppCommand.DisplayOn
isSelected - useful only if the command is added to a implicit list
isDefault - this command will be the default command in the context menu
Method Detail

attributesToXmlString

protected java.lang.StringBuffer attributesToXmlString()
Description copied from class: Xml
Should be overridden by classes that have some attributes.

Overrides:
attributesToXmlString in class Xml
Returns:
XML-text containing all attributes of the object