Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * @(#)KV.java		Created at 2013-7-4
   * 
   * Copyright (c) 2011-2013 azolla.org All rights reserved.
   * Azolla PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 
   */
  package org.azolla.l.ling.util;
  
  import java.util.Map;
 
The coder is very lazy for this KV class

Author(s):
sk@azolla.org
Since:
ADK1.0
 
 public final class KV
 {
     Map<StringStringmap = Maps.newHashMap();
 
     private KV()
     {
         //do nothing
     }
 
     //	public static KV ins()
     //	{
     //		return new KV();
     //	}
 
     public static KV ins(String keyString value)
     {
         return new KV().put(keyvalue);
     }
 
     public static KV ins(String keyObject o)
     {
         return new KV().put(keyo);
     }
 
     public KV put(String keyString value)
     {
         .put(keyvalue);
         return this;
     }
 
     public KV put(String keyObject o)
     {
         .put(keyo2String(o));
         return this;
     }
 
     private String o2String(Object o)
     {
         String rtn = String.valueOf(o);
 
         if(null != o && o.getClass().isArray())
         {
             // check for primitive array types because they
             // unfortunately cannot be cast to Object[]
             if(o instanceof boolean[] || o instanceof Boolean[])
             {
                 rtn = Array0.array2String((Boolean[]) o);
             }
             else if(o instanceof byte[] || o instanceof Byte[])
             {
                 rtn = Array0.array2String((Byte[]) o);
             }
             else if(o instanceof char[] || o instanceof Character[])
             {
                 rtn = Array0.array2String((Character[]) o);
             }
             else if(o instanceof short[] || o instanceof Short[])
             {
                 rtn = Array0.array2String((Short[]) o);
             }
             else if(o instanceof int[] || o instanceof Integer[])
             {
                 rtn = Array0.array2String((Integer[]) o);
             }
             else if(o instanceof long[] || o instanceof Long[])
             {
                 rtn = Array0.array2String((Long[]) o);
             }
             else if(o instanceof float[] || o instanceof Float[])
             {
                 rtn = Array0.array2String((Float[]) o);
             }
             else if(o instanceof double[] || o instanceof Double[])
             {
                 rtn = Array0.array2String((Double[]) o);
             }
             else
             {
                 rtn = Array0.array2String((Object[]) o);
             }
        }
        return rtn;
    }

    

Parameters:
separator
connector
Returns:
See also:
org.azolla.l.ling.json.Json0.object2String(java.lang.Object)
    @Deprecated
    public String toString(String separatorString connector)
    {
        separator = String.valueOf(separator);
        StringBuilder sb = new StringBuilder();
        for(Map.Entry<StringStringentry : .entrySet())
        {
            sb.append(separator).append(entry.getKey()).append(connector).append(entry.getValue());
        }
        return sb.toString().substring(separator.length());
    }
    @Override
    public String toString()
    {
        return Json0.object2String();
    }
    public static void main(String[] args)
    {
        StringBuilder sb = new StringBuilder();
        Object o = null;
        sb.append(o).append("a");
        ..println(sb.toString());
    }
New to GrepCode? Check out our FAQ X