Java Code Examples for java.io.CharArrayWriter#close()
The following examples show how to use
java.io.CharArrayWriter#close() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Parser.java From Tomcat8-Source-Read with MIT License | 6 votes |
private String parseScriptText(String tx) { CharArrayWriter cw = new CharArrayWriter(); int size = tx.length(); int i = 0; while (i < size) { char ch = tx.charAt(i); if (i + 2 < size && ch == '%' && tx.charAt(i + 1) == '\\' && tx.charAt(i + 2) == '>') { cw.write('%'); cw.write('>'); i += 3; } else { cw.write(ch); ++i; } } cw.close(); return cw.toString(); }
Example 2
Source File: Parser.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
private String parseScriptText(String tx) { CharArrayWriter cw = new CharArrayWriter(); int size = tx.length(); int i = 0; while (i < size) { char ch = tx.charAt(i); if (i + 2 < size && ch == '%' && tx.charAt(i + 1) == '\\' && tx.charAt(i + 2) == '>') { cw.write('%'); cw.write('>'); i += 3; } else { cw.write(ch); ++i; } } cw.close(); return cw.toString(); }
Example 3
Source File: Parser.java From tomcatsrc with Apache License 2.0 | 6 votes |
private String parseScriptText(String tx) { CharArrayWriter cw = new CharArrayWriter(); int size = tx.length(); int i = 0; while (i < size) { char ch = tx.charAt(i); if (i + 2 < size && ch == '%' && tx.charAt(i + 1) == '\\' && tx.charAt(i + 2) == '>') { cw.write('%'); cw.write('>'); i += 3; } else { cw.write(ch); ++i; } } cw.close(); return cw.toString(); }
Example 4
Source File: Parser.java From packagedrone with Eclipse Public License 1.0 | 6 votes |
private String parseScriptText(String tx) { CharArrayWriter cw = new CharArrayWriter(); int size = tx.length(); int i = 0; while (i < size) { char ch = tx.charAt(i); if (i+2 < size && ch == '%' && tx.charAt(i+1) == '\\' && tx.charAt(i+2) == '>') { cw.write('%'); cw.write('>'); i += 3; } else { cw.write(ch); ++i; } } cw.close(); return cw.toString(); }
Example 5
Source File: JspReader.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * Constructor: same as above constructor but with initialized reader * to the file given. * * @param ctxt The compilation context * @param fname The file name * @param reader A reader for the JSP source file * @param err The error dispatcher * * @throws JasperException If an error occurs parsing the JSP file */ public JspReader(JspCompilationContext ctxt, String fname, InputStreamReader reader, ErrorDispatcher err) throws JasperException { this.context = ctxt; this.err = err; try { CharArrayWriter caw = new CharArrayWriter(); char buf[] = new char[1024]; for (int i = 0 ; (i = reader.read(buf)) != -1 ;) caw.write(buf, 0, i); caw.close(); current = new Mark(this, caw.toCharArray(), fname); } catch (Throwable ex) { ExceptionUtils.handleThrowable(ex); log.error("Exception parsing file ", ex); err.jspError("jsp.error.file.cannot.read", fname); } finally { if (reader != null) { try { reader.close(); } catch (Exception any) { if(log.isDebugEnabled()) { log.debug("Exception closing reader: ", any); } } } } }
Example 6
Source File: JspReader.java From Tomcat8-Source-Read with MIT License | 5 votes |
String getText(Mark start, Mark stop) { Mark oldstart = mark(); reset(start); CharArrayWriter caw = new CharArrayWriter(); while (!markEquals(stop)) { caw.write(nextChar()); } caw.close(); setCurrent(oldstart); return caw.toString(); }
Example 7
Source File: AntProjectModule.java From netbeans with Apache License 2.0 | 5 votes |
private boolean verifyWriterCorrect() throws Exception { final String IDENTITY_XSLT_WITH_INDENT = "<xsl:stylesheet version='1.0' " + // NOI18N "xmlns:xsl='http://www.w3.org/1999/XSL/Transform' " + // NOI18N "xmlns:xalan='http://xml.apache.org/xslt' " + // NOI18N "exclude-result-prefixes='xalan'>" + // NOI18N "<xsl:output method='xml' indent='yes' xalan:indent-amount='4'/>" + // NOI18N "<xsl:template match='@*|node()'>" + // NOI18N "<xsl:copy>" + // NOI18N "<xsl:apply-templates select='@*|node()'/>" + // NOI18N "</xsl:copy>" + // NOI18N "</xsl:template>" + // NOI18N "</xsl:stylesheet>"; // NOI18N String data = "<root xmlns='root'/>"; // NOI18N Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(data))); doc.getDocumentElement().appendChild(doc.createElementNS("child", "child")); // NOI18N Transformer t = TransformerFactory.newInstance().newTransformer( new StreamSource(new StringReader(IDENTITY_XSLT_WITH_INDENT))); Source source = new DOMSource(doc); CharArrayWriter output = new CharArrayWriter(); Result result = new StreamResult(output); t.transform(source, result); output.close(); String text = output.toString(); return text.indexOf("\"child\"") != (-1) || text.indexOf("'child'") != (-1); // NOI18N }
Example 8
Source File: JspReader.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
String getText(Mark start, Mark stop) throws JasperException { Mark oldstart = mark(); reset(start); CharArrayWriter caw = new CharArrayWriter(); while (!markEquals(stop)) { caw.write(nextChar()); } caw.close(); setCurrent(oldstart); return caw.toString(); }
Example 9
Source File: JspReader.java From tomcatsrc with Apache License 2.0 | 5 votes |
String getText(Mark start, Mark stop) throws JasperException { Mark oldstart = mark(); reset(start); CharArrayWriter caw = new CharArrayWriter(); while (!markEquals(stop)) { caw.write(nextChar()); } caw.close(); setCurrent(oldstart); return caw.toString(); }
Example 10
Source File: JspReader.java From packagedrone with Eclipse Public License 1.0 | 5 votes |
String getText(Mark start, Mark stop) throws JasperException { Mark oldstart = mark(); reset(start); CharArrayWriter caw = new CharArrayWriter(); while (!stop.equals(mark())) caw.write(nextChar()); caw.close(); reset(oldstart); return caw.toString(); }
Example 11
Source File: AbstractCreatePlan.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
protected ExecutionPlanMessage sendMessage() throws StandardException, SQLException, IOException { LanguageConnectionContext lcc = ds.getLanguageConnectionContext(); Set<DistributedMember> members = GemFireXDUtils.getGfxdAdvisor() .adviseOperationNodes(null); final InternalDistributedMember myId = Misc.getGemFireCache().getMyId(); members.remove(myId); final ExecutionPlanMessage msg = new ExecutionPlanMessage( lcc.getCurrentSchemaName(), ds.getQueryID(), xmlForm, embedXslFileName, Misc.getGemFireCache().getDistributedSystem(), members); // local plan first. CharArrayWriter out = new CharArrayWriter(); try { processPlan(out, false); char[] lc = out.toCharArray(); if (lc != null && lc.length > 0) { if (GemFireXDUtils.TracePlanGeneration) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_PLAN_GENERATION, this + " adding local result " + String.valueOf(lc)); } msg.addResult(lc); } } finally { out.close(); } if (members.size() > 0) { if (GemFireXDUtils.TracePlanGeneration) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_PLAN_GENERATION, "sending execution plan message for " + ds.getQueryID()); } InternalDistributedSystem ids = Misc.getDistributedSystem(); msg.send(ids, ids.getDM(), msg.getReplyProcessor(), true, false); if (GemFireXDUtils.TracePlanGeneration) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_PLAN_GENERATION, "processing results from remote nodes for " + ds.getQueryID()); } } return msg; }
Example 12
Source File: CreateResultSet.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
@Override void processPlan(CharArrayWriter out, boolean isLocalPlanExtracted) throws SQLException, IOException { // query node plan if(!ds.isRemote() && !ds.isDerbyActivation()) { createBaseInfo(out); createScatterInfo(out); createBaseIterationInfo(out); createOtherIterationInfo(out); } else { /*if( !createBaseResponseInfo(out) ) { // no possibility of local execution as well. return; } createMsgReceiveAndResultSendInfo(out);*/ } // to avoid recursion further. if (!isLocalPlanExtracted) { BasicUUID locallyExecutedId = new BasicUUID(ds.getQueryID()); // for derby activation, without this flag, local plan will be captured. if (!ds.isDerbyActivation()) { locallyExecutedId.setLocallyExecuted(1); } if (SanityManager.DEBUG) { if (GemFireXDUtils.TracePlanGeneration) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_PLAN_GENERATION, "Now determining locally Executed Plan if any for " + ds.getQueryID() + " with local stmtUUID=" + locallyExecutedId.toString()); } } CharArrayWriter tmpXML = new CharArrayWriter(); new CreateXML(ds.getClone(locallyExecutedId.toString()), true, XMLForms.none, null) .processPlan(tmpXML, true); if (SanityManager.DEBUG) { if (GemFireXDUtils.TracePlanGeneration) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_PLAN_GENERATION, "CreateResultSet: Got Local Plan as : " + tmpXML.size() + " data " + tmpXML.toString()); } } if(tmpXML.size() > 0) { Element e = CreateXML.transformToXML(tmpXML.toCharArray()); final List<Element> el = new ArrayList<Element> (); el.add(e); out.write(String.valueOf(Misc.serializeXMLAsCharArr(el, "vanilla_text.xsl"))); } tmpXML.close(); /*new CreateResultSet(ds.getClone(locallyExecutedId.toString()), true) .processPlan(out, true);*/ } }
Example 13
Source File: AbstractCreatePlan.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
protected ExecutionPlanMessage sendMessage() throws StandardException, SQLException, IOException { LanguageConnectionContext lcc = ds.getLanguageConnectionContext(); Set<DistributedMember> members = GemFireXDUtils.getGfxdAdvisor() .adviseOperationNodes(null); final InternalDistributedMember myId = Misc.getGemFireCache().getMyId(); members.remove(myId); final ExecutionPlanMessage msg = new ExecutionPlanMessage( lcc.getCurrentSchemaName(), ds.getQueryID(), xmlForm, embedXslFileName, Misc.getGemFireCache().getDistributedSystem(), members); // local plan first. CharArrayWriter out = new CharArrayWriter(); try { processPlan(out, false); char[] lc = out.toCharArray(); if (lc != null && lc.length > 0) { if (GemFireXDUtils.TracePlanGeneration) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_PLAN_GENERATION, this + " adding local result " + String.valueOf(lc)); } msg.addResult(lc); } } finally { out.close(); } if (members.size() > 0) { if (GemFireXDUtils.TracePlanGeneration) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_PLAN_GENERATION, "sending execution plan message for " + ds.getQueryID()); } InternalDistributedSystem ids = Misc.getDistributedSystem(); msg.send(ids, ids.getDM(), msg.getReplyProcessor(), true, false); if (GemFireXDUtils.TracePlanGeneration) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_PLAN_GENERATION, "processing results from remote nodes for " + ds.getQueryID()); } } return msg; }
Example 14
Source File: CreateResultSet.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
@Override void processPlan(CharArrayWriter out, boolean isLocalPlanExtracted) throws SQLException, IOException { // query node plan if(!ds.isRemote() && !ds.isDerbyActivation()) { createBaseInfo(out); createScatterInfo(out); createBaseIterationInfo(out); createOtherIterationInfo(out); } else { /*if( !createBaseResponseInfo(out) ) { // no possibility of local execution as well. return; } createMsgReceiveAndResultSendInfo(out);*/ } // to avoid recursion further. if (!isLocalPlanExtracted) { BasicUUID locallyExecutedId = new BasicUUID(ds.getQueryID()); // for derby activation, without this flag, local plan will be captured. if (!ds.isDerbyActivation()) { locallyExecutedId.setLocallyExecuted(1); } if (SanityManager.DEBUG) { if (GemFireXDUtils.TracePlanGeneration) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_PLAN_GENERATION, "Now determining locally Executed Plan if any for " + ds.getQueryID() + " with local stmtUUID=" + locallyExecutedId.toString()); } } CharArrayWriter tmpXML = new CharArrayWriter(); new CreateXML(ds.getClone(locallyExecutedId.toString()), true, XMLForms.none, null) .processPlan(tmpXML, true); if (SanityManager.DEBUG) { if (GemFireXDUtils.TracePlanGeneration) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_PLAN_GENERATION, "CreateResultSet: Got Local Plan as : " + tmpXML.size() + " data " + tmpXML.toString()); } } if(tmpXML.size() > 0) { Element e = CreateXML.transformToXML(tmpXML.toCharArray()); final List<Element> el = new ArrayList<Element> (); el.add(e); out.write(String.valueOf(Misc.serializeXMLAsCharArr(el, "vanilla_text.xsl"))); } tmpXML.close(); /*new CreateResultSet(ds.getClone(locallyExecutedId.toString()), true) .processPlan(out, true);*/ } }
Example 15
Source File: JspReader.java From packagedrone with Eclipse Public License 1.0 | 4 votes |
/** * Push a file (and its associated Stream) on the file stack. THe * current position in the current file is remembered. */ private void pushFile(String file, String encoding, InputStreamReader reader) throws JasperException, FileNotFoundException { // Register the file String longName = file; int fileid = registerSourceFile(longName); if (fileid == -1) { err.jspError("jsp.error.file.already.registered", file); } currFileId = fileid; try { CharArrayWriter caw = new CharArrayWriter(); char buf[] = new char[1024]; for (int i = 0 ; (i = reader.read(buf)) != -1 ;) caw.write(buf, 0, i); caw.close(); if (current == null) { current = new Mark(this, caw.toCharArray(), fileid, getFile(fileid), master, encoding); } else { current.pushStream(caw.toCharArray(), fileid, getFile(fileid), longName, encoding); } } catch (Throwable ex) { log.log(Level.SEVERE, "Exception parsing file ", ex); // Pop state being constructed: popFile(); err.jspError("jsp.error.file.cannot.read", file); } finally { if (reader != null) { try { reader.close(); } catch (Exception any) {} } } }