String name = annotation.getName();
String value = annotation.getValue();
if (name.equals("stocky") && value.equals("_new_")) {
int startIndex = annotation.getRange().getStart();
BlipContentRefs blipContentRefs = blip.range(annotation.getRange().getStart(), annotation
.getRange().getEnd());
blipContentRefs.annotate("stocky", "_done_");
String annotatedContent = blipContentRefs.value().getText();
LOG.info("annotatedContent = " + annotatedContent);
//String symbol = annotatedContent.substring(1, annotatedContent.length() - 1).toUpperCase();
String symbol = annotatedContent.toUpperCase();
LOG.info("stocky finds new symbol: " + symbol);
// Replace the content with new and delete the "stocky" annotation.
String price = String.format("$%.2f", util.getStockPrice(symbol));
String newContent = String.format("%s[%s] ", symbol, price);
blipContentRefs = blipContentRefs.replace(newContent);
BlipContentRefs symbolContentRef = blip.range(startIndex, startIndex + symbol.length());
symbolContentRef.annotate("style/color", "rgb(50,205,50)");
symbolContentRef.annotate("style/fontWeight", "bold");
BlipContentRefs priceContentRef = blip.range(startIndex + symbol.length() + 1, startIndex
+ symbol.length() + 1 + price.length());
priceContentRef.annotate("style/color", "rgb(50,205,50)");
priceContentRef.annotate("style/fontSize", "0.8em");
priceContentRef.annotate("style/color", "rgb(255,0,0)");
}
}
}