Coverage Report - org.seasar.teeda.core.EnvironmentInfo
 
Classes in this File Line Coverage Branch Coverage Complexity
EnvironmentInfo
0%
0/25
0%
0/10
2.667
 
 1  
 /*
 2  
  * Copyright 2004-2011 the Seasar Foundation and the Others.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 15  
  */
 16  
 package org.seasar.teeda.core;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.Enumeration;
 20  
 import java.util.HashMap;
 21  
 import java.util.Iterator;
 22  
 import java.util.List;
 23  
 import java.util.Map;
 24  
 import java.util.Properties;
 25  
 
 26  
 /**
 27  
  * @author shot
 28  
  */
 29  
 public class EnvironmentInfo {
 30  
 
 31  0
     private EnvironmentInfo() {
 32  0
     }
 33  
 
 34  
     public static List getEnvironmentInfo() {
 35  0
         List list = new ArrayList();
 36  0
         final Properties properties = System.getProperties();
 37  0
         int length = 0;
 38  0
         Map map = new HashMap();
 39  0
         for (Enumeration e = properties.propertyNames(); e.hasMoreElements();) {
 40  0
             String key = (String) e.nextElement();
 41  0
             String value = null;
 42  0
             if (key.length() > length) {
 43  0
                 length = key.length();
 44  
             }
 45  0
             Object object = properties.get(key);
 46  0
             value = object.toString();
 47  0
             map.put(key, value);
 48  
         }
 49  0
         for (Iterator itr = map.entrySet().iterator(); itr.hasNext();) {
 50  0
             Map.Entry entry = (Map.Entry) itr.next();
 51  0
             String key = (String) entry.getKey();
 52  0
             if (key.length() < length) {
 53  0
                 key = key + appendBlank(length - key.length());
 54  
             }
 55  0
             list.add(key + " : " + entry.getValue());
 56  
         }
 57  0
         return list;
 58  
     }
 59  
 
 60  
     private static String appendBlank(int len) {
 61  0
         StringBuffer buf = new StringBuffer();
 62  0
         for (int i = 0; i < len; i++) {
 63  0
             buf.append(" ");
 64  
         }
 65  0
         return buf.toString();
 66  
     }
 67  
 }