|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.archive.crawler.writer.MirrorWriterProcessor.LumpyString
class MirrorWriterProcessor.LumpyString
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(java.lang.String str,
int beginIndex,
int endIndex,
int padding,
int maxLen,
java.util.Map characterMap,
java.lang.String dotBegin)
str - the source stringbeginIndex - the beginning index, inclusive, of the substring
of str to be usedendIndex - the ending index, exclusive, of the substring
of str to be usedpadding - reserve this many additional character positions
before dynamic growth is neededmaxLen - the maximum string length, regardless of the
values of beginIndex, endIndex, and paddingcharacterMap - 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]
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 |
|---|
public java.lang.String toString()
toString in class java.lang.Objectvoid append(java.lang.String lump)
lump - the lump (substring) to append
java.lang.IllegalArgumentException - if
lump is null or empty.java.lang.StringBuffer asStringBuffer()
boolean endsWith(char ch)
ch - the character to test for
void prepend(char ch)
ch - the character to prependint length()
void trimToMax(int maxLen)
maxLen - the new maximum length.
After trimming, the actual length of this string will be
at most maxLen.
java.lang.IllegalArgumentException - if
maxLen is negative.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||