Tabnine Logo
XMLWriter
Code IndexAdd Tabnine to your IDE (free)

How to use
XMLWriter
in
uk.org.ponder.xml

Best Java code snippets using uk.org.ponder.xml.XMLWriter (Showing top 20 results out of 315)

origin: uk.org.ponder.rsf/rsf-core-ponderutilcore

public static void dumpAttribute(String name, String value, XMLWriter xmlw) {
 xmlw.writeRaw(" ").writeRaw(name).writeRaw("=\"");
 xmlw.write(value);
 xmlw.writeRaw("\"");
}
origin: uk.org.ponder.rsf/rsf-core-ponderutilcore

 public static void dumpStackTraceXML(Throwable t, PrintOutputStream pos) {
  XMLWriter xmlw = new XMLWriter(pos);
  xmlw.write(t.getMessage() + "\n");
  StackTraceElement[] elements = t.getStackTrace();
  for (int i = 0; i < elements.length; ++ i) {
   xmlw.write(elements[i] + "\n");
  }
 }
}
origin: uk.org.ponder.rsf/rsf-core-ponderutilcore

/**
 * Writes the supplied string to the wrapped stream with the specified indent
 * level.
 * 
 * @param tag
 *          The string to be written.
 * @param nestinglevel
 *          The multiplier for the <code>INDENT_WIDTH</code>, giving the
 *          number of spaces to be written before the supplied string.
 */
public void writeRaw(String tag, int nestinglevel) {
 indent(nestinglevel, internalwriter);
 internalwriter.print(tag);
 // Logger.println(tag, Logger.DEBUG_SUBATOMIC);
}
origin: uk.org.ponder.rsf/rsf-core-ponderutilcore

 /**
  * Copies text from input to output, converting newlines into XHTML
  * &lt;br/&gt; elements. The supplied streams WILL be closed!
  */
 public void copyReader(Reader r, PrintOutputStream pos) {
  BufferedReader br = new BufferedReader(r);
  XMLWriter xmlw = new XMLWriter(pos);
  try {
   while (true) {
    String line = br.readLine();
   
    if (line == null)
     break;
    xmlw.write(line);
// TODO: make some kind of "XMLFilterWriter" architecture if necessary        
//        writeEncodeLinks(xmlw, line);
    xmlw.writeRaw("<br/>");
   }
  }
  catch (Throwable t) {
   throw UniversalRuntimeException.accumulate(t,
     "Error rendering text as HTML");
  }
  finally {
   StreamCloseUtil.closeReader(r);
   pos.close();
  }
 }
 
origin: uk.org.ponder.rsf/rsf-core

public static void dumpHiddenField(UIParameter todump, XMLWriter xmlw) {
 xmlw.writeRaw("<input type=\"hidden\" ");
 boolean isvirtual = todump instanceof UIBinding && ((UIBinding)todump).virtual;
 XMLUtil.dumpAttribute(isvirtual? "id" : "name", todump.name, xmlw);
 XMLUtil.dumpAttribute("value", todump.value, xmlw);
 xmlw.writeRaw(" />\n");
}
origin: uk.org.ponder.rsf/rsf-core-ponderutilcore

this.xmlw = new XMLWriter(os);
if (indentlevel == 0) {
 xmlw.writeDeclaration();
   break; // GLOBAL EXIT POINT
  top = getDeSAXingObject();
  xmlw.closeTag(top.stashedclosingtag, getIndent(), writtenchild);
  continue;
xmlw.closeTag(roottagname, indentlevel, top.writtenchild);
 xmlw.close();
origin: uk.org.ponder.rsf/rsf-core-ponderutilcore

/**
 * Writes the supplied data to the wrapped stream, escaping all mandatory
 * XML/HTML entities, being &amp;, &lt;, &gt;, &quot; and &#39;. &#39; is
 * escaped to &amp;#39; since HTML 4.0 does not define the &amp;apos; entity
 * and does not plan to.
 * 
 * @param towrite
 *          The string to be written.
 */
public void write(String towrite) {
 char[] array = (towrite == null ? "null" : towrite).toCharArray();
 write(array, 0, array.length);
}
origin: uk.org.ponder.rsf/rsf-core

public void render(PrintOutputStream pos) {
 IDassigner = new IDAssigner(debugrender ? ContentTypeInfo.ID_FORCE
   : contenttypeinfo.IDStrategy);
 // Add and remove the flyweight immediately around "resolveBranches" - instances of it
 // will be dynamically "invented" around the tree wherever there are messages
 messageFlyweight = new MessageFlyweight(view.viewroot);
 branchmap = BranchResolver.resolveBranches(globalmap, view.viewroot,
   roott.rootlump, idrewritemap);
 view.viewroot.remove(messageFlyweight.rsfMessages);    
 messagelump = (XMLLump) branchmap.get(messageFlyweight.rsfMessages);
 
 collectContributions();
 messagetargets = MessageTargetter.targetMessages(branchmap, view,
   messagelist, globalmessagetarget);
 String declaration = contenttypeinfo.get().declaration;
 if (declaration != null)
  pos.print(declaration);
 this.pos = pos;
 this.xmlw = new XMLWriter(pos);
 rsc = new RenderSystemContext(debugrender, view, pos, xmlw, IDassigner,
   collected, idrewritemap);
 rendereddeadletters = false;
 if (debugrender) {
  debugGlobalTargets();
 }
 renderRecurse(view.viewroot, roott.rootlump,
   roott.lumps[roott.roottagindex]);
}
origin: uk.org.ponder.rsf/rsf-core-ponderutilcore

 /**
  * Closes this XMLWriter object, in effect flushing it and making it unusable
  * for any further write operations.
  * <p>
  * Closing this does not close the underlying input stream!
  */
 public void close() {
  if (internalwriter != null) {
   try {
    flush();
   }
   catch (Throwable t) {
    Logger.println("Unhandled exception closing XML Writer: " + t,
      Logger.DEBUG_SEVERE);
    // internalwriter.close();
    internalwriter = null;
   }
  }
 }
}
origin: sakaiproject/sakai

public int render(TagRenderContext trc) {
  if (headmatter == null) {
    return NullRewriteSCR.instance.render(trc);
  } else {
    if (RenderUtil.isFirstSCR(trc.uselump, getName())) {
      trc.xmlw.writeRaw(headmatter);
    }
    return ComponentRenderer.LEAF_TAG;
  }
}
origin: uk.org.ponder.rsf/rsf-core

public void renderDebugMessage(RenderSystemContext rsc, String string) {
 rsc.pos.print("<span style=\"background-color:#FF466B;color:white;padding:1px;\">");
 rsc.xmlw.write(string);
 rsc.pos.print("</span><br/>");
}

origin: uk.org.ponder.rsf/rsf-core-ponderutilcore

private void appendAttr(String attrname, Object attrvalue) {
 xmlw.writeRaw(" ");
 xmlw.writeRaw(attrname); // attribute names may not contain escapes
 xmlw.writeRaw("=\"");
 xmlw.write(mappingcontext.generalLeafParser.render(attrvalue));
 xmlw.writeRaw("\"");
}
origin: uk.org.ponder.sakairsf/sakairsf

public int render(TagRenderContext trc) {
 if (headmatter == null) {
  return NullRewriteSCR.instance.render(trc);
 }
 else {
  if (RenderUtil.isFirstSCR(trc.uselump, getName())) {
   trc.xmlw.writeRaw(headmatter);
  }
  return ComponentRenderer.LEAF_TAG;
 }
}
origin: uk.org.ponder.rsf/rsf-core-ponderutilcore

/** A slow method for XML-encoding text
 * 
 * @param toencode text to encode
 * @return encoded text
 */
public static String encode(String toencode) {
 StringPOS pos = new StringPOS();
 XMLWriter xmlw = new XMLWriter(pos);
 xmlw.write(toencode);
 return pos.toString();
}

origin: uk.org.ponder.rsf/rsf-core

public void replaceBody(String value) {
 XMLUtil.dumpAttributes(attrcopy, xmlw);
 if (!iselide) {
  pos.print(">");
 }
 xmlw.write(value);
 closeTag();
}
origin: uk.org.ponder.rsf/rsf-core-ponderutilcore

public void closeTag(String tag, int nestinglevel, boolean writtenchildren) {
 if (writtenchildren) {
  indent(nestinglevel, internalwriter);
  internalwriter.print("</");
  internalwriter.print(tag);
  internalwriter.print(">");
 }
 else {
  internalwriter.print("/>");
 }
 if (nestinglevel >= 0) {
  internalwriter.print("\n");
 }
}
origin: uk.org.ponder.rsf/rsf-core-ponderutilcore

public static void writeEncodeLinks(XMLWriter xmlw, String line) {
 int linkpos = line.indexOf("://");
 if (linkpos == -1) {
  xmlw.write(line);
  return;
 }
 int backpos = linkpos - 1;
 for (; backpos >= 0; --backpos) {
  if (Character.isWhitespace(line.charAt(backpos))) break;
 }
 ++ backpos;
 if (backpos == linkpos - 1) { // require non-empty protocol
  xmlw.write(line);
  return;
 }
 
 int frontpos = linkpos + 3;
 for (; frontpos < line.length(); ++ frontpos) {
  if (Character.isWhitespace(line.charAt(backpos))) break;
 }
 String url = line.substring(backpos, frontpos);
 xmlw.write(line.substring(0, backpos));
 xmlw.writeRaw("<a target=\"_top\" href=\"");
 xmlw.write(url);
 xmlw.writeRaw("\">");
 xmlw.write(url);
 xmlw.writeRaw("</a>");
 xmlw.write(line.substring(frontpos));
}
origin: uk.org.ponder.rsf/rsf-core

public static String handleFatalErrorStatic(Throwable t,
  PrintOutputStream pos) {
 // We may have such a fatal misconfiguration that we can't even rely on
 // IKAT to format this error message
 Logger.log.fatal("Completely fatal error populating view root", t);
 pos.println("<html><head><title>Internal Error</title></head></body><pre>");
 pos.println(ERROR_STRING);
 StringWriter todump = new StringWriter();
 t.printStackTrace(new PrintWriter(todump));
 XMLWriter xml = new XMLWriter(pos);
 xml.write(todump.toString());
 pos.println("</pre></body></html>");
 pos.close();
 return HANDLED;
}
origin: uk.org.ponder.rsf/rsf-core

  trc.pos.print("<br/>");
 trc.xmlw.write(value.stringAt(i));
if (value == null)
 value = Constants.NULL_STRING;
xmlw.write(value);
if (select.selected.contains(value)) {
 pos.print("\" selected=\"selected");
xmlw.write(names[i]);
pos.print("</option>\n");
lastgroup = thisgroup;
origin: uk.org.ponder.rsf/rsf-core-ponderutilcore

SerialContext oldtop = getDeSAXingObject();
if (oldtop != null && !oldtop.writtenchild) {
 xmlw.writeRaw(">");
 if (indentlevel != COMPACT_MODE) {
  xmlw.writeRaw("\n");
xmlw.writeRaw("<" + childtagname, getIndent());
String genericdata = null;
if (child instanceof GenericSAX) {
 xmlw.writeRaw(">", 0);
  xmlw.write(mappingcontext.generalLeafParser.render(child));
 xmlw.writeRaw("</" + childtagname + ">\n", 0);
 top = null;
uk.org.ponder.xmlXMLWriter

Javadoc

A utility class to write XML data either raw or with XML/HTML entity escaping. An XMLWriter wraps either an OutputStream or a Writer, and supplies methods with similar names to Writer which escape all mandatory XML/HTML entities, and methods named with suffix Raw which write the data without transformation.

Most used methods

  • writeRaw
    Writes the supplied data to the wrapped stream without conversion.
  • <init>
  • write
    Writes the supplied data to the wrapped stream, escaping all mandatory XML entities, being &, <, >,
  • close
    Closes this XMLWriter object, in effect flushing it and making it unusable for any further write ope
  • closeTag
  • flush
    Flushes the wrapped stream.
  • indent
  • writeDeclaration
    Writes a default declaration to the wrapped stream.
  • writeSlow

Popular in Java

  • Running tasks concurrently on multiple threads
  • scheduleAtFixedRate (ScheduledExecutorService)
  • onCreateOptionsMenu (Activity)
  • startActivity (Activity)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now