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

How to use
DomUtils
in
com.nuecho.rivr.core.util

Best Java code snippets using com.nuecho.rivr.core.util.DomUtils (Showing top 20 results out of 315)

origin: nuecho/rivr

public static Document createDocument(String rootElementTagName) {
  Document document = createDocument();
  Element rootElement = document.createElement(rootElementTagName);
  document.appendChild(rootElement);
  return document;
}
origin: nuecho/rivr

public static Element addBlockElement(Element formElement) {
  return DomUtils.appendNewElement(formElement, BLOCK_ELEMENT);
}
origin: nuecho/rivr

public static void createScript(Element parent, String script) {
  Element scriptElement = DomUtils.appendNewElement(parent, SCRIPT_ELEMENT);
  DomUtils.appendNewText(scriptElement, script);
}
origin: nuecho/rivr

public static String writeToString(Node node) throws IOException {
  LSSerializer xmlSerializer = getSerializer();
  StringWriter stringWriter = new StringWriter();
  LSOutput destination = DOM_IMPLEMENTATION.createLSOutput();
  destination.setCharacterStream(stringWriter);
  try {
    xmlSerializer.write(node, destination);
  } catch (LSException exception) {
    throw new IOException("Error while writing document to output stream.", exception);
  }
  return stringWriter.toString();
}
origin: nuecho/rivr

public XmlDocumentServletResponseContent(Document document, String contentType) throws IOException {
  ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
  writeToOutputStream(document, byteArrayOutputStream, Encoding.UTF_8);
  mContent = byteArrayOutputStream.toByteArray();
  mContentType = contentType;
}
origin: nuecho/rivr

public static void addXmlNodeProperty(JsonObjectBuilder builder, String propertName, String item, Node node) {
  try {
    builder.add(propertName, DomUtils.writeToString(node));
  } catch (IOException exception) {
    builder.add(propertName,
          "Exception occurred during serialization of "
              + item
              + ": "
              + StringUtils.getAllMessages(exception));
  }
}
origin: nuecho/rivr

public static void renderInlineStringGrammar(Element grammarElement, InlineStringGrammar inlineStringGrammar) {
  DomUtils.appendNewCData(grammarElement, inlineStringGrammar.getSource());
  setAttribute(grammarElement, BASE_ATTRIBUTE, inlineStringGrammar.getBase());
  setAttribute(grammarElement, XML_LANGUAGE_ATTRIBUTE, inlineStringGrammar.getLanguage());
  setAttribute(grammarElement, ROOT_ATTRIBUTE, inlineStringGrammar.getRoot());
  setAttribute(grammarElement, TAG_FORMAT_ATTRIBUTE, inlineStringGrammar.getTagFormat());
  setAttribute(grammarElement, VERSION_ATTRIBUTE, inlineStringGrammar.getVersion());
}
origin: nuecho/rivr

public static void writeToOutputStream(Node node, OutputStream outputStream, Encoding encoding) throws IOException {
  LSSerializer xmlSerializer = getSerializer();
  LSOutput destination = DOM_IMPLEMENTATION.createLSOutput();
  destination.setByteStream(outputStream);
  destination.setEncoding(encoding.getId());
  try {
    xmlSerializer.write(node, destination);
  } catch (LSException exception) {
    throw new IOException("Error while writing document to output stream.", exception);
  }
}
origin: nuecho/rivr

private void processRootDocument(HttpServletRequest request, HttpServletResponse response) throws ServletException,
    IOException {
  try {
    Document rootDocument = mRootDocumentFactory.getDocument(request);
    response.setContentType(VOICE_XML_CONTENT_TYPE);
    DomUtils.writeToOutputStream(rootDocument, response.getOutputStream(), Encoding.UTF_8);
  } catch (VoiceXmlDocumentRenderingException exception) {
    throw new ServletException("Error while rendering root document.", exception);
  }
}
origin: nuecho/rivr

public static void createGotoSubmit(Element parent) {
  Element gotoElement = DomUtils.appendNewElement(parent, GOTO_ELEMENT);
  gotoElement.setAttribute(NEXT_ATTRIBUTE, "#" + SUBMIT_FORM_ID);
}
origin: nuecho/rivr

@Override
protected void fillVoiceXmlDocument(Document document, Element formElement, VoiceXmlDialogueContext dialogueContext)
    throws VoiceXmlDocumentRenderingException {
  addVariables(formElement, mVariables);
  Element blockElement = DomUtils.appendNewElement(formElement, BLOCK_ELEMENT);
  if (mCode != null) {
    Element scriptElement = DomUtils.appendNewElement(blockElement, SCRIPT_ELEMENT);
    DomUtils.appendNewText(scriptElement, mCode);
  }
  StringBuffer scriptBuffer = new StringBuffer();
  scriptBuffer.append(RIVR_SCOPE_OBJECT + ".addValueResult({");
  boolean first = true;
  for (Entry<String, String> entry : mVariables) {
    if (!first) {
      scriptBuffer.append(", ");
    } else {
      first = false;
    }
    scriptBuffer.append("\"");
    scriptBuffer.append(entry.getKey());
    scriptBuffer.append("\": ");
    scriptBuffer.append("dialog.");
    scriptBuffer.append(entry.getKey());
  }
  scriptBuffer.append("});");
  createScript(blockElement, scriptBuffer.toString());
  createGotoSubmit(blockElement);
}
origin: nuecho/rivr

public static Element createVoiceXmlDocumentRoot(String language) {
  Document document = DomUtils.createDocument(VXML_ELEMENT);
  Element vxmlElement = document.getDocumentElement();
  vxmlElement.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI,
                XMLConstants.XMLNS_ATTRIBUTE,
                VOICEXML_NAMESPACE);
  vxmlElement.setAttribute(VERSION_ATTRIBUTE, "2.1");
  setAttribute(vxmlElement, XML_LANGUAGE_ATTRIBUTE, language);
  return vxmlElement;
}
origin: nuecho/rivr

public static void createGotoFatalHandler(Element parent) {
  Element gotoElement = DomUtils.appendNewElement(parent, GOTO_ELEMENT);
  gotoElement.setAttribute(NEXT_ATTRIBUTE, "#" + FATAL_ERROR_HANDLER_FORM_ID);
}
origin: nuecho/rivr

if (audioItem instanceof AudioFile) {
  AudioFile audioFile = (AudioFile) audioItem;
  Element audioElement = DomUtils.appendNewElement(promptElement, AUDIO_ELEMENT);
      lastItemWasText = false;
    } else {
      DomUtils.appendNewText(audioElement, alternate.getText());
      lastItemWasText = true;
  } else {
    String spaceIfRequired = lastItemWasText ? " " : "";
    DomUtils.appendNewText(promptElement, spaceIfRequired + speechSynthesis.getText());
    lastItemWasText = true;
  Element breakElement = DomUtils.appendNewElement(promptElement, BREAK_ELEMENT);
  setDurationAttribute(breakElement, TIME_ATTRIBUTE, pause.getDuration());
  lastItemWasText = false;
} else if (audioItem instanceof Mark) {
  Mark mark = (Mark) audioItem;
  Element markElement = DomUtils.appendNewElement(promptElement, MARK_ELEMENT);
  markElement.setAttribute(NAME_ATTRIBUTE, mark.getName());
  lastItemWasText = false;
origin: nuecho/rivr

public static void createAssignation(Element parent, String variableName, String expression) {
  Element assingElement = DomUtils.appendNewElement(parent, ASSIGN_ELEMENT);
  assingElement.setAttribute(NAME_ATTRIBUTE, variableName);
  assingElement.setAttribute(EXPR_ATTRIBUTE, expression);
}
origin: nuecho/rivr

public static Element createForm(Document document) {
  Element vxmlElement = document.getDocumentElement();
  Element formElement = DomUtils.appendNewElement(vxmlElement, FORM_ELEMENT);
  formElement.setAttribute(ID_ATTRIBUTE, FORM_ID);
  return formElement;
}
origin: nuecho/rivr

public static void createVarElement(Element parent, String name, String expr) {
  Element varElement = DomUtils.appendNewElement(parent, VAR_ELEMENT);
  varElement.setAttribute(NAME_ATTRIBUTE, name);
  if (expr != null) {
    setAttribute(varElement, EXPR_ATTRIBUTE, expr);
  }
}
origin: nuecho/rivr

public static void addProperty(Element parent, String propertyName, String propertyValue) {
  Assert.notNull(propertyName, "propertyName");
  if (propertyValue != null) {
    Element propertyElement = DomUtils.appendNewElement(parent, PROPERTY_ELEMENT);
    propertyElement.setAttribute(NAME_ATTRIBUTE, propertyName);
    propertyElement.setAttribute(VALUE_ELEMENT, propertyValue);
  }
}
origin: nuecho/rivr

@Override
protected void fillVoiceXmlDocument(Document document, Element formElement, VoiceXmlDialogueContext dialogueContext)
    throws VoiceXmlDocumentRenderingException {
  Element blockElement = DomUtils.appendNewElement(formElement, BLOCK_ELEMENT);
  Element submitElement = DomUtils.appendNewElement(blockElement, SUBMIT_ELEMENT);
  VoiceXmlDomUtil.setAttribute(submitElement, VoiceXmlDomUtil.NEXT_ATTRIBUTE, mUri);
  if (mFetchConfiguration != null) {
    VoiceXmlDomUtil.applyDocumentFetchConfiguration(submitElement, dialogueContext);
  }
}
origin: nuecho/rivr

@Override
protected void fillVoiceXmlDocument(Document document, Element formElement, VoiceXmlDialogueContext dialogueContext)
    throws VoiceXmlDocumentRenderingException {
  Element blockElement = DomUtils.appendNewElement(formElement, BLOCK_ELEMENT);
  Element exitElement = document.createElement(EXIT_ELEMENT);
  if (mVariables != null) {
    addNamelist(blockElement, exitElement, mVariables);
  } else if (mExpression != null) {
    exitElement.setAttribute(EXPR_ATTRIBUTE, mExpression);
  }
  blockElement.appendChild(exitElement);
}
com.nuecho.rivr.core.utilDomUtils

Javadoc

XML DOM manipulation utility class.

Most used methods

  • createDocument
  • appendNewCData
  • appendNewElement
  • appendNewText
  • getSerializer
  • writeToOutputStream
  • writeToString

Popular in Java

  • Reading from database using SQL prepared statement
  • getContentResolver (Context)
  • setRequestProperty (URLConnection)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Best plugins for Eclipse
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