1   /***
2    Copyright (C) 2005 The Java Community
3   
4    This program is free software; you can redistribute it and/or modify  it under
5    the terms of the GNU General Public License as published by  the Free Software
6    Foundation; either version 2 of the License, or  (at your option) any later
7    version.
8   
9    This program is distributed in the hope that it will be useful,  but WITHOUT
10   ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS
11   FOR A PARTICULAR PURPOSE. See the  GNU General Public License for more details.
12  
13   You should have received a copy of the GNU General Public License  along with
14   this program; if not, write to the Free Software  Foundation, Inc., 59 Temple
15   Place, Suite 330, Boston, MA 02111-1307 USA.
16   */
17  package org.bejug.javacareers.view;
18  
19  import java.util.Comparator;
20  
21  
22  /***
23   * @author bbr (last modified by $Author: shally $)
24   * @version $Revision: 1.5 $ - $Date: 2005/12/21 11:38:43 $
25   */
26  public class FacesComponentHolder {
27  
28      private String componentName;
29      private String page;
30      private String id;
31  
32      /***
33       * @param componentName is the name for the component
34       * @param page is the page
35       * @param id is the id
36       */
37      public FacesComponentHolder(String componentName, String page, String id) {
38          this.componentName = componentName;
39          this.page = page;
40          this.id = id;
41      }
42  
43      /***
44       * @return componentName
45       */
46      public String getComponentName() {
47          return componentName;
48      }
49  
50      /***
51       * @param componentName is the name for the component
52       */
53      public void setComponentName(String componentName) {
54          this.componentName = componentName;
55      }
56  
57      /***
58       * @return page
59       */
60      public String getPage() {
61          return page;
62      }
63  
64      /***
65       * @param page is the page
66       */
67      public void setPage(String page) {
68          this.page = page;
69      }
70  
71      /***
72       * @return the id
73       */
74      public String getId() {
75          return id;
76      }
77  
78      /***
79       * @param id to be set
80       */
81      public void setId(String id) {
82          this.id = id;
83      }
84  
85      /***
86       * @return the comparator
87       */
88      public static Comparator getIdComparator() {
89          Comparator byId = new Comparator() {
90  
91              public int compare(Object o1, Object o2) {
92                  FacesComponentHolder f1 = (FacesComponentHolder) o1;
93                  FacesComponentHolder f2 = (FacesComponentHolder) o2;
94                  String id1 = f1.getId();
95                  String id2 = f2.getId();
96                  if (id1 == null) {
97                      id1 = "noId";
98                  }
99                  if (id2 == null) {
100                     id2 = "noId";
101                 }
102 
103 
104                 return id1.compareTo(id2);
105 
106             }
107         };
108         return byId;
109 
110 
111     }
112 
113     /***
114      * @return the string representation
115      */
116     public String toString() {
117         StringBuffer buffer = new StringBuffer();
118         buffer.append("Id: ");
119    		buffer.append(id);
120         buffer.append(" -- Component: ");
121    		buffer.append(componentName);
122         buffer.append(" -- Page: ");
123         buffer.append(page);
124         return buffer.toString();
125     }
126 }
127 
128 /***
129  * $Log: FacesComponentHolder.java,v $
130  * Revision 1.5  2005/12/21 11:38:43  shally
131  * *** empty log message ***
132  *
133  * Revision 1.4  2005/12/09 10:46:57  shally
134  * Opkuis voor checkstyle en PMD
135  *
136  * Revision 1.3  2005/12/08 14:53:46  shally
137  * Opkuis voor checkstyle.
138  *
139  * Revision 1.2  2005/08/11 08:38:26  bme_jcs
140  * checkstyle errors resolved
141  *
142  * Revision 1.1  2005/07/26 14:22:04  bavo_jcs
143  * Faces Id tests
144  *
145  */