protected EnhancedStringBuilder getUpdatedSource(final FileObject fileObject) throws IOException {
final EnhancedStringBuilder builder = new EnhancedStringBuilder(fileObject.asText(FileEncodingQuery.getEncoding(fileObject).name()));
final Collection<MatchEntry> currentLicense = builder.findPattern(JAVA_LICENSE);
if (CollectionUtils.isNotEmpty(currentLicense)) {
MatchEntry me = currentLicense.iterator().next();
switch (params.getUpdateMode()) {
case ALL_FILES:
/* source already have a license header. lets replace it */
builder.replace(me, getJavaLicense());
break;
case WITHOUT_LICENSE_FILES:
/* we consider the default netbeans template as "file without license" */
if (builder.substring(me.getStart(), me.getEnd()).contains(NB_LICENSE_TEMPLATE)) {
builder.replace(me, getJavaLicense());
} else {
/* returning null sinalize that this FileObject will not be updated */
return null;
}