View Javadoc

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