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.archive.crawler.writer
Class MirrorWriterProcessor.LumpyString

    java.lang.Object
      org.archive.crawler.writer.MirrorWriterProcessor.LumpyString

Enclosing class:
  MirrorWriterProcessor

     class MirrorWriterProcessor.LumpyString

extends java.lang.Object

This class represents a dynamically growable string consisting of substrings ("lumps") that are treated atomically. If the string is shortened, then an entire lump is removed. The intent is to treat each %XX escape as a lump. This class also allows single characters in a source string to be re-mapped to a different string, possible containing more than one character. Each re-mapped character is also treated as a lump.

For example, suppose part of a URI, between two slashes, is `/VeryLongString...%3A/`. We want to create a corresponding file system directory, but the string is a little longer than the allowed maximum. It's better to trim the entire `%3A` off the end than part of it. This is especially true if, later, we need to append some digits to create a unique directory name. So we treat the entire `%3A` as one lump.

Constructor Summary
`MirrorWriterProcessor.LumpyString(java.lang.String str, int beginIndex, int endIndex, int padding, int maxLen, java.util.Map characterMap, java.lang.String dotBegin)` Creates a LumpyString.

Method Summary
`(package private) void` | `append(java.lang.String lump)` Appends one lump to the end of this string.
`(package private) java.lang.StringBuffer` | `asStringBuffer()` Returns the string as a StringBuffer.
`(package private) boolean` | `endsWith(char ch)` Tests if this string ends with a character.
`(package private) int` | `length()` Gets the length of this string.
`(package private) void` | `prepend(char ch)` Prepends one character, as a lump, to this string.
`java.lang.String` | `toString()` Converts this LumpyString to a String.
`(package private) void` | `trimToMax(int maxLen)` If necessary, trims this string to a maximum length.

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

Constructor Detail

### MirrorWriterProcessor.LumpyString

    MirrorWriterProcessor.LumpyString(java.lang.String str,
                                      int beginIndex,
                                      int endIndex,
                                      int padding,
                                      int maxLen,
                                      java.util.Map characterMap,
                                      java.lang.String dotBegin)

  Creates a LumpyString.

  Parameters:
    `str` - the source string
    `beginIndex` - the beginning index, inclusive, of the substring of str to be used
    `endIndex` - the ending index, exclusive, of the substring of str to be used
    `padding` - reserve this many additional character positions before dynamic growth is needed
    `maxLen` - the maximum string length, regardless of the values of beginIndex, endIndex, and padding
    `characterMap` - maps from characters in the source string (represented as length-one String values) to replacement String values (length at least 1). Each replacement string is treated as one lump. This is intended to cope with characters that a file system does not allow.
    `dotBegin` - if non-null, this replaces a '.' at `str[beginIndex]`
  Throws:
    `java.lang.IllegalArgumentException` - if beginIndex is negative.
    `java.lang.IllegalArgumentException` - if endIndex is less than beginIndex.
    `java.lang.IllegalArgumentException` - if padding is negative.
    `java.lang.IllegalArgumentException` - if maxLen is less than one.
    `java.lang.IllegalArgumentException` - if characterMap is null.
    `java.lang.IllegalArgumentException` - if dotBegin is non-null but empty.

Method Detail

### toString

    public java.lang.String toString()

  Converts this LumpyString to a String.

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    the current string contents

### append

    void append(java.lang.String lump)

  Appends one lump to the end of this string.

  Parameters:
    `lump` - the lump (substring) to append
  Throws:
    `java.lang.IllegalArgumentException` - if lump is null or empty.

### asStringBuffer

    java.lang.StringBuffer asStringBuffer()

  Returns the string as a StringBuffer. The caller should not modify the return value.

  Returns:
    the string

### endsWith

    boolean endsWith(char ch)

  Tests if this string ends with a character.

  Parameters:
    `ch` - the character to test for
  Returns:
    true if and only if this string ends with ch

### prepend

    void prepend(char ch)

  Prepends one character, as a lump, to this string.

  Parameters:
    `ch` - the character to prepend

### length

    int length()

  Gets the length of this string.

  Returns:
    the number of characters in this string

### trimToMax

    void trimToMax(int maxLen)

  If necessary, trims this string to a maximum length. Any trimming is done by removing one or more complete lumps from the end of this string.

  Parameters:
    `maxLen` - the new maximum length. After trimming, the actual length of this string will be at most maxLen.
  Throws:
    `java.lang.IllegalArgumentException` - if maxLen is negative.

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

Copyright © 2003-2008 Internet Archive. All Rights Reserved.