001 package org.springframework.richclient.util.l2fprod; 002 003 import com.l2fprod.common.propertysheet.DefaultProperty; 004 import com.l2fprod.common.propertysheet.Property; 005 006 import java.util.Enumeration; 007 import java.util.Properties; 008 009 @SuppressWarnings("unchecked") 010 public class L2fProdSupport 011 { 012 013 public static Property[] makePropertyArray(Properties properties) 014 { 015 Property[] propertiesArray = new Property[properties.size()]; 016 Enumeration propertyEnum = properties.propertyNames(); 017 int i = 0; 018 019 while (propertyEnum.hasMoreElements()) 020 { 021 String name = (String) propertyEnum.nextElement(); 022 String value = properties.get(name).toString(); 023 propertiesArray[i++] = makePropertyInCategory(name, value); 024 } 025 return propertiesArray; 026 } 027 028 private static String getPropertyCategory(String name) 029 { 030 int pos = name.indexOf('.'); 031 return (pos == -1) ? name : name.substring(0, pos); 032 } 033 034 private static Property makePropertyInCategory(String name, String value) 035 { 036 String category = getPropertyCategory(name); 037 return makeProperty(category, name, value); 038 } 039 040 public static Property makeProperty(String category, String name, String value) 041 { 042 DefaultProperty prop; 043 prop = new DefaultProperty(); 044 prop.setCategory(category); 045 046 prop.setName(name); 047 prop.setDisplayName(name); 048 prop.setValue(value); 049 prop.setShortDescription(value); 050 return prop; 051 } 052 053 }