1 26 27 package org.nextime.ion.frontoffice.bean; 28 29 import java.io.InputStream ; 30 import java.util.Hashtable ; 31 import java.util.StringTokenizer ; 32 import java.util.Vector ; 33 34 import org.apache.struts.digester.Digester; 35 36 public class TypeBean { 37 38 protected String _name; 39 protected String _template; 40 protected String _cache; 41 protected String _jsp; 42 protected String _description; 43 protected Vector _properties = new Vector (); 44 protected Vector _publicationsTypes = new Vector (); 45 46 protected static Vector _types = new Vector (); 47 48 public String getName() { 49 return _name; 50 } 51 52 public String getJsp() { 53 return _jsp; 54 } 55 56 public String getTemplate() { 57 return _template; 58 } 59 60 public String getCache() { 61 return _cache; 62 } 63 64 public void setCache(String value) { 65 _cache = value; 66 } 67 68 public void setJsp(String value) { 69 _jsp = value; 70 } 71 72 protected static TypeBean getBean(String 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 getDescription() { 82 return _description; 83 } 84 85 public Vector getPublicationTypes() { 86 return _publicationsTypes; 87 } 88 89 public void setPublicationTypes(String types) { 90 StringTokenizer tokenizer = new StringTokenizer (types,", "); 91 while( tokenizer.hasMoreTokens() ) { 92 _publicationsTypes.add( tokenizer.nextToken() ); 93 } 94 } 95 96 public void setDescription(String description) { 97 _description = description; 98 } 99 100 public void setName(String name) { 101 _name = name; 102 } 103 104 public void setTemplate(String template) { 105 _template = template; 106 } 107 108 public Vector getProperties() { 109 return _properties; 110 } 111 112 public PropertyBean getProperty(String 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 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 in ) throws Exception { 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 |