diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2010-11-30 16:01:03 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2010-11-30 16:01:03 +0000 |
commit | ff12f54997320a2ed2d0bfec82e970455093f33a (patch) | |
tree | 4ed5fab115060a0c584c15f0d8dbf0cd74ccd137 /sca-java-2.x/trunk | |
parent | 3ef38a403a9bf8609d8a57a0d9fa7dd48ab17016 (diff) |
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
Diffstat (limited to 'sca-java-2.x/trunk')
-rw-r--r-- | sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/test/java/sample/Xutil.java | 28 |
1 files changed, 14 insertions, 14 deletions
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<String> print = new Reducer<String>() { + public static Reducer<String> print = new Reducer<String>() { 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 <T> List<T> xmap(final Mapper<T> f, final Iterable<Element> l) { + public static <T> List<T> xmap(final Mapper<T> f, final Iterable<Element> l) { final List<T> v = new ArrayList<T>(); 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<Element> xfilter(final Mapper<Boolean> f, final Iterable<Element> l) { + public static List<Element> xfilter(final Mapper<Boolean> f, final Iterable<Element> l) { final List<Element> v = new ArrayList<Element>(); for(Element e: l) if(f.map(e)) @@ -171,7 +171,7 @@ class Xutil { /** * Perform a reduction over a list of elements. */ - static <T> T xreduce(final Reducer<T> f, final T initial, final Iterable<Element> l) { + public static <T> T xreduce(final Reducer<T> f, final T initial, final Iterable<Element> 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<Boolean> select(final String name) { + public static Mapper<Boolean> select(final String name) { return new Mapper<Boolean>() { 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<Element> elems(final Node parent) { + public static Iterable<Element> elems(final Node parent) { final List<Element> l = new ArrayList<Element>(); for (Node n: children(parent)) if (n instanceof Element) |