FileDocCategorySizeDatePackage
SystemProps.javaAPI DocGlassfish v2 API3748Fri May 04 22:32:14 BST 2007com.sun.enterprise.util.diagnostics

SystemProps

public class SystemProps extends Object
author
bnevins
version

Fields Summary
Constructors Summary
private SystemProps()

	
Methods Summary
public static java.util.Listget()

		Properties p = System.getProperties();
		// these 2 lines woul;d be nice -- but it's case-sensitive...
		//Map sortedMap = new TreeMap(p);
		//Set sortedSet = sortedMap.entrySet();
		Set		set = p.entrySet();
		List	list = new ArrayList(set);
		Collections.sort(list, new Comparator()
		{
			public int compare(Object o1, Object o2)
			{
				Map.Entry me1 = (Map.Entry)o1;
				Map.Entry me2 = (Map.Entry)o2;
				
				return ((String)me1.getKey()).compareToIgnoreCase((String)me2.getKey());
			}
		});
		return list;
	
public static voidmain(java.lang.String[] args)

		System.out.println(toStringStatic());
	
public static java.lang.StringtoStringStatic()

		int				longestKey	= 0;
		List			list		= get();
		StringBuffer	sb			= new StringBuffer();

		for(Iterator it = list.iterator(); it.hasNext(); )
		{
			Map.Entry entry = (Map.Entry)it.next();
			int len = ((String)entry.getKey()).length();

			if(len > longestKey)
				longestKey = len;
		}

		longestKey += 1;

		for(Iterator it = list.iterator(); it.hasNext(); )
		{
			Map.Entry entry = (Map.Entry)it.next();
			sb.append(StringUtils.padRight((String)entry.getKey(), longestKey));
			sb.append("= ");
			sb.append((String)entry.getValue());
			sb.append("\n");
		}
		
		return sb.toString();