KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > model > repository > RepositoryMetaData


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.verge.mvc.model.repository;
8
9
10 import java.util.Map JavaDoc;
11
12 import javax.servlet.http.HttpServletRequest JavaDoc;
13
14 import com.inversoft.beans.BeanException;
15 import com.inversoft.verge.mvc.MVCConstants;
16 import com.inversoft.verge.mvc.MVCException;
17 import com.inversoft.verge.mvc.MVCRegistry;
18 import com.inversoft.verge.mvc.model.AbstractMetaData;
19 import com.inversoft.verge.mvc.model.ModelHandler;
20 import com.inversoft.verge.repository.RepositoryBean;
21 import com.inversoft.verge.repository.RepositoryBeanProperty;
22
23
24 /**
25  * <p>
26  * This class is the meta data for the repository items.
27  * </p>
28  *
29  * @author Brian Pontarelli
30  * @since 2.0
31  * @version 2.0
32  */

33 public class RepositoryMetaData extends AbstractMetaData {
34     
35     private RepositoryBean repositoryBean;
36     private RepositoryBeanProperty repositoryBeanProperty;
37     
38
39     /**
40      * Constructor for RepositoryMetaData.
41      */

42     public RepositoryMetaData(String JavaDoc id, String JavaDoc property) {
43         super(id, property);
44     }
45
46     /**
47      * Constructor for RepositoryMetaData.
48      */

49     public RepositoryMetaData(String JavaDoc definition) throws MVCException {
50         super(definition);
51     }
52
53
54     /**
55      * Sets the id of this model
56      *
57      * @param id The id
58      */

59     public void setID(String JavaDoc id) {
60         this.id = id;
61     }
62     
63     /**
64      * Sets the property of this model
65      *
66      * @param property The name of the property of this model
67      */

68     public void setProperty(String JavaDoc property) {
69         this.property = property;
70     }
71
72     /**
73      * Returns null because the repository model does not use ExtraParams
74      *
75      * @return null
76      */

77     public Map JavaDoc getExtraParams() {
78         return null;
79     }
80
81     /**
82      * Creates a RepositoryBean from the information in this meta data
83      *
84      * @return A new RepositoryBean
85      */

86     public RepositoryBean createRepositoryBean(HttpServletRequest JavaDoc request)
87     throws MVCException {
88         
89         if (repositoryBean != null) {
90             return repositoryBean;
91         }
92
93         try {
94             repositoryBean = new RepositoryBean(id, request);
95             return repositoryBean;
96         } catch (BeanException be) {
97             throw new MVCException(be);
98         }
99     }
100
101     /**
102      * Creates a RepositoryBeanProperty from the information in this meta data
103      *
104      * @return A new RepositoryBeanProperty
105      */

106     public RepositoryBeanProperty createRepositoryBeanProperty(
107             HttpServletRequest JavaDoc request)
108     throws MVCException {
109
110         if (repositoryBeanProperty != null) {
111             return repositoryBeanProperty;
112         }
113
114         try {
115             repositoryBeanProperty = new RepositoryBeanProperty(id, property,
116                 request);
117             return repositoryBeanProperty;
118         } catch (BeanException be) {
119             throw new MVCException(be);
120         }
121     }
122
123     /**
124      * Returns the instance of the RepositoryModelHandler class. This is the
125      * handler that uses this MetaData
126      *
127      * @return The instance of the RepositoryModelHandler class from the
128      * MVCRegistry
129      */

130     public ModelHandler getModelHandler() {
131         return MVCRegistry.lookupModelHandler(MVCConstants.REPOSITORY_NAME);
132     }
133
134     /**
135      * Returns repository
136      *
137      * @return repository
138      */

139     public String JavaDoc getModelSystem() {
140         return MVCConstants.REPOSITORY_NAME;
141     }
142 }
Popular Tags