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  package org.apache.commons.jxpath;
18  
19  import java.beans.PropertyDescriptor;
20  import java.io.Serializable;
21  
22  /**
23   * JXPathBeanInfo  is similar to {@link java.beans.BeanInfo} in that it describes
24   * properties of a JavaBean class.  By default, JXPathBeanInfo classes are
25   * automatically generated by {@link JXPathIntrospector JXPathIntrospector}
26   * based on the java.beans.BeanInfo. As with JavaBeans, the user can supply an
27   * alternative implementation of JXPathBeanInfo for a custom class.  The
28   * alternative implementation is located by class name, which is the same as the
29   * name of the class it represents with the suffix "XBeanInfo".  So, for
30   * example, if you need to provide an alternative JXPathBeanInfo class for class
31   * "com.foo.Bar", write a class "com.foo.BarXBeanInfo" and make it implement the
32   * JXPathBeanInfo interface.
33   *
34   * @author Dmitri Plotnikov
35   * @version $Revision: 668329 $ $Date: 2008-06-16 23:59:48 +0200 (Mo, 16 Jun 2008) $
36   */
37  public interface JXPathBeanInfo extends Serializable {
38  
39      /**
40       * Returns true if objects of this class are treated as atomic
41       * objects which have no properties of their own.
42       * For example, {@link String} and {@link Number} are atomic.
43       * @return boolean
44       */
45      boolean isAtomic();
46  
47      /**
48       * Returns true if the objects of this class have dynamic properties
49       * (e.g. java.util.Map). If this method returns true, {@link #getPropertyDescriptors}
50       * should return null and {@link #getDynamicPropertyHandlerClass} should return
51       * a valid class name.  An object cannot have both static and dynamic
52       * properties at the same time.
53       * @return boolean
54       */
55      boolean isDynamic();
56  
57      /**
58       * Returns a list of property descriptors for the beans described by this
59       * bean info object.  Returns null for atomic beans.
60       * @return PropertyDescriptor[]
61       */
62      PropertyDescriptor[] getPropertyDescriptors();
63  
64      /**
65       * Returns a PropertyDescriptor for the specified name or null if there
66       * is no such property.
67       * @param propertyName property name
68       * @return PropertyDescriptor
69       */
70      PropertyDescriptor getPropertyDescriptor(String propertyName);
71  
72      /**
73       * For dynamic objects, returns the class implementing
74       * the {@link DynamicPropertyHandler} interface. That class can
75       * be used to access dynamic properties.
76       * @return Class
77       */
78      Class getDynamicPropertyHandlerClass();
79  }