* @return A set of types or an empty set if the black list was not found.
*/
protected Set<TypeMatcher> loadBlackListFromPackage(final Package packagee) {
Checker.notNull("parameter:package", packagee);
final GeneratorContext context = this.getGeneratorContext();
context.delayedBranch();
context.debug(packagee.getName());
final Set<TypeMatcher> expressions = new HashSet<TypeMatcher>();
final String fileName = this.getResourceName(packagee, SerializationConstants.BLACKLIST_FILENAME);
InputStream inputStream = null;
while (true) {
try {
inputStream = this.getClass().getResourceAsStream(fileName);
if (null == inputStream) {
break;
}
// context.debug(fileName);
// use a BufferedReader to read a line at a time skipping
// comments and empty lines.
final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
while (true) {
final String line = reader.readLine();
// eof reached...
if (null == line) {
break;
}
// skip empty / comment lines...
final String typeName = line.trim();
if (Tester.isNullOrEmpty(typeName) || typeName.startsWith("#")) {
continue;
}
context.debug(line);
final TypeMatcher typeNameMatcher = TypeMatcherFactory.createTypeNameMatcher(typeName);
expressions.add(typeNameMatcher);
}
break;
} catch (final RuntimeException caught) {
throw caught;
} catch (final Exception caught) {
throw new SerializationFactoryGeneratorException("Failed to load black list, message: " + caught.getMessage(), caught);
} finally {
InputOutput.closeIfNecessary(inputStream);
}
}
context.unbranch();
return expressions;
}