From ff12f54997320a2ed2d0bfec82e970455093f33a Mon Sep 17 00:00:00 2001 From: slaws Date: Tue, 30 Nov 2010 16:01:03 +0000 Subject: Open up this utility so it can be used from the async implementation provider git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1040594 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/test/java/sample/Xutil.java | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'sca-java-2.x/trunk') diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sample/Xutil.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sample/Xutil.java index ce89f9dd8c..264ce7fc85 100644 --- a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sample/Xutil.java +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sample/Xutil.java @@ -44,22 +44,22 @@ import org.w3c.dom.NodeList; /** * Just for fun, a little bit of magic code and utility functions to help work with XML DOM. */ -class Xutil { - interface NodeBuilder { +public class Xutil { + public interface NodeBuilder { Node build(Document doc); } /** * Convert a name and a list of children to a document element. */ - static Element xdom(String ns, String name, final NodeBuilder... nodes) { + public static Element xdom(String ns, String name, final NodeBuilder... nodes) { return (Element)elem(ns, name, nodes).build(db.newDocument()); } /** * Convert a name and children to an element. */ - static NodeBuilder elem(final String uri, final String n, final NodeBuilder... nodes) { + public static NodeBuilder elem(final String uri, final String n, final NodeBuilder... nodes) { return new NodeBuilder() { public Node build(Document doc) { final Element e = doc.createElementNS(uri, n); @@ -70,14 +70,14 @@ class Xutil { }; } - static NodeBuilder elem(final String n, final NodeBuilder... nodes) { + public static NodeBuilder elem(final String n, final NodeBuilder... nodes) { return elem(null, n, nodes); } /** * Convert a string to a text element. */ - static NodeBuilder text(final String t) { + public static NodeBuilder text(final String t) { return new NodeBuilder() { public Node build(final Document doc) { return doc.createTextNode(t); @@ -100,7 +100,7 @@ class Xutil { */ static TransformerFactory trf = TransformerFactory.newInstance(); - static String xml(final Node node) { + public static String xml(final Node node) { try { final StreamResult r = new StreamResult(new StringWriter()); trf.newTransformer().transform(new DOMSource(node), r); @@ -115,7 +115,7 @@ class Xutil { */ private static XPathFactory xpf = XPathFactory.newInstance(); - static String xpath(final String expr, final Node node) { + public static String xpath(final String expr, final Node node) { final XPath xp = xpf.newXPath(); try { return (String)xp.evaluate(expr, node, XPathConstants.STRING); @@ -141,7 +141,7 @@ class Xutil { T reduce(final T accum, final Element e); } - static Reducer print = new Reducer() { + public static Reducer print = new Reducer() { public String reduce(String accum, Element e) { return accum + e.getTextContent(); } @@ -150,7 +150,7 @@ class Xutil { /** * Apply a mapper to a list of elements. */ - static List xmap(final Mapper f, final Iterable l) { + public static List xmap(final Mapper f, final Iterable l) { final List v = new ArrayList(); for(Element e: l) v.add(f.map(e)); @@ -160,7 +160,7 @@ class Xutil { /** * Apply a filter to a list of elements. */ - static List xfilter(final Mapper f, final Iterable l) { + public static List xfilter(final Mapper f, final Iterable l) { final List v = new ArrayList(); for(Element e: l) if(f.map(e)) @@ -171,7 +171,7 @@ class Xutil { /** * Perform a reduction over a list of elements. */ - static T xreduce(final Reducer f, final T initial, final Iterable l) { + public static T xreduce(final Reducer f, final T initial, final Iterable l) { T accum = initial; for(Element e: l) accum = f.reduce(accum, e); @@ -181,7 +181,7 @@ class Xutil { /** * Return a filter that selects elements by name. */ - static Mapper select(final String name) { + public static Mapper select(final String name) { return new Mapper() { public Boolean map(Element e) { return name.equals(e.getLocalName()); @@ -192,7 +192,7 @@ class Xutil { /** * Return the child elements of a node. */ - static Iterable elems(final Node parent) { + public static Iterable elems(final Node parent) { final List l = new ArrayList(); for (Node n: children(parent)) if (n instanceof Element) -- cgit v1.2.3