Bees v0.5.0 API

bees.core
Class PairChain

java.lang.Object
  |
  +--bees.core.PairChain
All Implemented Interfaces:
java.lang.Cloneable

public final class PairChain
extends java.lang.Object
implements java.lang.Cloneable

A PairChain manages an ordered collection of Pair objects. PairChains are used to carry untyped byte arrays between nodes in the system.

See Also:
Pair

Constructor Summary
PairChain()
          Construct an empty PairChain.
PairChain(Pair[] pairs)
          Construct a PairChain with the given values.
 
Method Summary
 PairChain add(Pair pair)
           
 PairChain add(java.lang.String tag, byte[] value)
           
 PairChain add(java.lang.String tag, java.lang.String value)
           
 java.lang.Object clone()
           
 Pair expect(java.lang.String tag)
           
 Pair expect(java.lang.String tag, int instance)
           
 PairChain from(Pair[] pairs)
           
 PairChain from(PairChain pc)
           
 Pair get(java.lang.String tag)
           
 Pair get(java.lang.String tag, int instance)
           
static PairChain instantiate(byte[] pc)
           
 void marshal(XdrByteArray xdr)
           
 int marshalledLength()
           
 void remove(java.lang.String tag)
           
 void remove(java.lang.String tag, int instance)
           
 int size()
           
 Pair[] toArray()
           
 byte[] toBytes()
           
 java.lang.String toString()
           
 void unmarshal(XdrByteArray xdr)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PairChain

public PairChain(Pair[] pairs)
Construct a PairChain with the given values.
Parameters:
pairs - An array of Pairs to add to the new chain.

PairChain

public PairChain()
Construct an empty PairChain.
Method Detail

from

public PairChain from(Pair[] pairs)
Parameters:
pairs - The pairs to add to this chain.
Returns:
this

from

public PairChain from(PairChain pc)
Parameters:
pc - The pairs to add to this chain.
Returns:
this

add

public PairChain add(Pair pair)
Parameters:
pair - A pair to add to this chain.

add

public PairChain add(java.lang.String tag,
                     java.lang.String value)
Parameters:
tag - The name part of the pair.
value - The value part of the pair.
Returns:
this

add

public PairChain add(java.lang.String tag,
                     byte[] value)
Parameters:
tag - The name part of the pair.
value - The value part of the pair.
Returns:
this

get

public Pair get(java.lang.String tag,
                int instance)
Parameters:
tag - The tag to look for.
instance - The instance of "tag" to look for.
Returns:
The matching Pair or NULL.

get

public Pair get(java.lang.String tag)
Parameters:
tag - The tag to look for.
Returns:
The matching Pair or NULL.

expect

public Pair expect(java.lang.String tag,
                   int instance)
            throws MissingPairException

expect

public Pair expect(java.lang.String tag)
            throws MissingPairException

remove

public void remove(java.lang.String tag,
                   int instance)
Parameters:
tag - The tag to remove.
instance - The instance of "tag" to remove.

remove

public void remove(java.lang.String tag)
Parameters:
tag - The tag to remove.

size

public int size()
Returns:
The number of Pairs in this chain.

toArray

public Pair[] toArray()
Returns:
An array containing all of this chain's Pairs.

marshalledLength

public int marshalledLength()
Returns:
The number of bytes needed to flatten this chain.

marshal

public void marshal(XdrByteArray xdr)
Parameters:
xdr - The object to marshal this chain to.

unmarshal

public void unmarshal(XdrByteArray xdr)
Parameters:
xdr - The object to unmarshal this chain from.

toBytes

public byte[] toBytes()
Returns:
A flattened version of this chain.

instantiate

public static PairChain instantiate(byte[] pc)
Parameters:
pc - A flattened PairChain object.
Returns:
A new PairChain object initialized with the values in "pc".

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object
See Also:
Object.clone()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

Bees v0.5.0 API

This documentation is Copyright (C) 2002 The University of Utah. All Rights Reserved. See the individual source files for distribution terms.
Documentation, software, and mailing lists for Bees v0.5.0 can be found at the Janos Project: http://www.cs.utah.edu/flux/janos/