View Javadoc

1   /* $Id: ObjectTestImpl.java 1102402 2011-05-12 18:03:26Z simonetripodi $
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one or more
4    * contributor license agreements.  See the NOTICE file distributed with
5    * this work for additional information regarding copyright ownership.
6    * The ASF licenses this file to You under the Apache License, Version 2.0
7    * (the "License"); you may not use this file except in compliance with
8    * the License.  You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package org.apache.commons.digester3.xmlrules;
20  
21  import java.util.ArrayList;
22  import java.util.HashMap;
23  
24  /**
25   * Test harness object for holding results of digestion.
26   * 
27   * @author David H. Martin - Initial Contribution
28   * @author Scott Sanders - Added ASL, removed external dependencies
29   * @author Tim O'Brien - Added bean property to test bean property setter rule
30   */
31  public class ObjectTestImpl
32  {
33  
34      private ArrayList<Object> children = new ArrayList<Object>();
35  
36      private String value = "";
37  
38      private Long longValue = new Long( -1L );
39  
40      private String property = "";
41  
42      private HashMap<String, String> mapValue = new HashMap<String, String>();
43  
44      private boolean pushed = false;
45  
46      public ObjectTestImpl()
47      {
48      }
49  
50      @Override
51      public String toString()
52      {
53          String str = value;
54          for ( Object o : children )
55          {
56              str += " " + o;
57          }
58          return str;
59      }
60  
61      public void add( Object o )
62      {
63          children.add( o );
64      }
65  
66      public void setValue( String val )
67      {
68          value = val;
69      }
70  
71      public void setLongValue( Long val )
72      {
73          longValue = val;
74      }
75  
76      public Long getLongValue()
77      {
78          return longValue;
79      }
80  
81      public void setStringValue( String val )
82      {
83      }
84  
85      public boolean isPushed()
86      {
87          return pushed;
88      }
89  
90      public void push()
91      {
92          pushed = true;
93      }
94  
95      public void setMapValue( String name, String value )
96      {
97          this.mapValue.put( name, value );
98      }
99  
100     public String getMapValue( String name )
101     {
102         return this.mapValue.get( name );
103     }
104 
105     public String getProperty()
106     {
107         return property;
108     }
109 
110     public void setProperty( String pProperty )
111     {
112         property = pProperty;
113     }
114 }