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

How to use
XMLUtil
in
org.apache.activemq.artemis.utils

Best Java code snippets using org.apache.activemq.artemis.utils.XMLUtil (Showing top 20 results out of 315)

origin: wildfly/wildfly

List<Node> nodes = XMLUtil.filter(nl, toFilter);
List<Node> nodes2 = XMLUtil.filter(nl2, toFilter);
 Node n = nodes.get(i);
 Node n2 = nodes2.get(i);
 XMLUtil.assertEquivalent(n, n2);
origin: wildfly/wildfly

if ((textContent = XMLUtil.getTextContent(n)) != null && !"".equals(textContent)) {
 sb.append(textContent).append("</").append(name).append('>');
} else {
boolean hasValidChildren = false;
for (int i = 0; i < children.getLength(); i++) {
 String childToString = XMLUtil.elementToString(children.item(i));
 if (!"".equals(childToString)) {
   sb.append(childToString);
if (!hasValidChildren && (textContent = XMLUtil.getTextContent(n)) != null) {
 sb.append(textContent);
origin: wildfly/wildfly

public static void validate(final Node node, final String schemaFile) throws Exception {
 SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
 Schema schema = factory.newSchema(new URL(findResource(schemaFile).toURI().toASCIIString()));
 Validator validator = schema.newValidator();
 // validate the DOM tree
 try {
   validator.validate(new DOMSource(node));
 } catch (SAXException e) {
   ActiveMQClientLogger.LOGGER.errorOnXMLTransformInvalidConf(e);
   throw new IllegalStateException("Invalid configuration", e);
 }
}
origin: apache/activemq-artemis

@Test
public void testElementToString_1() throws Exception {
 String s = "<a b=\"something\">somethingelse</a>";
 Element e = XMLUtil.stringToElement(s);
 String tostring = XMLUtil.elementToString(e);
 Element convertedAgain = XMLUtil.stringToElement(tostring);
 XMLUtil.assertEquivalent(e, convertedAgain);
}
origin: apache/activemq-artemis

@Test
public void testEquivalent_1() throws Exception {
 String s = "<a/>";
 String s2 = "<a/>";
 XMLUtil.assertEquivalent(XMLUtil.stringToElement(s), XMLUtil.stringToElement(s2));
}
origin: apache/activemq-artemis

public Configuration parseMainConfig(final InputStream input) throws Exception {
 Reader reader = new InputStreamReader(input);
 String xml = XMLUtil.readerToString(reader);
 xml = XMLUtil.replaceSystemProps(xml);
 Element e = XMLUtil.stringToElement(xml);
 SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
 Schema schema = schemaFactory.newSchema(XMLUtil.findResource("schema/artemis-server.xsd"));
 Validator validator = schema.newValidator();
 try {
   validator.validate(new DOMSource(e));
 } catch (Exception ex) {
   ActiveMQServerLogger.LOGGER.error(ex.getMessage());
 }
 Configuration config = new ConfigurationImpl();
 parseMainConfig(e, config);
 return config;
}
origin: apache/activemq-artemis

@Test
public void testGetTextContext_4() throws Exception {
 String document = "<blah someattribute=\"somevalue\"><a></a></blah>";
 Element e = XMLUtil.stringToElement(document);
 String s = XMLUtil.getTextContent(e);
 Element subelement = XMLUtil.stringToElement(s);
 Assert.assertEquals("a", subelement.getNodeName());
}
origin: wildfly/wildfly

public static Element stringToElement(final String s) throws Exception {
 return XMLUtil.readerToElement(new StringReader(s));
}
origin: apache/activemq-artemis

public void readConfiguration() throws Exception {
 URL url;
 url = Thread.currentThread().getContextClassLoader().getResource(configurationUrl);
 if (url == null) {
   // trying a different classloader now
   url = getClass().getClassLoader().getResource(configurationUrl);
 }
 if (url == null) {
   // The URL is outside of the classloader. Trying a pure url now
   url = new URL(configurationUrl);
 }
 // create a reader
 try (Reader reader = new InputStreamReader(url.openStream())) {
   String xml = XMLUtil.readerToString(reader);
   //replace any system props
   xml = XMLUtil.replaceSystemProps(xml);
   Element e = XMLUtil.stringToElement(xml);
   //iterate around all the deployables
   for (Deployable deployable : deployables.values()) {
    String root = deployable.getRootElement();
    NodeList children = e.getElementsByTagName(root);
    //if the root element exists then parse it
    if (root != null && children.getLength() > 0) {
      Node item = children.item(0);
      XMLUtil.validate(item, deployable.getSchema());
      deployable.parse((Element) item, url);
    }
   }
 }
}
origin: wildfly/wildfly

/**
* Note: if the content is another element or set of elements, it returns a string representation
* of the hierarchy.
*/
public static String getTextContent(final Node n) {
 if (n.hasChildNodes()) {
   StringBuffer sb = new StringBuffer();
   NodeList nl = n.getChildNodes();
   for (int i = 0; i < nl.getLength(); i++) {
    sb.append(XMLUtil.elementToString(nl.item(i)));
    if (i < nl.getLength() - 1) {
      sb.append('\n');
    }
   }
   String s = sb.toString();
   if (s.length() != 0) {
    return s;
   }
 }
 return n.getTextContent();
}
origin: apache/activemq-artemis

public void parseConfiguration(final InputStream input) throws Exception {
 Reader reader = new InputStreamReader(input);
 String xml = XMLUtil.readerToString(reader);
 xml = XMLUtil.replaceSystemProps(xml);
 Element e = XMLUtil.stringToElement(xml);
 // only parse elements from <jms>
 NodeList children = e.getElementsByTagName(CONFIGURATION_SCHEMA_ROOT_ELEMENT);
 if (children.getLength() > 0) {
   parseConfiguration(children.item(0));
 }
}
origin: org.apache.activemq.rest/artemis-rest

String xml = XMLUtil.readerToString(reader);
xml = XMLUtil.replaceSystemProps(xml);
configuration = (MessageServiceConfiguration) jaxb.createUnmarshaller().unmarshal(new StringReader(xml));
origin: apache/activemq-artemis

/**
* test does not pass in eclipse (because it can not find artemis-configuration.xsd).
* It runs fine on the CLI with the proper env setting.
*/
@Test
public void testMinimalConfiguration() throws Exception {
 String xml = "<core xmlns='urn:activemq:core'>" + "</core>";
 Element element = XMLUtil.stringToElement(xml);
 Assert.assertNotNull(element);
 XMLUtil.validate(element, "schema/artemis-configuration.xsd");
}
origin: apache/activemq-artemis

@Test
public void testReplaceSystemProperties() {
 String before = "<configuration>\n" + "   <test name=\"${sysprop1}\">content1</test>\n" + "   <test name=\"test2\">content2</test>\n" + "   <test name=\"test3\">content3</test>\n" + "   <test name=\"test4\">${sysprop2}</test>\n" + "   <test name=\"test5\">content5</test>\n" + "   <test name=\"test6\">content6</test>\n" + "</configuration>";
 String after = "<configuration>\n" + "   <test name=\"test1\">content1</test>\n" + "   <test name=\"test2\">content2</test>\n" + "   <test name=\"test3\">content3</test>\n" + "   <test name=\"test4\">content4</test>\n" + "   <test name=\"test5\">content5</test>\n" + "   <test name=\"test6\">content6</test>\n" + "</configuration>";
 System.setProperty("sysprop1", "test1");
 System.setProperty("sysprop2", "content4");
 String replaced = XMLUtil.replaceSystemProps(before);
 Assert.assertEquals(after, replaced);
}
origin: apache/activemq-artemis

@Test
public void testElementToString_4() throws Exception {
 String s = "<a><![CDATA[somedata]]></a>";
 Element e = XMLUtil.stringToElement(s);
 String tostring = XMLUtil.elementToString(e);
 Element convertedAgain = XMLUtil.stringToElement(tostring);
 XMLUtil.assertEquivalent(e, convertedAgain);
}
origin: apache/activemq-artemis

@Test
public void testEquivalent_4() throws Exception {
 String s = "<a attr1=\"val1\" attr2=\"val2\"/>";
 String s2 = "<a attr2=\"val2\" attr1=\"val1\"/>";
 XMLUtil.assertEquivalent(XMLUtil.stringToElement(s), XMLUtil.stringToElement(s2));
}
origin: apache/activemq-artemis

@Test
public void testGetTextContext_3() throws Exception {
 String document = "<blah someattribute=\"somevalue\"><a/></blah>";
 Element e = XMLUtil.stringToElement(document);
 String s = XMLUtil.getTextContent(e);
 Element subelement = XMLUtil.stringToElement(s);
 Assert.assertEquals("a", subelement.getNodeName());
}
origin: wildfly/wildfly

public static Element urlToElement(final URL url) throws Exception {
 return XMLUtil.readerToElement(new InputStreamReader(url.openStream()));
}
origin: apache/activemq-artemis

url = configFile.toURI().toURL();
reader = new InputStreamReader(url.openStream());
String xml = XMLUtil.readerToString(reader);
xml = XMLUtil.replaceSystemProps(xml);
Element e = XMLUtil.stringToElement(xml);
if (root != null && children.getLength() > 0) {
  Node item = children.item(0);
  XMLUtil.validate(item, ((FileConfiguration) configuration).getSchema());
  ((FileConfiguration) configuration).parse((Element) item, url);
origin: apache/activemq-artemis

/**
* Note: if the content is another element or set of elements, it returns a string representation
* of the hierarchy.
*/
public static String getTextContent(final Node n) {
 if (n.hasChildNodes()) {
   StringBuffer sb = new StringBuffer();
   NodeList nl = n.getChildNodes();
   for (int i = 0; i < nl.getLength(); i++) {
    sb.append(XMLUtil.elementToString(nl.item(i)));
    if (i < nl.getLength() - 1) {
      sb.append('\n');
    }
   }
   String s = sb.toString();
   if (s.length() != 0) {
    return s;
   }
 }
 return n.getTextContent();
}
org.apache.activemq.artemis.utilsXMLUtil

Most used methods

  • assertEquivalent
  • elementToString
  • findResource
  • getTextContent
    Note: if the content is another element or set of elements, it returns a string representation of th
  • filter
  • readerToElement
  • replaceSystemProps
  • stringToElement
  • readerToString
  • validate
  • parseBoolean
  • parseDouble
  • parseBoolean,
  • parseDouble,
  • parseInt,
  • parseLong,
  • stripCDATA

Popular in Java

  • Making http post requests using okhttp
  • getSharedPreferences (Context)
  • setContentView (Activity)
  • runOnUiThread (Activity)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • JFrame (javax.swing)
  • JLabel (javax.swing)
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Top PhpStorm 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