Skip to content

Commit

Permalink
Fix checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
normanmaurer committed Jul 4, 2012
1 parent 5acd5a2 commit f499348
Showing 1 changed file with 51 additions and 51 deletions.
Expand Up @@ -1281,12 +1281,12 @@ private String readLine() throws NotEnoughDataDecoderException {
throw new NotEnoughDataDecoderException();
}

/**
/**
* Read one line up to --delimiter or --delimiter-- and if existing the CRLF or LF
* Read one line up to --delimiter or --delimiter-- and if existing the CRLF or LF.
* Note that CRLF or LF are mandatory for opening delimiter (--delimiter) but not for
* closing delimiter (--delimiter--) since some clients does not include CRLF in this case.
*
*
* @param delimiter of the form --string, such that '--' is already included
* @return the String from one line as the delimiter searched (opening or closing)
* @throws NotEnoughDataDecoderException Need more chunks and
Expand All @@ -1301,26 +1301,26 @@ private String readDelimiterStandard(String delimiter) throws NotEnoughDataDecod
while (undecodedChunk.readable() && delimiterPos < len) {
byte nextByte = undecodedChunk.readByte();
if (nextByte == delimiter.charAt(delimiterPos)) {
delimiterPos++;
delimiterPos++;
sb.append((char) nextByte);
} else {
// delimiter not found so break here !
undecodedChunk.readerIndex(readerIndex);
// delimiter not found so break here !
undecodedChunk.readerIndex(readerIndex);
throw new NotEnoughDataDecoderException();
}
}
// Now check if either opening delimiter or closing delimiter
if (undecodedChunk.readable()) {
byte nextByte = undecodedChunk.readByte();
byte nextByte = undecodedChunk.readByte();
// first check for opening delimiter
if (nextByte == HttpConstants.CR) {
nextByte = undecodedChunk.readByte();
if (nextByte == HttpConstants.LF) {
return sb.toString();
} else {
// error since CR must be followed by LF
// delimiter not found so break here !
undecodedChunk.readerIndex(readerIndex);
// error since CR must be followed by LF
// delimiter not found so break here !
undecodedChunk.readerIndex(readerIndex);
throw new NotEnoughDataDecoderException();
}
} else if (nextByte == HttpConstants.LF) {
Expand All @@ -1339,26 +1339,26 @@ private String readDelimiterStandard(String delimiter) throws NotEnoughDataDecod
if (nextByte == HttpConstants.LF) {
return sb.toString();
} else {
// error CR without LF
// delimiter not found so break here !
undecodedChunk.readerIndex(readerIndex);
// error CR without LF
// delimiter not found so break here !
undecodedChunk.readerIndex(readerIndex);
throw new NotEnoughDataDecoderException();
}
} else if (nextByte == HttpConstants.LF) {
return sb.toString();
} else {
// No CRLF but ok however (Adobe Flash uploader)
// minus 1 since we read one char ahead but should not
undecodedChunk.readerIndex(undecodedChunk.readerIndex()-1);
// No CRLF but ok however (Adobe Flash uploader)
// minus 1 since we read one char ahead but should not
undecodedChunk.readerIndex(undecodedChunk.readerIndex() - 1);
return sb.toString();
}
}
// FIXME what do we do here?
// FIXME what do we do here?
// either considering it is fine, either waiting for more data to come?
// lets try considering it is fine...
return sb.toString();
}
// only one '-' => not enough
// only one '-' => not enough
// whatever now => error since incomplete
}
}
Expand All @@ -1369,11 +1369,12 @@ private String readDelimiterStandard(String delimiter) throws NotEnoughDataDecod
undecodedChunk.readerIndex(readerIndex);
throw new NotEnoughDataDecoderException();
}

/**
* Read one line up to --delimiter or --delimiter-- and if existing the CRLF or LF.
* Note that CRLF or LF are mandatory for opening delimiter (--delimiter) but not for
* closing delimiter (--delimiter--) since some clients does not include CRLF in this case.
*
*
* @param delimiter of the form --string, such that '--' is already included
* @return the String from one line as the delimiter searched (opening or closing)
* @throws NotEnoughDataDecoderException Need more chunks and
Expand All @@ -1395,11 +1396,11 @@ private String readDelimiter(String delimiter) throws NotEnoughDataDecoderExcept
while (sao.pos < sao.limit && delimiterPos < len) {
byte nextByte = sao.bytes[sao.pos ++];
if (nextByte == delimiter.charAt(delimiterPos)) {
delimiterPos++;
delimiterPos++;
sb.append((char) nextByte);
} else {
// delimiter not found so break here !
undecodedChunk.readerIndex(readerIndex);
// delimiter not found so break here !
undecodedChunk.readerIndex(readerIndex);
throw new NotEnoughDataDecoderException();
}
}
Expand All @@ -1415,9 +1416,9 @@ private String readDelimiter(String delimiter) throws NotEnoughDataDecoderExcept
return sb.toString();
}
} else {
// error since CR must be followed by LF
// delimiter not found so break here !
undecodedChunk.readerIndex(readerIndex);
// error since CR must be followed by LF
// delimiter not found so break here !
undecodedChunk.readerIndex(readerIndex);
throw new NotEnoughDataDecoderException();
}
} else if (nextByte == HttpConstants.LF) {
Expand All @@ -1427,44 +1428,44 @@ private String readDelimiter(String delimiter) throws NotEnoughDataDecoderExcept
} else if (nextByte == '-') {
sb.append((char) nextByte);
// second check for closing delimiter
if (sao.pos < sao.limit) {
if (sao.pos < sao.limit) {
nextByte = sao.bytes[sao.pos ++];
if (nextByte == '-') {
sb.append((char) nextByte);
// now try to find if CRLF or LF there
if (sao.pos < sao.limit) {
nextByte = sao.bytes[sao.pos ++];
if (nextByte == HttpConstants.CR) {
if (sao.pos < sao.limit) {
nextByte = sao.bytes[sao.pos ++];
if (nextByte == HttpConstants.LF) {
sao.setReadPosition(0);
return sb.toString();
}
} else {
// error CR without LF
// delimiter not found so break here !
undecodedChunk.readerIndex(readerIndex);
throw new NotEnoughDataDecoderException();
}
} else if (nextByte == HttpConstants.LF) {
sao.setReadPosition(0);
return sb.toString();
} else {
// No CRLF but ok however (Adobe Flash uploader)
// minus 1 since we read one char ahead but should not
sao.setReadPosition(1);
return sb.toString();
}
nextByte = sao.bytes[sao.pos++];
if (nextByte == HttpConstants.CR) {
if (sao.pos < sao.limit) {
nextByte = sao.bytes[sao.pos++];
if (nextByte == HttpConstants.LF) {
sao.setReadPosition(0);
return sb.toString();
}
} else {
// error CR without LF
// delimiter not found so break here !
undecodedChunk.readerIndex(readerIndex);
throw new NotEnoughDataDecoderException();
}
} else if (nextByte == HttpConstants.LF) {
sao.setReadPosition(0);
return sb.toString();
} else {
// No CRLF but ok however (Adobe Flash uploader)
// minus 1 since we read one char ahead but should not
sao.setReadPosition(1);
return sb.toString();
}
}
// FIXME what do we do here?
// FIXME what do we do here?
// either considering it is fine, either waiting for more data to come?
// lets try considering it is fine...
sao.setReadPosition(0);
return sb.toString();
}
// whatever now => error since incomplete
// only one '-' => not enough or whatever not enough element
// only one '-' => not enough or whatever not enough element
}
}
}
Expand All @@ -1476,7 +1477,6 @@ private String readDelimiter(String delimiter) throws NotEnoughDataDecoderExcept
throw new NotEnoughDataDecoderException();
}


/**
* Read a FileUpload data as Byte (Binary) and add the bytes directly to the
* FileUpload. If the delimiter is found, the FileUpload is completed.
Expand Down

0 comments on commit f499348

Please sign in to comment.