List of usage examples for java.io StringWriter getBuffer
public StringBuffer getBuffer()
From source file:edu.cornell.med.icb.goby.modes.TestDiscoverSVMethylationRatesMode.java
@Test public void testMethylationFormatGenomicContext() throws IOException, JSAPException { final MethylationRateVCFOutputFormat outputFormat = new MethylationRateVCFOutputFormat(); DiscoverVariantIterateSortedAlignments iterator = new DiscoverVariantIterateSortedAlignments(outputFormat) { @Override/*from w ww .ja v a2 s . c o m*/ public CharSequence getReferenceId(int targetIndex) { return Integer.toString(targetIndex); } }; DiscoverSequenceVariantsMode mode = new DiscoverSequenceVariantsMode() { @Override public String[] getSamples() { return new String[] { "methylated", "not-so" }; } @Override public String[] getGroups() { return new String[] { "methylated", "not-so" }; } @Override public int[] getReaderIndexToGroupIndex() { return new int[] { 0, 1 }; // sample index is group index; } @Override public ArrayList<GroupComparison> getGroupComparisons() { ArrayList<GroupComparison> list = new ArrayList<GroupComparison>(); list.add(new GroupComparison("methylated", "not-so", 0, 1, 0)); return list; } }; outputFormat.setGenome(genome); StringWriter writer = new StringWriter(); outputFormat.allocateStorage(2, 2); outputFormat.defineColumns(new PrintWriter(writer), mode); outputFormat.setMinimumEventThreshold(0); outputFormat.writeRecord(iterator, makeTwoSampleCounts(), 1, 6, list1(), 0, 1); writer.flush(); String stringB = writer.getBuffer().toString(); assertTrue(stringB, stringB.contains("Context=CpG")); writer = new StringWriter(); outputFormat.allocateStorage(2, 2); outputFormat.defineColumns(new PrintWriter(writer), mode); outputFormat.setMinimumEventThreshold(0); final int referenceIndex = 2; outputFormat.setGenomeReferenceIndex(referenceIndex); outputFormat.writeRecord(iterator, makeTwoSampleCounts(), referenceIndex, 1, list1(), 0, 1); writer.flush(); String stringC = writer.getBuffer().toString(); assertTrue(stringC, stringC.contains("Context=CpT")); writer = new StringWriter(); outputFormat.allocateStorage(2, 2); outputFormat.defineColumns(new PrintWriter(writer), mode); outputFormat.setMinimumEventThreshold(0); final int referenceIndex1 = 1; outputFormat.setGenomeReferenceIndex(referenceIndex1); outputFormat.writeRecord(iterator, makeTwoSampleCounts(), referenceIndex1, 2, list1(), 0, 1); stringB = writer.getBuffer().toString(); assertTrue(stringB, stringB.contains("CpT")); writer = new StringWriter(); outputFormat.allocateStorage(2, 2); outputFormat.defineColumns(new PrintWriter(writer), mode); outputFormat.setMinimumEventThreshold(0); final int referenceIndex4 = 4; outputFormat.setGenomeReferenceIndex(referenceIndex4); outputFormat.writeRecord(iterator, makeTwoSampleCounts(), referenceIndex4, 7, list1(), 0, 1); stringB = writer.getBuffer().toString(); assertTrue(stringB, stringB.contains("CpC")); }
From source file:com.evon.injectTemplate.InjectTemplateFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; StringWriter writer = new StringWriter(); BufferedResponseWrapper wrapper = new BufferedResponseWrapper((HttpServletResponse) response, writer); chain.doFilter(request, wrapper);//from w w w .j ava2 s. co m String contentType = null; String uri = httpRequest.getRequestURI(); contentType = httpResponse.getContentType(); if (contentTypes.containsKey(uri)) { contentType = contentTypes.get(uri); } else if (contentType != null) { contentTypes.put(uri, contentType); } contentType = (contentType == null) ? "none" : contentType; String out = writer.getBuffer().toString(); boolean requestedURIIsTheTemplate = false; requestedURIIsTheTemplate = InjectUtils.isTemplate(uri); boolean contentTypeIsText = !wrapper.isBinary() && contentType != null && !contentType.equals("none"); if (requestedURIIsTheTemplate || !contentTypeIsText) { if (contentTypeIsText) { response.getWriter().print(out); } return; } if (!templateLodaded && !templateLodadedStarted) { loadTemplates(httpRequest); } TemplateBean template = getTemplatePathByURI(uri); if (template == null) { response.getWriter().print(out); return; } String key = null; if (template.cache.equals("SESSION")) { String cookiesNames = getCookieHashs(httpRequest); key = template.path + cookiesNames; } else if (template.cache.equals("ON")) { key = template.path; } if (!templates.containsKey("/" + template.path)) { throw new ServletException("Template [" + template.path + "] not founded"); } boolean needRefresh = template.refreshInSeconds > 0 && ((System.currentTimeMillis() - template.lastUpdate) / 1000) > template.refreshInSeconds; boolean replaceTemplate = template.cache.equals("OFF") || !htmlContents.containsKey(key) || needRefresh; /* pra investigar erro de nulo, boolean notExist = key==null || !htmlContents.containsKey(key); * if(!notExist) { notExist=!notExist; //throw new ServletException("content not exist"); } */ if (replaceTemplate) { if (needRefresh) { template.lastUpdate = System.currentTimeMillis(); } try { loadContentTemplate(template, request.getServerName(), request.getServerPort(), request.getProtocol().contains("HTTPS"), httpRequest); } catch (Exception e) { throw new ServletException(e.getMessage(), e); } } HTMLInfoBean templateHTML = templates.get("/" + template.path); String contentTemplate = htmlContents.get(key).getContent(); IDocument docOut = HTMLParser.parse(out); for (String selector : templateHTML.getSelectors()) { IElements elements = docOut.select(selector); if (elements.size() == 0) { System.out.println("WARNING: Selector [" + selector + "] in template [" + templateHTML.getUri() + "] not founded in [" + httpRequest.getRequestURI() + "]"); continue; } if (elements.size() != 1) { System.out.println( "WARNING: Selector get many elements. Choosed the first to URI: " + templateHTML.getUri()); } IElement element = elements.get(0); String innerHTML = element.html(); contentTemplate = contentTemplate.replace("<INJECT selector='" + selector + "'/>", innerHTML); } response.getWriter().print(contentTemplate); }
From source file:isl.FIMS.servlet.imports.ImportXML.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.initVars(request); String username = getUsername(request); Config conf = new Config("EisagwghXML_RDF"); String xsl = ApplicationConfig.SYSTEM_ROOT + "formating/xsl/import/ImportXML.xsl"; String displayMsg = ""; response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); StringBuilder xml = new StringBuilder( this.xmlStart(this.topmenu, username, this.pageTitle, this.lang, "", request)); // ArrayList<String> notValidMXL = new ArrayList<String>(); HashMap<String, ArrayList> notValidMXL = new <String, ArrayList>HashMap(); if (!ServletFileUpload.isMultipartContent(request)) { displayMsg = "form"; } else {// w ww . j a va2s. c om // configures some settings String filePath = this.export_import_Folder; java.util.Date date = new java.util.Date(); Timestamp t = new Timestamp(date.getTime()); String currentDir = filePath + t.toString().replaceAll(":", ""); File saveDir = new File(currentDir); if (!saveDir.exists()) { saveDir.mkdir(); } DiskFileItemFactory factory = new DiskFileItemFactory(); factory.setSizeThreshold(DiskFileItemFactory.DEFAULT_SIZE_THRESHOLD); factory.setRepository(saveDir); ArrayList<String> savedIDs = new ArrayList<String>(); ServletFileUpload upload = new ServletFileUpload(factory); upload.setSizeMax(REQUEST_SIZE); // constructs the directory path to store upload file String uploadPath = currentDir; int xmlCount = 0; String[] id = null; try { // parses the request's content to extract file data List formItems = upload.parseRequest(request); Iterator iter = formItems.iterator(); // iterates over form's fields File storeFile = null; while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); // processes only fields that are not form fields if (!item.isFormField()) { String fileName = new File(item.getName()).getName(); filePath = uploadPath + File.separator + fileName; storeFile = new File(filePath); item.write(storeFile); Utils.unzip(fileName, uploadPath); File dir = new File(uploadPath); String[] extensions = new String[] { "xml", "x3ml" }; List<File> files = (List<File>) FileUtils.listFiles(dir, extensions, true); xmlCount = files.size(); for (File file : files) { // saves the file on disk Document doc = ParseXMLFile.parseFile(file.getPath()); String xmlContent = doc.getDocumentElement().getTextContent(); String uri_name = ""; try { uri_name = DMSTag.valueOf("uri_name", "target", type, this.conf)[0]; } catch (DMSException ex) { ex.printStackTrace(); } String uriValue = this.URI_Reference_Path + uri_name + "/"; boolean insertEntity = false; if (xmlContent.contains(uriValue) || file.getName().contains(type)) { insertEntity = true; } Element root = doc.getDocumentElement(); Node admin = Utils.removeNode(root, "admin", true); // File rename = new File(uploadPath + File.separator + id[0] + ".xml"); // boolean isRename = storeFile.renameTo(rename); // ParseXMLFile.saveXMLDocument(rename.getPath(), doc); String schemaFilename = ""; schemaFilename = type; SchemaFile sch = new SchemaFile(schemaFolder + schemaFilename + ".xsd"); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); StringWriter writer = new StringWriter(); transformer.transform(new DOMSource(doc), new StreamResult(writer)); String xmlString = writer.getBuffer().toString().replaceAll("\r", ""); //without admin boolean isValid = sch.validate(xmlString); if ((!isValid && insertEntity)) { notValidMXL.put(file.getName(), null); } else if (insertEntity) { id = initInsertFile(type, false); doc = createAdminPart(id[0], type, doc, username); writer = new StringWriter(); transformer.transform(new DOMSource(doc), new StreamResult(writer)); xmlString = writer.getBuffer().toString().replaceAll("\r", ""); DBCollection col = new DBCollection(this.DBURI, id[1], this.DBuser, this.DBpassword); DBFile dbF = col.createFile(id[0] + ".xml", "XMLDBFile"); dbF.setXMLAsString(xmlString); dbF.store(); ArrayList<String> externalFiles = new <String>ArrayList(); ArrayList<String> externalDBFiles = new <String>ArrayList(); String q = "//*["; for (String attrSet : this.uploadAttributes) { String[] temp = attrSet.split("#"); String func = temp[0]; String attr = temp[1]; if (func.contains("text")) { q += "@" + attr + "]/text()"; } else { q = "data(//*[@" + attr + "]/@" + attr + ")"; } String[] res = dbF.queryString(q); for (String extFile : res) { externalFiles.add(extFile + "#" + attr); } } q = "//"; if (!dbSchemaPath[0].equals("")) { for (String attrSet : this.dbSchemaPath) { String[] temp = attrSet.split("#"); String func = temp[0]; String path = temp[1]; if (func.contains("text")) { q += path + "//text()"; } else { q = "data(//" + path + ")"; } String[] res = dbF.queryString(q); for (String extFile : res) { externalDBFiles.add(extFile); } } } ArrayList<String> missingExternalFiles = new <String>ArrayList(); for (String extFile : externalFiles) { extFile = extFile.substring(0, extFile.lastIndexOf("#")); List<File> f = (List<File>) FileUtils.listFiles(dir, FileFilterUtils.nameFileFilter(extFile), TrueFileFilter.INSTANCE); if (f.size() == 0) { missingExternalFiles.add(extFile); } } if (missingExternalFiles.size() > 0) { notValidMXL.put(file.getName(), missingExternalFiles); } XMLEntity xmlNew = new XMLEntity(this.DBURI, this.systemDbCollection + type, this.DBuser, this.DBpassword, type, id[0]); ArrayList<String> worngFiles = Utils.checkReference(xmlNew, this.DBURI, id[0], type, this.DBuser, this.DBpassword); if (worngFiles.size() > 0) { //dbF.remove(); notValidMXL.put(file.getName(), worngFiles); } //remove duplicates from externalFiles if any HashSet hs = new HashSet(); hs.addAll(missingExternalFiles); missingExternalFiles.clear(); missingExternalFiles.addAll(hs); if (missingExternalFiles.isEmpty() && worngFiles.isEmpty()) { for (String extFile : externalFiles) { String attr = extFile.substring(extFile.lastIndexOf("#") + 1, extFile.length()); extFile = extFile.substring(0, extFile.lastIndexOf("#")); List<File> f = (List<File>) FileUtils.listFiles(dir, FileFilterUtils.nameFileFilter(extFile), TrueFileFilter.INSTANCE); File uploadFile = f.iterator().next(); String content = FileUtils.readFileToString(uploadFile); DBFile uploadsDBFile = new DBFile(this.DBURI, this.adminDbCollection, "Uploads.xml", this.DBuser, this.DBpassword); String mime = Utils.findMime(uploadsDBFile, uploadFile.getName(), attr); String uniqueName = Utils.createUniqueFilename(uploadFile.getName()); File uploadFileUnique = new File(uploadFile.getPath().substring(0, uploadFile.getPath().lastIndexOf(File.separator)) + File.separator + uniqueName); uploadFile.renameTo(uploadFileUnique); xmlString = xmlString.replaceAll(uploadFile.getName(), uniqueName); String upload_path = this.systemUploads + type; File upload_dir = null; ; if (mime.equals("Photos")) { upload_path += File.separator + mime + File.separator + "original" + File.separator; upload_dir = new File(upload_path + uniqueName); FileUtils.copyFile(uploadFileUnique, upload_dir); Utils.resizeImage(uniqueName, upload_path, upload_path.replaceAll("original", "thumbs"), thumbSize); Utils.resizeImage(uniqueName, upload_path, upload_path.replaceAll("original", "normal"), normalSize); xmlString = xmlString.replace("</versions>", "</versions>" + "\n" + "<type>Photos</type>"); } else { upload_path += File.separator + mime + File.separator; upload_dir = new File(upload_path + uniqueName); FileUtils.copyFile(uploadFileUnique, upload_dir); } if (!dbSchemaFolder.equals("")) { if (externalDBFiles.contains(extFile)) { try { DBCollection colSchema = new DBCollection(this.DBURI, dbSchemaFolder, this.DBuser, this.DBpassword); DBFile dbFSchema = colSchema.createFile(uniqueName, "XMLDBFile"); dbFSchema.setXMLAsString(content); dbFSchema.store(); } catch (Exception e) { } } } uploadFileUnique.renameTo(uploadFile); } dbF.setXMLAsString(xmlString); dbF.store(); Utils.updateReferences(xmlNew, this.DBURI, id[0].split(type)[1], type, this.DBpassword, this.DBuser); Utils.updateVocabularies(xmlNew, this.DBURI, id[0].split(type)[1], type, this.DBpassword, this.DBuser, lang); savedIDs.add(id[0]); } else { dbF.remove(); } } } } } Document doc = ParseXMLFile.parseFile(ApplicationConfig.SYSTEM_ROOT + "formating/multi_lang.xml"); Element root = doc.getDocumentElement(); Element contextTag = (Element) root.getElementsByTagName("context").item(0); String uri_name = ""; try { uri_name = DMSTag.valueOf("uri_name", "target", type, this.conf)[0]; } catch (DMSException ex) { } if (notValidMXL.size() == 0) { xsl = conf.DISPLAY_XSL; displayMsg = Messages.ACTION_SUCCESS; displayMsg += Messages.NL + Messages.NL + Messages.URI_ID; String uriValue = ""; xml.append("<Display>").append(displayMsg).append("</Display>\n"); xml.append("<backPages>").append('2').append("</backPages>\n"); for (String saveId : savedIDs) { uriValue = this.URI_Reference_Path + uri_name + "/" + saveId + Messages.NL; xml.append("<codeValue>").append(uriValue).append("</codeValue>\n"); } } else if (notValidMXL.size() >= 1) { xsl = ApplicationConfig.SYSTEM_ROOT + "formating/xsl/import/ImportXML.xsl"; Iterator it = notValidMXL.keySet().iterator(); while (it.hasNext()) { String key = (String) it.next(); ArrayList<String> value = notValidMXL.get(key); if (value != null) { displayMsg += "<line>"; Element select = (Element) contextTag.getElementsByTagName("missingReferences").item(0); displayMsg += select.getElementsByTagName(lang).item(0).getTextContent(); displayMsg = displayMsg.replace("?", key); for (String mis_res : value) { displayMsg += mis_res + ","; } displayMsg = displayMsg.substring(0, displayMsg.length() - 1); displayMsg += "."; displayMsg += "</line>"; } else { displayMsg += "<line>"; Element select = (Element) contextTag.getElementsByTagName("NOT_VALID_XML").item(0); displayMsg += select.getElementsByTagName(lang).item(0).getTextContent(); displayMsg = displayMsg.replace(";", key); displayMsg += "</line>"; } displayMsg += "<line>"; displayMsg += "</line>"; } if (notValidMXL.size() < xmlCount) { displayMsg += "<line>"; Element select = (Element) contextTag.getElementsByTagName("rest_valid").item(0); displayMsg += select.getElementsByTagName(lang).item(0).getTextContent(); displayMsg += "</line>"; for (String saveId : savedIDs) { displayMsg += "<line>"; String uriValue = this.URI_Reference_Path + uri_name + "/" + saveId; select = (Element) contextTag.getElementsByTagName("URI_ID").item(0); displayMsg += select.getElementsByTagName(lang).item(0).getTextContent() + ": " + uriValue; displayMsg += "</line>"; } } } Utils.deleteDir(currentDir); } catch (Exception ex) { ex.printStackTrace(); displayMsg += Messages.NOT_VALID_IMPORT; } } xml.append("<Display>").append(displayMsg).append("</Display>\n"); xml.append("<EntityType>").append(type).append("</EntityType>\n"); xml.append(this.xmlEnd()); try { XMLTransform xmlTrans = new XMLTransform(xml.toString()); xmlTrans.transform(out, xsl); } catch (DMSException e) { e.printStackTrace(); } out.close(); }
From source file:com.flexive.war.beans.admin.main.ScriptBean.java
/** * Runs the given script code in the console *//*from ww w . j av a 2 s . c om*/ public void runScriptInConsole() { FxScriptInfoEdit sinfo = currentData.sinfo; if (StringUtils.isBlank(sinfo.getCode())) { new FxFacesMsgErr("Script.err.noCodeProvided").addToContext(); } else { long start = System.currentTimeMillis(); try { result = ScriptConsoleBean.runScript(sinfo.getCode(), sinfo.getName(), false); } catch (Exception e) { final StringWriter writer = new StringWriter(); e.printStackTrace(new PrintWriter(writer)); final String msg = e.getCause() != null ? e.getCause().getMessage() : e.getMessage(); result = new Formatter().format("Exception caught: %s%n%s", msg, writer.getBuffer()); } finally { currentData.executionTime = System.currentTimeMillis() - start; } } }
From source file:com.twinsoft.convertigo.engine.util.XMLUtils.java
public static String prettyPrintElement(Element elt, boolean omitXMLDeclaration, boolean bIndent) { Node firstChild = elt;/* w w w . java2 s . co m*/ String encoding = "ISO-8859-1"; // default Encoding char set if non is // found in the PI if (omitXMLDeclaration && (firstChild.getNodeType() == Document.PROCESSING_INSTRUCTION_NODE) && (firstChild.getNodeName().equals("xml"))) { String piValue = firstChild.getNodeValue(); // extract from PI the encoding Char Set int encodingOffset = piValue.indexOf("encoding=\""); if (encodingOffset != -1) { encoding = piValue.substring(encodingOffset + 10); // remove the last " encoding = encoding.substring(0, encoding.length() - 1); } } StringWriter strWtr = new StringWriter(); try { Transformer t = getNewTransformer(); t.setOutputProperty(OutputKeys.ENCODING, encoding); t.setOutputProperty(OutputKeys.INDENT, bIndent ? "yes" : "no"); t.setOutputProperty(OutputKeys.METHOD, "xml"); // xml, html, text t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, omitXMLDeclaration ? "yes" : "no"); t.transform(new DOMSource(elt), new StreamResult(strWtr)); return strWtr.getBuffer().toString(); } catch (Exception e) { System.err.println("XML.toString(Document): " + e); Engine.logEngine.error("Unexpected exception", e); return e.getMessage(); } }
From source file:net.sf.jabref.gui.plaintextimport.TextInputDialog.java
private void updateSourceView() { StringWriter sw = new StringWriter(200); try {//from ww w. jav a 2 s .c o m new BibEntryWriter( new LatexFieldFormatter(LatexFieldFormatterPreferences.fromPreferences(Globals.prefs)), false) .write(entry, sw, frame.getCurrentBasePanel().getBibDatabaseContext().getMode()); sourcePreview.setText(sw.getBuffer().toString()); } catch (IOException ex) { LOGGER.error("Error in entry" + ": " + ex.getMessage(), ex); } fieldList.clearSelection(); }
From source file:edu.cornell.med.icb.goby.modes.TestDiscoverSVMethylationRatesMode.java
@Test public void testMethylationFormat() throws IOException, JSAPException { final MethylationRateVCFOutputFormat outputFormat = new MethylationRateVCFOutputFormat(); DiscoverVariantIterateSortedAlignments iterator = new DiscoverVariantIterateSortedAlignments(outputFormat) { @Override/*from w w w. ja v a 2 s .co m*/ public CharSequence getReferenceId(int targetIndex) { return "ref-id"; } }; DiscoverSequenceVariantsMode mode = new DiscoverSequenceVariantsMode() { @Override public String[] getSamples() { return new String[] { "methylated", "not-so" }; } @Override public String[] getGroups() { return new String[] { "methylated", "not-so" }; } @Override public int[] getReaderIndexToGroupIndex() { return new int[] { 0, 1 }; // sample index is group index; } @Override public ArrayList<GroupComparison> getGroupComparisons() { ArrayList<GroupComparison> list = new ArrayList<GroupComparison>(); list.add(new GroupComparison("methylated", "not-so", 0, 1, 0)); return list; } }; StringWriter writer = new StringWriter(); outputFormat.allocateStorage(2, 2); outputFormat.setGenome(genome); outputFormat.defineColumns(new PrintWriter(writer), mode); outputFormat.setMinimumEventThreshold(0); outputFormat.writeRecord(iterator, makeTwoSampleCounts(), 0, 0, list1(), 0, 1); writer.flush(); String stringB = writer.getBuffer().toString(); assertTrue(stringB, stringB.contains("#Cm_Group[methylated]=1;")); assertTrue(stringB, stringB.contains("#Cm_Group[not-so]=0;")); writer = new StringWriter(); outputFormat.allocateStorage(2, 2); outputFormat.defineColumns(new PrintWriter(writer), mode); final SampleCountInfo[] sampleCounts = makeTwoSampleCounts(); sampleCounts[0].referenceBase = 'G'; outputFormat.writeRecord(iterator, sampleCounts, 0, 0, list2(), 0, 1); writer.flush(); stringB = writer.getBuffer().toString(); assertTrue(stringB, stringB.contains("#Cm_Group[methylated]=1;")); assertTrue(stringB, stringB.contains("#Cm_Group[not-so]=0;")); assertTrue(stringB, stringB.contains("MR[methylated]=100.0;")); assertTrue(stringB, stringB.contains("MR[not-so]=NaN;")); writer = new StringWriter(); outputFormat.allocateStorage(2, 2); outputFormat.defineColumns(new PrintWriter(writer), mode); outputFormat.writeRecord(iterator, makeTwoSampleCounts(), 0, 0, list3(), 0, 1); stringB = writer.getBuffer().toString(); assertTrue(stringB, stringB.contains("#Cm_Group[methylated]=1;")); assertTrue(stringB, stringB.contains("#C_Group[methylated]=1;")); assertTrue(stringB, stringB.contains("#Cm_Group[not-so]=0;")); assertTrue(stringB, stringB.contains("#C_Group[not-so]=0;")); /* org.junit.Assert.assertEquals("content must match", header+ "ref-id\t1\t\tC\tA,T,N\t\t\tBIOMART_COORDS=ref-id:1:1;Strand=+;LOD[methylated/not-so]=NaN;LOD_SE[methylated/not-so]=NaN;LOD_Z[methylated/not-so]=NaN;FisherP[methylated/not-so]=NaN;#C Group[methylated]=0;#Cm Group[methylated]=1;#C Group[not-so]=0;#Cm Group[not-so]=0;DP=1\tMR:GT:BC:GB:FB\t100:0/1/2/3:A=5,T=1,C=9,G=0,N=1:16:0\t0:1/2/3:A=10,T=4,C=0,G=0,N=2:16:0", buffer.toString()); */ }
From source file:org.apache.hadoop.hdfs.server.namenode.INode.java
/** * Dump the subtree starting from this inode. * @return a text representation of the tree. *//*from ww w.j a va2s . c o m*/ @VisibleForTesting public final StringBuffer dumpTreeRecursively() { final StringWriter out = new StringWriter(); dumpTreeRecursively(new PrintWriter(out, true), new StringBuilder(), Snapshot.CURRENT_STATE_ID); return out.getBuffer(); }
From source file:ddf.compression.exi.EXIEncoderTest.java
/** * Tests that the encode method converts xml into exi-compressed xml. * * @throws Exception/*from w w w . ja v a2 s . com*/ */ @Test public void testEncode() throws Exception { ByteArrayOutputStream exiStream = new ByteArrayOutputStream(); InputStream xmlStream = getClass().getResourceAsStream(TEST_FILE); EXIEncoder.encode(xmlStream, exiStream); StringWriter stringWriter = new StringWriter(); GrammarCache grammarCache; SAXTransformerFactory saxTransformerFactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); saxParserFactory.setNamespaceAware(true); TransformerHandler transformerHandler = saxTransformerFactory.newTransformerHandler(); EXIReader reader = new EXIReader(); grammarCache = new GrammarCache(null, GrammarOptions.DEFAULT_OPTIONS); reader.setGrammarCache(grammarCache); transformerHandler.setResult(new StreamResult(stringWriter)); reader.setContentHandler(transformerHandler); reader.parse(new InputSource(new ByteArrayInputStream(exiStream.toByteArray()))); XMLUnit.setNormalize(true); XMLUnit.setNormalizeWhitespace(true); InputStream stream = getClass().getResourceAsStream(TEST_FILE); Diff diff = XMLUnit.compareXML(IOUtils.toString(stream), stringWriter.getBuffer().toString()); IOUtils.closeQuietly(stream); assertTrue("The XML input file (" + TEST_FILE + ") did not match the EXI-decoded output", diff.similar()); }
From source file:com.sshtools.sshvnc.SshVncSessionPanel.java
/** * * * @param application//from w w w . jav a2 s . co m * * @throws SshToolsApplicationException */ public void init(SshToolsApplication application) throws SshToolsApplicationException { super.init(application); setLayout(new BorderLayout()); sendTimer = new javax.swing.Timer(500, this); sendTimer.setRepeats(false); receiveTimer = new javax.swing.Timer(500, this); receiveTimer.setRepeats(false); statusBar = new StatusBar(); statusBar.setUser(""); statusBar.setHost(""); statusBar.setStatusText("Disconnected"); statusBar.setConnected(false); setLayout(new BorderLayout()); // Create our terminal emulation object try { emulation = createEmulation(); } catch (IOException ioe) { throw new SshToolsApplicationException(ioe); } // Set a scrollbar for the terminal - doesn't seem to be as simple as this emulation.setBufferSize(1000); // Create our swing terminal and add it to the main frame terminal = new TerminalPanel(emulation); terminal.requestFocus(); // try { vnc = new SshVNCViewer(); // Additional connection tabs additionalTabs = new SshToolsConnectionTab[] { new VNCTab(), new VNCAdvancedTab() }; add(vnc, BorderLayout.CENTER); initActions(); } catch (Throwable t) { StringWriter sw = new StringWriter(); t.printStackTrace(new PrintWriter(sw)); IconWrapperPanel p = new IconWrapperPanel(UIManager.getIcon("OptionPane.errorIcon"), new ErrorTextBox(((t.getMessage() == null) ? "<no message supplied>" : t.getMessage()) + (debug ? ("\n\n" + sw.getBuffer().toString()) : ""))); p.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); add(p, BorderLayout.CENTER); throw new SshToolsApplicationException("Failed to start SshVNC. ", t); } }