2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

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  /*
19   * $Id: ElementBean.java 464373 2006-10-16 04:21:54Z rahul $
20   */
21  package org.apache.shale.clay.config.beans;
22  
23  import java.io.Serializable;
24  
25  /***
26   * <p>This bean represents the composition of a complex component.  The renderId
27   * uniquely sequences it within a top-level {@link ComponentBean}.</p>
28   */
29  
30  public class ElementBean extends InnerComponentBean implements Comparable, Serializable {
31  
32      /***
33       * <p>Unique id used by the Serializable interface.</p>
34       */
35      private static final long serialVersionUID = 3690760596346123828L;
36  
37      /***
38       * <p>An integer id that is used to order a nested component within it's
39       * child collection.  This id is also used a the "signature" when resolving
40       * inheritance.
41       * </p>
42       */
43      private int renderId = 0;
44  
45      /***
46       * @return a named value list of the object's state
47       */
48      public String toString() {
49          StringBuffer buff = new StringBuffer();
50          buff.append("renderId=\"").append(renderId).append("\" ").append(super.toString());
51          return buff.toString();
52      }
53  
54      /***
55       * <p>Returns an integer id that is used to order within the {@link ComponentBean} children
56       * set.</p>
57       *
58       * @return the render id
59       */
60      public int getRenderId() {
61          return renderId;
62      }
63  
64      /***
65       * <p>Sets an integer id that is used to order within the {@link ComponentBean} children
66       * set.</p>
67       *
68       * @param i render id
69       */
70      public void setRenderId(int i) {
71          renderId = i;
72      }
73  
74      /***
75       * <p>This is an override of the {@link ComponentBean} making the
76       * <code>renderId</code> the ordering identifier instead of the
77       * <code>jsfid</code>.</p>
78       *
79       * @param obj object to compare
80       * @return weight of the comparison
81       */
82      public int compareTo(Object obj) {
83          ElementBean item = (ElementBean) obj;
84          if (item.renderId < renderId) {
85              return 1;
86          } else if (item.renderId > renderId) {
87              return -1;
88          } else {
89              return 0;
90          }
91      }
92  
93  }
94