Java Reference
In-Depth Information
if (!inTheSonnets) {
textId = doCreateBook(createBook, title,
Integer.parseInt(year), executor);
lineOffset = 0;
}
} else if (IS_COMMENT_START.test(line)) {
while (
(line = nextLine(reader)) != null &&
!IS_COMMENT_END.test(line)
) {
continue;
}
assert line != null : "No ending comment found";
} else if (IS_THE_END.test(line)) {
inTheSonnets = false;
} else {
assert (textId != 0) : "Processing, but no title provided";
lineOffset += 1;
createLine.setInt(1, textId);
createLine.setInt(2, lineOffset);
boolean createdLine = createLine.executeUpdate() == 1;
assert createdLine : "Could not create line";
ResultSet rs = createLine.getGeneratedKeys();
boolean hasNext = rs.next();
assert hasNext :
"No result when getting generated keys for for line " +
textId + "-" + lineOffset;
int lineId = rs.getInt(1);
rs.close();
String[] words = line.split("\\s+");
for (int i = 0; i < words.length; i++) {
int wordOffset = i + 1;
String word = words[i];
word = word.replaceAll("(?!')\\p{Punct}", "");
final int wordId;
if (wordMap.containsKey(word)) {
wordId = wordMap.get(word);
} else {
createWord.setString(1, word);
boolean createdWord = createWord.executeUpdate() == 1;
assert createdWord : "Could not create word: " + word;
rs = createWord.getGeneratedKeys();
hasNext = rs.next();
assert hasNext : "Created word but still could not find it!";
Search WWH ::




Custom Search