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

## org.crosswire.jsword.book.sword
Class DataEntry

    java.lang.Object
      org.crosswire.jsword.book.sword.DataEntry

    public class DataEntry

extends Object

Data entry represents an entry in a Data file. The entry consists of a key and an optional payload.

The payload may be:

- the content, that is raw text
- an alias (@LINK) for another entry
- a block locator

Author:
  DM Smith
See Also:
  `The GNU Lesser General Public License for details.`

Field Summary
`private String` | `charset` The character set of the data entry.
`private byte[]` | `data` The data entry as it comes out of the data file.
`private String` | `key` The key in the data entry.
`private int` | `keyEnd` The index of the separator between the key and the payload.
`private int` | `linkEnd` The index of the separator between the link and the payload.
`private static org.slf4j.Logger` | `log` The log stream
`private String` | `name` A diagnostic name.
`private static byte` | `SEPARATOR` Used to separate the key name from the key value Note: it may be \r\n or just \n, so only need \n.

Constructor Summary
`DataEntry(String name, byte[] data, String charset)` Construct a data entry.

Method Summary
`void` | `cipher(byte[] cipherKey, int offset)` Decipher/Encipher the data in place, if there is a cipher key.
`DataIndex` | `getBlockIndex()` Get the block start and entry position.
`String` | `getCharset()` Get the charset in which the data is encoded.
`String` | `getKey()` Get the key from this DataEntry.
`private int` | `getLinkEnd()` Get the position of the second \n in the data.
`String` | `getLinkTarget()` Get the link target for this entry.
`String` | `getName()` Get the name, that is, the diagnostic label, for this DataEntry.
`String` | `getRawText(byte[] cipherKey)` Get the raw text from this entry.
`boolean` | `isLinkEntry()` Determine whether this entry is an alias for another.

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

Field Detail

### SEPARATOR

    private static final byte SEPARATOR

  Used to separate the key name from the key value Note: it may be \r\n or just \n, so only need \n. ^M=CR=13=0x0d=\r ^J=LF=10=0x0a=\n

  See Also:
    Constant Field Values

### name

    private String name

  A diagnostic name.

### data

    private byte[] data

  The data entry as it comes out of the data file.

### charset

    private String charset

  The character set of the data entry.

### key

    private String key

  The key in the data entry.

### keyEnd

    private int keyEnd

  The index of the separator between the key and the payload.

### linkEnd

    private int linkEnd

  The index of the separator between the link and the payload.

### log

    private static final org.slf4j.Logger log

  The log stream

Constructor Detail

### DataEntry

    public DataEntry(String name,
                     byte[] data,
                     String charset)

  Construct a data entry.

  Parameters:
    `name` - A name used for diagnostics.
    `data` - The data for this entry.
    `charset` - The character encoding for this entry.

Method Detail

### getName

    public String getName()

  Get the name, that is, the diagnostic label, for this DataEntry.

  Returns:
    the diagnostic name.

### getCharset

    public String getCharset()

  Get the charset in which the data is encoded.

  Returns:
    this entry's charset

### getKey

    public String getKey()

  Get the key from this DataEntry.

  Returns:
    the key

### isLinkEntry

    public boolean isLinkEntry()

  Determine whether this entry is an alias for another.

  Returns:
    whether this is an alias entry

### getLinkTarget

    public String getLinkTarget()

  Get the link target for this entry. One entry can be chained to another. If the entry is not linked then it is an error to call this method.

  Returns:
    the key to look up
  See Also:
    `isLinkEntry()`

### getRawText

    public String getRawText(byte[] cipherKey)

  Get the raw text from this entry.

  Parameters:
    `cipherKey` - the key, if any, to (un)lock the text
  Returns:
    the raw text

### getBlockIndex

    public DataIndex getBlockIndex()

  Get the block start and entry position.

  Returns:
    the index of the block

### getLinkEnd

    private int getLinkEnd()

  Get the position of the second \n in the data. This represents the end of the link and the start of the rest of the data.

  Returns:
    the end of the link or -1 if not found.

### cipher

    public void cipher(byte[] cipherKey,
                       int offset)

  Decipher/Encipher the data in place, if there is a cipher key.

  Parameters:
    `cipherKey` - the key to the cipher
    `offset` - the start of the cipher data

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