Coverage Report
livenotificationrun
measured on November 5, 2007 4:04:16 PM CET
up to the title page
org . codecover . simplejavaapp . model . AppFile . saveAppFile
Statement Coverage Branch Coverage Loop Coverage Strict Condition Coverage
void saveAppFile(File file) throws ParserConfigurationException, TransformerException, IOException 22 / 22 100 %
2 / 3 66 %
1 / 3 33 %
0 / 1 0 %
AppFile.java
204       void saveAppFile(File file) throws ParserConfigurationException,
205               TransformerException, IOException {
206           Document xmlDoc = null;
207           DocumentBuilderFactory docBFac;
208           DocumentBuilder docBuild;
209  
210           docBFac = DocumentBuilderFactory.newInstance();
211           docBFac.setNamespaceAware(true);
212           docBuild = docBFac.newDocumentBuilder();
213           xmlDoc = docBuild.newDocument();
214  
215           if (xmlDoc != null) {
216               Element documentElement = xmlDoc.createElement("SimpleJavaApp");
217               xmlDoc.appendChild(documentElement);
218  
219               Element bookListElement = xmlDoc.createElement("BookList");
220  
221               for (Book book : getBooks()) {
222                   bookListElement.appendChild(book.getXMLRepresentation(xmlDoc));
223               }
224  
225               documentElement.appendChild(bookListElement);
226           }
227  
228           FileOutputStream out = new FileOutputStream(file);
229           try {
230               DOMSource domSource = new DOMSource(xmlDoc);
231               StreamResult streamResult = new StreamResult(out);
232               TransformerFactory tf = TransformerFactory.newInstance();
233               Transformer serializer = tf.newTransformer();
234               serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
235               serializer.setOutputProperty(OutputKeys.INDENT, "yes");
236               serializer.transform(domSource, streamResult);
237               out.flush();
238  
239               /*
240                * All saving operations were successful, so the AppFile can be set
241                * to 'not modified'.
242                */
243               this.setModified(false);
244               this.setPath(file.getAbsolutePath());
245           } finally {
246               out.close();
247           }
248       }
created on November 17, 2007 7:07:00 PM CET with CodeCover