use of de.janrufmonitor.service.comment.impl.Comment in project janrufmonitor by tbrandt77.
the class CommentCallerHandler method createComment.
private IComment createComment(File commentFile) {
IComment comment = new Comment();
String commentID = commentFile.getName();
commentID = commentID.substring(0, commentID.indexOf(this.getCommentFilenameExtension()));
comment.setID(commentID);
comment.setDate(new Date(commentFile.lastModified()));
try {
FileReader commentReader = new FileReader(commentFile);
BufferedReader bufReader = new BufferedReader(commentReader);
StringBuffer text = new StringBuffer();
while (bufReader.ready()) {
text.append(bufReader.readLine());
text.append(IJAMConst.CRLF);
}
bufReader.close();
commentReader.close();
comment.setText(text.substring(0));
} catch (FileNotFoundException ex) {
this.m_logger.warning("Cannot find comment file " + commentFile);
} catch (IOException ex) {
this.m_logger.severe("IOException on file " + commentFile);
}
File commentAttributesFile = new File(commentFile.getAbsolutePath() + ".attributes");
if (commentAttributesFile.exists() && commentAttributesFile.isFile()) {
Properties commentAttributes = new Properties();
try {
FileInputStream in = new FileInputStream(commentAttributesFile);
commentAttributes.load(in);
in.close();
Iterator it = commentAttributes.keySet().iterator();
IAttribute a = null;
String key = null;
while (it.hasNext()) {
key = (String) it.next();
a = PIMRuntime.getInstance().getCallerFactory().createAttribute(key, commentAttributes.getProperty(key));
comment.addAttribute(a);
}
} catch (FileNotFoundException ex) {
this.m_logger.severe("File not found: " + commentAttributesFile.getAbsolutePath());
} catch (IOException ex) {
this.m_logger.severe("IOException on file " + commentAttributesFile.getAbsolutePath());
}
}
return comment;
}
Aggregations