thinkmap.datasource.util
Class Message

java.lang.Object
  extended by thinkmap.datasource.util.Message
All Implemented Interfaces:
IEntityHandler

public class Message
extends Object
implements IEntityHandler

Message is an IEntityHandler that stores its input for later retrieval.

Version:
$Id: Message.java,v 1.19 2010/07/22 19:01:52 mdeloria Exp $

Field Summary
 
Fields inherited from interface thinkmap.datasource.IEntityHandler
ADD_REQUEST, ATTR_CACHE_REVISION, DELETE_REQUEST, EDGE, ENTITY_REQUEST, FLAG_NO_CACHE, FLAGS, FLAGS_DEFAULT, ID_REQUEST, LIST_ENTITIES_REQUEST, METADATA_REQUEST, NODE, NULL_REQUEST, QUERY_MAX_RESULTS, QUERY_STARTING_RESULT_NUMBER, QUERY_STRING, RELATED_REQUEST, RESERVED_ID_MAX, SINK, SOURCE, TOTAL_RESULTS, UNLIMITED_RESULTS, UPDATE_REQUEST
 
Constructor Summary
Message()
           
 
Method Summary
 void addEntity(SourceEntity entity)
          Add an Entity
 void addEntityType(EntityType entityType)
          Add an EntityType
 void attribute(String name, Object value)
          Send a message attribute.
 void beginEntity()
          Begin an entity.
 void beginEntityMD(String parentType)
          Begin entity metadata.
 void beginId(String type)
          Begin an entity ID.
 void beginMessage(int type)
          Begin a message.
 void beginRelatedEntity(String relation, boolean reciprical)
          A related entity.
 void beginRelatedList(byte i)
          Begin the list of related entities.
protected  void complainClosed()
          Someone tried to modify the message after endMessage() was called.
 void endEntity()
          End an entity.
 void endEntityMD()
          End entity metadata.
 void endId()
          End an entity ID.
 void endMessage()
          End a message.
 void endRelatedEntity()
          End a related entity.
 void endRelatedList()
          Mark the end of a related list.
 void error(Exception e)
          Tell the entity source about an error.
 void fatalError(Exception e)
          A fatal error occured.
 Object getAttribute(String name)
          Get the named attributes.
 Enumeration getAttributeNames()
          Get the names of all attributes.
 Enumeration getEntities()
           
 SourceEntity getEntity(int i)
          Get the Entity at the specified index.
 int getEntityCount()
          Get the number of entities in this message.
 EntityId getEntityId(int i)
           
 int getEntityIdCount()
           
 EntityType getEntityType(int i)
           
 int getEntityTypeCount()
           
 ExceptionChain getErrors()
           
 ExceptionChain getFatalErrors()
           
 ExceptionChain getNonFatalErrors()
           
 int getType()
          Get the type of message.
 void idKey(Object value)
          Send an id key.
 void idKeyMD(Class type)
          Describe an entity id's key.
 void property(String name, Object value)
          Send an entity's property.
 void propertyMD(String name, Class type)
          Describe an entity's property.
 void removeEntity(SourceEntity entity)
          Remove an Entity
 void removeEntityType(EntityType entityType)
          Remove an EntityType
 void replaceEntity(int i, SourceEntity replacement)
          Replace an entity at the specified index
static void setCompatibilityMode(boolean b)
          This static method turns on and off backwards compatibility mode.
 void writeTo(IEntityHandler handler)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Message

public Message()
Method Detail

getType

public int getType()
Get the type of message.

Returns:
the type of message, ie ENTITY_REQUEST

getAttribute

public Object getAttribute(String name)
Get the named attributes.

Parameters:
name - A request attribute name.
Returns:
The request attribute value.

getAttributeNames

public Enumeration getAttributeNames()
Get the names of all attributes.

Returns:
An enumeration of all request attribute names in this message.

getEntity

public SourceEntity getEntity(int i)
Get the Entity at the specified index.

Parameters:
i - Index of the entity.
Returns:
The given entity.

getEntityCount

public int getEntityCount()
Get the number of entities in this message.

Returns:
Number of entities in this message.

getEntityIdCount

public int getEntityIdCount()

getEntityId

public EntityId getEntityId(int i)

getEntityTypeCount

public int getEntityTypeCount()

getEntityType

public EntityType getEntityType(int i)

getEntities

public Enumeration getEntities()

getErrors

public ExceptionChain getErrors()

getFatalErrors

public ExceptionChain getFatalErrors()

getNonFatalErrors

public ExceptionChain getNonFatalErrors()

beginMessage

public void beginMessage(int type)
Description copied from interface: IEntityHandler
Begin a message.

Specified by:
beginMessage in interface IEntityHandler
Parameters:
type - one of the request types below, eg RELATED_REQUEST

attribute

public void attribute(String name,
                      Object value)
Description copied from interface: IEntityHandler
Send a message attribute. See the grammar above; this is sent only at the top level of a message, before entities (if any) are sent.

Specified by:
attribute in interface IEntityHandler
Parameters:
name - The attribute's name
value - The attribute's value

beginEntity

public void beginEntity()
Description copied from interface: IEntityHandler
Begin an entity.

Specified by:
beginEntity in interface IEntityHandler

endEntity

public void endEntity()
Description copied from interface: IEntityHandler
End an entity.

Specified by:
endEntity in interface IEntityHandler

beginEntityMD

public void beginEntityMD(String parentType)
Description copied from interface: IEntityHandler
Begin entity metadata.

Specified by:
beginEntityMD in interface IEntityHandler
Parameters:
parentType - The parent type of this entity, eg NODE or EDGE.

endEntityMD

public void endEntityMD()
Description copied from interface: IEntityHandler
End entity metadata.

Specified by:
endEntityMD in interface IEntityHandler

idKeyMD

public void idKeyMD(Class type)
Description copied from interface: IEntityHandler
Describe an entity id's key.

Specified by:
idKeyMD in interface IEntityHandler
Parameters:
type - Describe an entity ID's key.

idKey

public void idKey(Object value)
Description copied from interface: IEntityHandler
Send an id key.

Specified by:
idKey in interface IEntityHandler
Parameters:
value - A key in an entity ID.

property

public void property(String name,
                     Object value)
Description copied from interface: IEntityHandler
Send an entity's property. Primary data-transmission point.

Specified by:
property in interface IEntityHandler

propertyMD

public void propertyMD(String name,
                       Class type)
Description copied from interface: IEntityHandler
Describe an entity's property.

Specified by:
propertyMD in interface IEntityHandler

beginId

public void beginId(String type)
Description copied from interface: IEntityHandler
Begin an entity ID.

Specified by:
beginId in interface IEntityHandler
Parameters:
type - The type of entity being sent.

endId

public void endId()
Description copied from interface: IEntityHandler
End an entity ID.

Specified by:
endId in interface IEntityHandler

beginRelatedList

public void beginRelatedList(byte i)
Description copied from interface: IEntityHandler
Begin the list of related entities.

Specified by:
beginRelatedList in interface IEntityHandler
Parameters:
i - one of: FLAGS_DEFAULT, FLAG_NO_CACHE

endRelatedList

public void endRelatedList()
Description copied from interface: IEntityHandler
Mark the end of a related list.

Specified by:
endRelatedList in interface IEntityHandler

beginRelatedEntity

public void beginRelatedEntity(String relation,
                               boolean reciprical)
Description copied from interface: IEntityHandler
A related entity. Generally only EDGEs have related entities, and they have two of them (SOURCE and SINK).

Specified by:
beginRelatedEntity in interface IEntityHandler
Parameters:
relation - either SOURCE or SINK.
reciprical - should this connection go both ways? SOURCE should always be reciprocal, and SINK should be reciprocal for a bidirectional edge.

endRelatedEntity

public void endRelatedEntity()
Description copied from interface: IEntityHandler
End a related entity.

Specified by:
endRelatedEntity in interface IEntityHandler

endMessage

public void endMessage()
Description copied from interface: IEntityHandler
End a message.

Specified by:
endMessage in interface IEntityHandler

error

public void error(Exception e)
Description copied from interface: IEntityHandler
Tell the entity source about an error. The message must still be well- formed; this is not an abort.

Specified by:
error in interface IEntityHandler
Parameters:
e - The cause.

fatalError

public void fatalError(Exception e)
Description copied from interface: IEntityHandler
A fatal error occured. This is an abort, so don't expect the message to be properly finished.

Specified by:
fatalError in interface IEntityHandler
Parameters:
e - The cause.

writeTo

public void writeTo(IEntityHandler handler)

setCompatibilityMode

public static void setCompatibilityMode(boolean b)
This static method turns on and off backwards compatibility mode. When set to true, messages from old datasources will be converted to work with the new format.

Parameters:
b - false to turn off compatibility mode.

complainClosed

protected void complainClosed()
Someone tried to modify the message after endMessage() was called. Squeal like a pig.


addEntityType

public void addEntityType(EntityType entityType)
Add an EntityType


removeEntityType

public void removeEntityType(EntityType entityType)
Remove an EntityType


addEntity

public void addEntity(SourceEntity entity)
Add an Entity


removeEntity

public void removeEntity(SourceEntity entity)
Remove an Entity


replaceEntity

public void replaceEntity(int i,
                          SourceEntity replacement)
Replace an entity at the specified index



Copyright © 2013 Thinkmap, Inc. All Rights Reserved.