KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nextime > ion > frontoffice > bean > TypeBean


1 /*
2  * ĻON content management system.
3  * Copyright (C) 2002 Guillaume Bort(gbort@msn.com). All rights reserved.
4  *
5  * Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
6  * Copyright 2000-2002 (C) Intalio Inc. All Rights Reserved.
7  *
8  * ĻON is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * ĻON core framework, ĻON content server, ĻON backoffice, ĻON frontoffice
14  * and ĻON admin application are parts of ĻON and are distributed under
15  * same terms of licence.
16  *
17  *
18  * ĻON includes software developed by the Apache Software Foundation (http://www.apache.org/)
19  * and software developed by the Exolab Project (http://www.exolab.org).
20  *
21  * ĻON is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  */

26
27 package org.nextime.ion.frontoffice.bean;
28
29 import java.io.InputStream JavaDoc;
30 import java.util.Hashtable JavaDoc;
31 import java.util.StringTokenizer JavaDoc;
32 import java.util.Vector JavaDoc;
33
34 import org.apache.struts.digester.Digester;
35
36 public class TypeBean {
37     
38     protected String JavaDoc _name;
39     protected String JavaDoc _template;
40     protected String JavaDoc _cache;
41     protected String JavaDoc _jsp;
42     protected String JavaDoc _description;
43     protected Vector JavaDoc _properties = new Vector JavaDoc();
44     protected Vector JavaDoc _publicationsTypes = new Vector JavaDoc();
45     
46     protected static Vector JavaDoc _types = new Vector JavaDoc();
47     
48     public String JavaDoc getName() {
49         return _name;
50     }
51     
52     public String JavaDoc getJsp() {
53         return _jsp;
54     }
55     
56     public String JavaDoc getTemplate() {
57         return _template;
58     }
59     
60     public String JavaDoc getCache() {
61         return _cache;
62     }
63     
64     public void setCache(String JavaDoc value) {
65         _cache = value;
66     }
67     
68     public void setJsp(String JavaDoc value) {
69         _jsp = value;
70     }
71     
72     protected static TypeBean getBean(String JavaDoc template) {
73         for( int i=0;i<_types.size();i++){
74             if( ((TypeBean)_types.get(i)).getTemplate().equals(template) ) {
75                 return (TypeBean)_types.get(i);
76             }
77         }
78         return null;
79     }
80     
81     public String JavaDoc getDescription() {
82         return _description;
83     }
84     
85     public Vector JavaDoc getPublicationTypes() {
86         return _publicationsTypes;
87     }
88     
89     public void setPublicationTypes(String JavaDoc types) {
90         StringTokenizer JavaDoc tokenizer = new StringTokenizer JavaDoc(types,", ");
91         while( tokenizer.hasMoreTokens() ) {
92             _publicationsTypes.add( tokenizer.nextToken() );
93         }
94     }
95     
96     public void setDescription(String JavaDoc description) {
97         _description = description;
98     }
99     
100     public void setName(String JavaDoc name) {
101         _name = name;
102     }
103     
104     public void setTemplate(String JavaDoc template) {
105         _template = template;
106     }
107     
108     public Vector JavaDoc getProperties() {
109         return _properties;
110     }
111     
112     public PropertyBean getProperty(String JavaDoc name) {
113         for( int i=0; i<_properties.size(); i++ ) {
114             PropertyBean p = (PropertyBean)_properties.get(i);
115             if( name.equals(p.getName()) ) {
116                 return p;
117             }
118         }
119         return null;
120     }
121     
122     public int getPropertiesNumber() {
123         return _properties.size();
124     }
125     
126     public void addProperty( PropertyBean p ) {
127         _properties.add(p);
128     }
129     
130     public Vector JavaDoc getItems() {
131         return _types;
132     }
133     
134     public static void addBean( TypeBean bean ) {
135         _types.add(bean);
136     }
137     
138     protected static TypeBean parse( InputStream JavaDoc in ) throws Exception JavaDoc {
139         TypeBean bean = new TypeBean();
140         Digester digester = new Digester();
141         digester.push(bean);
142         digester.setValidating(false);
143         digester.addObjectCreate("templates-description/template","org.nextime.ion.frontoffice.bean.TypeBean");
144         digester.addSetProperties("templates-description/template");
145         digester.addSetNext("templates-description/template","addBean");
146         digester.addCallMethod("templates-description/template/description","setDescription",0);
147         digester.addCallMethod("templates-description/template/publication-types","setPublicationTypes",0);
148         digester.addObjectCreate("templates-description/template/property","org.nextime.ion.frontoffice.bean.PropertyBean");
149         digester.addSetProperties("templates-description/template/property");
150         digester.addSetTop("templates-description/template/property","setSectionType");
151         digester.parse(in);
152         return bean;
153     }
154 }
155
Popular Tags