| 1 33 34 package com.icesoft.jsfmeta.util; 35 36 import java.io.IOException ; 37 import java.net.URL ; 38 39 import org.xml.sax.SAXException ; 40 41 import com.icesoft.jsfmeta.MetadataXmlParser; 42 import com.sun.rave.jsfmeta.beans.ComponentBean; 43 import com.sun.rave.jsfmeta.beans.FacesConfigBean; 44 import com.sun.rave.jsfmeta.beans.PropertyBean; 45 46 51 52 public class FilterComponentBeanProperties { 53 54 55 public FilterComponentBeanProperties(){ 56 57 } 58 59 public void init(){ 60 61 } 62 63 public static void main(String [] args) { 64 65 FilterComponentBeanProperties status = new FilterComponentBeanProperties(); 66 status.getFilterComponentProperty(); 67 } 68 69 72 public PropertyBean[] getFilterComponentProperty() { 73 74 PropertyBean[] pb = null; 75 String [] cb = null; 76 MetadataXmlParser metadataParser = new MetadataXmlParser(); 77 metadataParser.setDesign(true); 78 79 try { 80 ClassLoader classLoader = Thread.currentThread() 81 .getContextClassLoader(); 82 URL localUrl = classLoader.getResource("."); 83 String newPath = "file:" + localUrl.getPath() 84 + "./../conf/filter.properties/filter-faces-config.xml"; 85 URL url = new URL (newPath); 86 87 FacesConfigBean facesConfigBean = metadataParser.parse(url); 88 ComponentBean[] componentbeans = facesConfigBean.getComponents(); 89 cb = new String [componentbeans.length]; 90 91 for (int i = 0; i < componentbeans.length; i++) { 92 cb[i] = componentbeans[i].getComponentClass(); 93 PropertyBean[] descriptions = componentbeans[i].getProperties(); 94 95 String one = ""; 96 pb = descriptions; 97 for (int j = 0; j < pb.length; j++) { 98 99 one = one + "\n property name=" + pb[j].getPropertyName()+ " property category="+ pb[j].getCategory(); 100 } 101 } 102 } catch (IOException e) { 103 e.printStackTrace(); 104 } catch (SAXException e) { 105 e.printStackTrace(); 106 } 107 108 return pb; 109 } 110 111 112 private void filterCategory(PropertyBean propertyBean){ 113 114 PropertyBean[] filterPropertyBeans = getFilterComponentProperty(); 115 116 for(int i=0 ; i< filterPropertyBeans.length; i++){ 117 118 boolean condition = filterPropertyBeans[i].getPropertyName().equalsIgnoreCase(propertyBean.getPropertyName()); 119 if(condition){ 120 propertyBean.setCategory(filterPropertyBeans[i].getCategory()); 121 } 122 } 123 } 124 125 126 129 public void filter(ComponentBean componentBean) { 130 131 PropertyBean[] propertyBeans = null; 132 propertyBeans = componentBean.getProperties(); 133 for (int j = 0; j < propertyBeans.length; j++) { 134 135 String propertyName = propertyBeans[j].getPropertyName(); 136 String categoryName = propertyBeans[j].getCategory(); 137 138 if (categoryName != null 139 && categoryName.equalsIgnoreCase("javascript")) { 140 PropertyBean temp = propertyBeans[j]; 141 temp.setHidden(true); 142 } 143 } 144 } 145 146 149 public void filter(ComponentBean[] componentBeans) { 150 151 PropertyBean[] propertyBeans = null; 152 153 for (int i = 0; i < componentBeans.length; i++) { 154 155 componentBeans[i].getProperties(); 156 propertyBeans = componentBeans[i].getProperties(); 157 158 for (int j = 0; j < propertyBeans.length; j++) { 159 String propertyName = propertyBeans[j].getPropertyName(); 160 String categoryName = propertyBeans[j].getCategory(); 161 System.out.println("propertyName=" + propertyName 162 + " categoryName=" + categoryName); 163 } 164 } 165 } 166 167 170 public void filter(ComponentBean[] componentBeans, 171 PropertyBean[] propertyBeans) { 172 173 for (int i = 0; i < componentBeans.length; i++) { 174 componentBeans[i].getProperties(); 175 } 176 177 for (int i = 0; i < propertyBeans.length; i++) { 178 String propertyName = propertyBeans[i].getPropertyName(); 179 String categoryName = propertyBeans[i].getCategory(); 180 } 181 } 182 183 } 184 | Popular Tags |