View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.commons.jxpath;
19  
20  import java.util.ArrayList;
21  import java.util.Collections;
22  import java.util.HashMap;
23  import java.util.List;
24  import java.util.Map;
25  
26  import org.apache.commons.jxpath.xml.DocumentContainer;
27  import org.w3c.dom.Document;
28  import org.w3c.dom.Element;
29  
30  /**
31   * Mixed model test bean: Java, collections, map, DOM, Container.
32   */
33  public class TestMixedModelBean {
34  
35      private final String string;
36      private final TestBean bean;
37      private final Container container;
38      private final Document document;
39      private final Element element;
40      private final Map map;
41      private final List list;
42      private int[][] matrix;
43  
44      public TestMixedModelBean() {
45          string = "string";
46          bean = new TestBean();
47          map = new HashMap();
48          list = new ArrayList();
49          container = new DocumentContainer(getClass().getResource("Vendor.xml"));
50          document = (Document) container.getValue();
51          element = document.getDocumentElement();
52          map.put("string", string);
53          map.put("bean", bean);
54          map.put("map", map);
55          map.put("list", list);
56          map.put("document", document);
57          map.put("element", element);
58          map.put("container", container);
59          list.add(string);
60          list.add(bean);
61          list.add(map);
62          list.add(new ArrayList(Collections.singletonList("string2")));
63          list.add(document);
64          list.add(element);
65          list.add(container);
66          matrix = new int[1][];
67          matrix[0] = new int[1];
68          matrix[0][0] = 3;
69      }
70  
71      public TestBean getBean() {
72          return bean;
73      }
74  
75      public Container getContainer() {
76          return container;
77      }
78  
79      public Document getDocument() {
80          return document;
81      }
82  
83      public Element getElement() {
84          return element;
85      }
86  
87      public List getList() {
88          return list;
89      }
90  
91      public Map getMap() {
92          return map;
93      }
94  
95      public int[][] getMatrix() {
96          return matrix;
97      }
98  
99      public String getString() {
100         return string;
101     }
102 
103     public void setMatrix(final int[][] matrix) {
104         this.matrix = matrix;
105     }
106 }