Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## network
Class FragmentManager

    java.lang.Object
      network.FragmentManager

    public class FragmentManager

extends java.lang.Object

This class provides capability to split messages to be sent into smaller fragments that can be reassebled at remote end. User is allowed to specify maximum size of fragments. Every fragment is prepended string that uniquely identifies its position in sequence of fragments, so original message can be assebled correctly. This string also contains value, which should distinguish fragment from fragments belonging to other message. Format of string used is: "fragment: xxxxxxxxxx:yyyyyyyyyy\n" where x is sequence number and y is unique identifier. "\n" represents new line.

Constructor Summary
`FragmentManager()` Creates new fragment manager.
`FragmentManager(int fragmentSize)` Creates new fragment manager splitting large messages into fragments of maximum size entered by user.

Method Summary
`byte[][]` | `createFragments(byte[] message)` Given array of bytes representing single message, this function splits it into several messages and prepends header to each of them.
`byte[][]` | `mergeFragments(byte[][] fragments)` Given array of fragments received, this function merges them into original messages.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### FragmentManager

    public FragmentManager()

  Creates new fragment manager.

### FragmentManager

    public FragmentManager(int fragmentSize)

  Creates new fragment manager splitting large messages into fragments of maximum size entered by user. Every fragment has header prepended, so actual size of fragment is larger by few bytes.

  Parameters:
    `fragmentSize` - maximum size of fragment

Method Detail

### createFragments

    public byte[][] createFragments(byte[] message)

  Given array of bytes representing single message, this function splits it into several messages and prepends header to each of them. This fragments can be send over network to remote end where they will be reassembled.

  Parameters:
    `message` - byte array of message
  Returns:
    array of message fragments

### mergeFragments

    public byte[][] mergeFragments(byte[][] fragments)

  Given array of fragments received, this function merges them into original messages. If fragments of several messages are passed to function, they are sorted, so they don't mix. Array of reassembled messages is returned.

  Parameters:
    `fragments` - array of fragments to be reassebled
  Returns:
    assembled messages

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD