public class

MessageProcessor

extends Object
java.lang.Object
   ↳ com.esri.core.symbol.advanced.MessageProcessor

Class Overview

A MessageProcessor allows you to process a Message from external resources. For example, display a military symbol by passing a message to a MessageProcesor. Each MessageProcessor comes with a SymbolDictionary.DictionaryType, which dictates message format understood by MessageProcessor, e.g. a message needs to have one or more properties from 'wkid', ''sic', '_Type', '_Action' and '_Control_Points' in order to be successfully processed by a MessageProcessor. Each dictionary type is backed by a resource bundle which includes dictionary data file and message type files. The path to the resource files defaults to

 [external-resource-dir]/ArcGIS/SymbolDictionary
In the default location your device should have the following directory structure for Mil2525C:
     + mnt
         + sdcard
             + ArcGIS
                 + SymbolDictionary
                     + MessageTypes
                         -  Chemlight.json
                         -  PositionReport.json
                         - SpotReport.json
                    - Mil2525C.dat
 
You can specify an alternative path using the overloaded constructor:
 MessageProcessor(DictionaryType.APP6B , mGroupLayer, symbolDictionaryPath);
 

MessageProcessor currently does not support MIL-2525C and APP 6B dictionaries installed in the default location together. You must use the overloaded constructor for one of the symbol dictionaries to support both resources on a single device.

A MessageProcessor is bound to a MessageGroupLayer, which is used to display, update and remove MultiLayerSymbol associated with the message. The MessageGroupLayer has to be added into MapView, otherwise MessageProcessor will fail to process the message.

Creates a MessageProcessor object:

     MapView map = new MapView(this); 
     try {   
       MessageGroupLayer mgroupLayer= new MessageGroupLayer(DictionaryType.MIL2525C);
       map.addLayer(mgroupLayer);
       MessageProcessor processor = mgroupLayer.getMessageProcessor();
     catch(FileNotFoundException ex) {
        ex.printStackTrace();
     }
   
Creates a Message object, then process it:
     
      Message message = new Message();
      UUID uuid = UUID.randomUUID();
      message.setID(uuid.toString());
      message.setProperty("_Type", "position_report");
      message.setProperty("_Action", "update");
      message.setProperty("_Control_Points", "7846271.25206,4091857.83028");
      message.setProperty("sic", "SFGPUCRRL--E---");
      message.setProperty("_WKID", "3857");
      message.setProperty("UniqueDesignation", "Mad dog");
      processor.processMessage(message);
   

Summary

Fields
protected static String defaultDictionaryFolder
Public Constructors
MessageProcessor(SymbolDictionary.DictionaryType type, MessageGroupLayer mgroupLayer)
Constructs a MessageProcesor object using specified SymbolDictionary.DictionaryType and GroupLayer.
MessageProcessor(SymbolDictionary.DictionaryType type, MessageGroupLayer mgroupLayer, String symbolDictionaryPath)
Constructs a MessageProcesor object using specified SymbolDictionary.DictionaryType, MessageGroupLayer and resource bundle path.
MessageProcessor(SymbolDictionary.DictionaryType type, MessageGroupLayer mgroupLayer, String symbolDictionaryPath, double symbolScaleFactor)
Constructs a MessageProcesor object using specified SymbolDictionary.DictionaryType, MessageGroupLayer, resource bundle path and symbol scale factor.
Public Methods
Message createMessageFrom(String messageID)
Creates a Message from an existing message ID.
Message createMessageFrom(Graphic graphic)
Creates a Message from a Graphic object.
SpatialReference getDefaultMessageSpatialReference()
Gets the default message spatial reference.
SymbolDictionary.DictionaryType getDictionaryType()
Gets the dictionary type.
Graphic getGraphic(String messageID)
Retrieves the graphic which originates from the message with specified id.
String[] getMessageTypesSupported()
Gets the message types supported.
SymbolDictionary getSymbolDictionary()
Gets the SymbolDictionary instance.
boolean processMessage(Message message)
Processes the message which conforms to the format dictated by the dictionary type.
void setDefaultMessageSpatialReference(SpatialReference sr)
Sets the default message spatial reference.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

protected static String defaultDictionaryFolder

Public Constructors

public MessageProcessor (SymbolDictionary.DictionaryType type, MessageGroupLayer mgroupLayer)

Constructs a MessageProcesor object using specified SymbolDictionary.DictionaryType and GroupLayer. Default path(/sdcard/ArcGIS/SymbolDictionary) to the resource bundle is used

Parameters
type SymbolDictionary.DictionaryType: processor type.
mgroupLayer MessageGroupLayer: MessageGroupLayer which displays symbols.
Throws
FileNotFoundException the file not found exception

public MessageProcessor (SymbolDictionary.DictionaryType type, MessageGroupLayer mgroupLayer, String symbolDictionaryPath)

Constructs a MessageProcesor object using specified SymbolDictionary.DictionaryType, MessageGroupLayer and resource bundle path.

Parameters
type SymbolDictionary.DictionaryType: processor type.
mgroupLayer MessageGroupLayer: MessageGroupLayer which displays symbols
symbolDictionaryPath String: path to the symbol dictionary source bundle directory.
Throws
FileNotFoundException the file not found exception

public MessageProcessor (SymbolDictionary.DictionaryType type, MessageGroupLayer mgroupLayer, String symbolDictionaryPath, double symbolScaleFactor)

Constructs a MessageProcesor object using specified SymbolDictionary.DictionaryType, MessageGroupLayer, resource bundle path and symbol scale factor.

Parameters
type SymbolDictionary.DictionaryType: processor type.
mgroupLayer MessageGroupLayer: MessageGroupLayer which displays symbols
symbolDictionaryPath String: path to the symbol dictionary source bundle directory.
symbolScaleFactor double: scale factor to apply to symbols
Throws
FileNotFoundException the file not found exception

Public Methods

public Message createMessageFrom (String messageID)

Creates a Message from an existing message ID. The message ID is used previously to create or update a graphic. The returned message has the same attributes as the previous message with specified message ID except that '_Action' property is empty.

Parameters
messageID String: message ID
Returns
Message a Message object with attributes from previous message with same message id.

public Message createMessageFrom (Graphic graphic)

Creates a Message from a Graphic object. The message gets populated with properties understood by the message processor. If the specified graphic is created from previous message, the returned message is the same as the previous one except that '_Action' property is empty.

Parameters
graphic Graphic: a Graphic object.
Returns
Message a Message object populated with attributes/geometry from the specified graphic.

public SpatialReference getDefaultMessageSpatialReference ()

Gets the default message spatial reference. Message spatial reference is used by control points inside the message. Usually a WKID or WKT property indicates the message spatial reference. If WKID or WKT property is omitted, this default message spatial reference is treated as the message spatial reference. If default message spatial reference is not set, it will be the same as the map's spatial reference.

Returns
SpatialReference the default spatial reference.

public SymbolDictionary.DictionaryType getDictionaryType ()

Gets the dictionary type. The dictionary type is associated with a resource bundle, which includes dictionary data file and message type configuration files. Only Mil2525C dictionary type is available for now.

Returns
SymbolDictionary.DictionaryType the mType the processor type.

public Graphic getGraphic (String messageID)

Retrieves the graphic which originates from the message with specified id.

Parameters
messageID String: message id.
Returns
Graphic a Graphic object populated with the properties of message of specified id.

public String[] getMessageTypesSupported ()

Gets the message types supported. A message requires a type property which describes how message is processed. The message type is defined in the resource bundle as a configuration file in JSON format. A message type contains properties like type name, layer name and renderer.

a sample message type file:

 {
 "type": "position_report",
 "layerName": "position_reports",
 "renderer":
 {
 "type"           : "dictionary",
 "description"    : "postion report",
 "dictionaryType" : "2525C",
 "field"          : "sic"
 }
 }
 
 

Returns
String[] the message types supported

public SymbolDictionary getSymbolDictionary ()

Gets the SymbolDictionary instance.

Returns
SymbolDictionary symbol dictionary.

public boolean processMessage (Message message)

Processes the message which conforms to the format dictated by the dictionary type. MessageProcessor uses message properties to create, update, delete or otherwise change the state of the graphic(geometry and attributes). MessageProcessor determines which message properties should be persisted on graphic as attributes.

Parameters
message Message: A Message object
Returns
boolean true if the message is processed successfully.

public void setDefaultMessageSpatialReference (SpatialReference sr)

Sets the default message spatial reference. Message spatial reference is used by control points inside the message. Usually a WKID or WKT property indicates the message spatial reference. If WKID or WKT property is omitted, this default message spatial reference is treated as the message spatial reference. If default message spatial reference is not set, it will be the same as the map's spatial reference.

Parameters
sr SpatialReference: the default message spatial reference to set.