1 55 package org.lateralnz.common.cli; 56 57 import java.io.*; 58 59 import org.w3c.dom.Document ; 60 61 import org.lateralnz.common.util.IOUtils; 62 import org.lateralnz.common.util.StringUtils; 63 import org.lateralnz.common.util.XMLUtils; 64 65 public class CLInterface { 66 protected String prompt; 67 protected CLIOHandler ioh; 68 69 protected CLInterface(String prompt, CLIOHandler ioh) { 70 this.prompt = prompt; 71 this.ioh = ioh; 72 } 73 74 public CLTemplate parse(String templateFile) throws Exception { 75 InputStream is = this.getClass().getClassLoader().getResourceAsStream(templateFile); 76 77 InputStreamReader isr = null; 78 Document doc; 79 try { 80 isr = new InputStreamReader(is); 81 doc = XMLUtils.parse(XMLUtils.preprocess(StringUtils.readFrom(isr))); 82 } 83 finally { 84 IOUtils.close(isr); 85 } 86 return new CLTemplate(doc, ioh); 87 } 88 } 89 | Popular Tags |