com.google.bitcoin.core
Class ListMessage

java.lang.Object
  extended by com.google.bitcoin.core.Message
      extended by com.google.bitcoin.core.ListMessage
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
GetDataMessage, InventoryMessage

public abstract class ListMessage
extends Message

Abstract superclass of classes with list based payload, ie InventoryMessage and GetDataMessage.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.bitcoin.core.Message
Message.LazyParseException
 
Field Summary
protected  List<InventoryItem> items
           
static long MAX_INVENTORY_ITEMS
           
 
Fields inherited from class com.google.bitcoin.core.Message
bytes, checksum, cursor, length, MAX_SIZE, offset, params, parsed, parseLazy, parseRetain, protocolVersion, recached, UNKNOWN_LENGTH
 
Constructor Summary
ListMessage(NetworkParameters params)
           
ListMessage(NetworkParameters params, byte[] bytes)
           
ListMessage(NetworkParameters params, byte[] msg, boolean parseLazy, boolean parseRetain, int length)
           
 
Method Summary
 void addItem(InventoryItem item)
           
 void bitcoinSerializeToStream(OutputStream stream)
          Serializes this message to the provided stream.
 boolean equals(Object o)
           
 List<InventoryItem> getItems()
           
 void parse()
           
protected  void parseLite()
          Perform the most minimal parse possible to calculate the length of the message.
 void removeItem(int index)
           
 
Methods inherited from class com.google.bitcoin.core.Message
adjustLength, bitcoinSerialize, bitcoinSerialize, ensureParsed, getHash, getMessageSize, getParams, isCached, isParsed, isRecached, maybeParse, unCache, unsafeBitcoinSerialize
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

items

protected List<InventoryItem> items

MAX_INVENTORY_ITEMS

public static final long MAX_INVENTORY_ITEMS
See Also:
Constant Field Values
Constructor Detail

ListMessage

public ListMessage(NetworkParameters params,
                   byte[] bytes)
            throws ProtocolException
Throws:
ProtocolException

ListMessage

public ListMessage(NetworkParameters params,
                   byte[] msg,
                   boolean parseLazy,
                   boolean parseRetain,
                   int length)
            throws ProtocolException
Throws:
ProtocolException

ListMessage

public ListMessage(NetworkParameters params)
Method Detail

getItems

public List<InventoryItem> getItems()

addItem

public void addItem(InventoryItem item)

removeItem

public void removeItem(int index)

parseLite

protected void parseLite()
                  throws ProtocolException
Description copied from class: Message
Perform the most minimal parse possible to calculate the length of the message. This is only required for subclasses of ChildClass as root level messages will have their length passed into the constructor.

Implementations should adhere to the following contract: If parseLazy = true the 'length' field must be set before returning. If parseLazy = false the length field must be set either within the parseLite() method OR the parse() method. The overriding requirement is that length must be set to non UNKNOWN_MESSAGE value by the time the constructor exits.

Specified by:
parseLite in class Message
Throws:
ProtocolException

parse

public void parse()
           throws ProtocolException
Throws:
ProtocolException

bitcoinSerializeToStream

public void bitcoinSerializeToStream(OutputStream stream)
                              throws IOException
Description copied from class: Message
Serializes this message to the provided stream. If you just want the raw bytes use bitcoinSerialize().

Throws:
IOException

equals

public boolean equals(Object o)
Overrides:
equals in class Object


Copyright © 2014. All rights reserved.