1 4 5 package com.icesoft.jsfmeta.eclipse; 6 7 import com.icesoft.jsfmeta.util.ConfigStorage; 8 import com.icesoft.jsfmeta.util.GeneratorUtil; 9 import java.util.Arrays ; 10 import java.util.HashMap ; 11 import java.util.HashSet ; 12 import java.util.Iterator ; 13 import java.util.Map ; 14 import java.util.Properties ; 15 import java.util.Set ; 16 17 public class PropertyClassNameUtil { 18 19 private Properties properties; 20 private Map propertyNameToTypeMap = new HashMap (); 21 private Map propertyClassToTypeMap = new HashMap (); 22 private Map propertyCategoryToTypeMap = new HashMap (); 23 24 public PropertyClassNameUtil(){ 25 properties = loadProperties(); 26 initMapping(); 27 } 28 29 30 public Properties loadProperties(){ 31 32 String filePath = GeneratorUtil.getWorkingFolder()+ "conf/eclipse.schema/cm_type.properties"; 33 Properties props = ConfigStorage.getInstance(filePath).loadProperties(); 34 for(Iterator iterator = props.keySet().iterator(); iterator.hasNext();){ 35 Object nextKey = iterator.next(); 36 } 37 return props; 38 } 39 40 public void initMapping(){ 41 String [] propertyNames = new String []{"style","styleClass","bgcolor","binding"}; 42 String [] propertyTypes = new String []{"CSSSTYLE","CSSCLASS","COLOR","PROPERTYBINDING"}; 43 44 for(int i=0; i< propertyNames.length; i++){ 45 propertyNameToTypeMap.put(propertyNames[i], propertyTypes[i]); 46 } 47 48 String [] propertyClasses = new String []{"com.icesoft.faces.context.effects.Effect","boolean", "java.lang.Object", "javax.faces.el.MethodBinding"}; 49 String [] propertyClassesToTypes = new String []{"METHODBINDING","BOOLEAN", "METHODBINDING","METHODBINDING" }; 50 51 for(int i=0; i< propertyClasses.length; i++){ 52 propertyClassToTypeMap.put(propertyClasses[i], propertyClassesToTypes[i]); 53 } 54 55 String [] propertyCategories = new String []{"javascript"}; 56 String [] propertyCategroiesToTypes = new String []{"JAVASCRIPT"}; 57 58 for(int i=0; i< propertyCategories.length; i++){ 59 propertyClassToTypeMap.put(propertyCategories[i], propertyCategroiesToTypes[i]); 60 } 61 62 } 63 64 private final static Set propertyClassHashSet = new HashSet (Arrays.asList( 66 new String []{ 67 "boolean","com.icesoft.faces.context.effects.Effect","int","java.lang.Object", 68 "java.lang.String","java.util.List","javax.faces.convert.Converter","javax.faces.el.MethodBinding" 69 })); 70 71 private final static Set propertyTypeHashSet = new HashSet (Arrays.asList( 73 new String []{ 74 "BOOLEAN", "COLOR","CSSCLASS", "CSSSTYLE", "ENUMERATED", 75 "JAVASCRIPT", "METHODBINDING", "NAMED-BOOLEAN", "PROPERTYBINDING", "RELATIVEPATH", "WEBPATH" 76 })); 77 78 79 public static boolean isPropertyType(String name){ 80 return propertyTypeHashSet.contains(name); 81 } 82 83 public static boolean isPropertyClass(String name){ 84 return propertyClassHashSet.contains(name); 85 } 86 87 public String getMatchedName(String propertyClassName, String propertyCategoryName, String propertyName, String propertyEditor){ 90 91 if(propertyClassName != null){ 92 propertyClassName = propertyClassName.trim(); 93 } 94 95 if(propertyCategoryName != null){ 96 propertyCategoryName = propertyCategoryName.trim(); 97 } 98 99 if(propertyName != null){ 100 propertyName = propertyName.trim(); 101 } 102 103 if((String )propertyNameToTypeMap.get(propertyName)!= null){ 104 return (String )propertyNameToTypeMap.get(propertyName); 105 } 106 107 if((String )propertyClassToTypeMap.get(propertyClassName)!= null){ 108 return (String )propertyClassToTypeMap.get(propertyClassName); 109 } 110 111 if((String )propertyCategoryToTypeMap.get(propertyCategoryName)!= null){ 112 return (String )propertyCategoryToTypeMap.get(propertyCategoryName); 113 } 114 115 if(propertyEditor != null && (String )properties.get(propertyEditor) != null){ 116 return (String )properties.get(propertyEditor); 117 } 118 119 return null; 120 } 121 122 } 123
| Popular Tags
|