thinkmap.datasource.stream
Class BinaryStreamWriter

java.lang.Object
  extended by thinkmap.datasource.stream.StreamWriter
      extended by thinkmap.datasource.stream.BinaryStreamWriter
All Implemented Interfaces:
IEntityHandler

public class BinaryStreamWriter
extends StreamWriter
implements IEntityHandler

This class implements the writing portion of the binary stream format for Thinkmap.

Version:
$Revision: 1.3 $

Field Summary
 
Fields inherited from class thinkmap.datasource.stream.StreamWriter
error, factory, format
 
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
protected BinaryStreamWriter(IStreamFormat sf, IStreamFactory isf)
           
 
Method Summary
 void _beginMessage(int messageType)
           
 void _endMessage()
           
 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 beginRelatedEntity(String relation, boolean reciprical)
          A related entity.
 void beginRelatedList(byte flag)
          Begin the list of related entities.
 void endEntity()
          End an entity.
 void endEntityMD()
          End entity metadata.
 void endId()
          End an entity ID.
 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.
 OutputStream getStream()
          Get the OutputStream this writes to.
 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.
protected  void writeArray(Object obj)
           
protected  void writeHeader()
           
protected  void writeValue(Object obj)
           
 
Methods inherited from class thinkmap.datasource.stream.StreamWriter
beginMessage, endMessage, getError, getStreamFactory, getStreamFormat, setError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface thinkmap.datasource.IEntityHandler
beginMessage, endMessage
 

Constructor Detail

BinaryStreamWriter

protected BinaryStreamWriter(IStreamFormat sf,
                             IStreamFactory isf)
Method Detail

getStream

public OutputStream getStream()
Description copied from class: StreamWriter
Get the OutputStream this writes to.

Overrides:
getStream in class StreamWriter
Returns:
output stream

_beginMessage

public void _beginMessage(int messageType)
Specified by:
_beginMessage in class StreamWriter

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

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.

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.

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.

endId

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

Specified by:
endId in interface IEntityHandler

beginRelatedList

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

Specified by:
beginRelatedList in interface IEntityHandler
Parameters:
flag - 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()
Specified by:
_endMessage in class StreamWriter

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.

writeHeader

protected void writeHeader()
                    throws IOException
Throws:
IOException

writeValue

protected void writeValue(Object obj)
                   throws IOException
Throws:
IOException

writeArray

protected void writeArray(Object obj)
                   throws IOException
Throws:
IOException


Copyright © 2013 Thinkmap, Inc. All Rights Reserved.