View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.xml.config;
8   
9   import org.mule.api.annotations.expression.XPath;
10  
11  import java.util.HashMap;
12  import java.util.Map;
13  
14  import org.w3c.dom.Document;
15  import org.w3c.dom.Element;
16  import org.w3c.dom.Node;
17  import org.w3c.dom.NodeList;
18  
19  public class AnnotatedComponent
20  {
21      public Map<String, Object> doStuff(
22              @XPath("/foo") Element fooDocument,
23              @XPath("/foo/bar[1] = 4") Boolean isBarValue,
24              @XPath("/foo/bar[1]") String bar)
25      {
26          Map<String, Object> map = new HashMap<String, Object>(3);
27          map.put("foo", fooDocument);
28          map.put("isBarValue", isBarValue);
29          map.put("bar", bar);
30          return map;
31      }
32  
33       public Map<String, Object> doStuff2(
34              @XPath("/foo") Document fooDocument,
35              @XPath("/foo/bar[2] = '8'") Boolean isBarValue,
36              @XPath("/foo/bar[2]") Double bar)
37      {
38          Map<String, Object> map = new HashMap<String, Object>(3);
39          map.put("foo", fooDocument);
40          map.put("isBarValue", isBarValue);
41          map.put("bar", bar);
42          return map;
43      }
44  
45      public Map<String, Object> doStuff3(
46              @XPath("/foo") Node foo,
47              @XPath("/foo/bar") NodeList barNodes)
48      {
49          Map<String, Object> map = new HashMap<String, Object>(3);
50          map.put("foo", foo);
51          map.put("bar", barNodes);
52          return map;
53      }
54  
55      public Map<String, Object> doStuff4(@XPath("/faz") Node foo)
56      {
57          Map<String, Object> map = new HashMap<String, Object>(1);
58          map.put("foo", foo);
59          return map;
60      }
61  
62      public Map<String, Object> doStuff5(@XPath(value = "/faz", optional = true) Node foo)
63      {
64          Map<String, Object> map = new HashMap<String, Object>(1);
65          map.put("foo", foo);
66          return map;
67      }
68  }