List of usage examples for org.apache.commons.collections MapIterator getKey
Object getKey();
next()
. From source file:com.projity.field.StaticSelect.java
public String toString() { MapIterator i = stringMap.mapIterator(); StringBuffer result = new StringBuffer(); while (i.hasNext()) { i.next();//w w w .j av a2s. c o m result.append("[key]" + i.getKey() + " [value]" + i.getValue() + "\n"); } return result.toString(); }
From source file:AIR.Common.Web.WebValueCollection.java
public String toString(boolean urlencoded, Map<String, Object> excludeKeys) { int count = this.size(); if (count == 0) { return ""; }//from w w w.j a v a 2 s . c o m StringBuilder builder = new StringBuilder(); MapIterator iter = this.mapIterator(); while (iter.hasNext()) { String key = (String) iter.getKey(); if (((excludeKeys == null) || (key == null)) || (excludeKeys.get(key) == null)) { String str3; if (urlencoded) { try { byte[] utf8Bytes = key.getBytes("UTF8"); key = new String(utf8Bytes, "UTF8"); } catch (UnsupportedEncodingException e) { _logger.error(e.getMessage()); key = null; } } String str2 = !StringUtils.isEmpty(key) ? (key + "=") : ""; if (builder.length() > 0) { builder.append('&'); } Object value = iter.getValue(); if (value instanceof List) { List list = (List) value; int num3 = (list != null) ? list.size() : 0; if (num3 == 1) { builder.append(str2); str3 = list.get(0).toString(); if (urlencoded) { try { byte[] utf8Bytes = str3.getBytes("UTF8"); str3 = new String(utf8Bytes, "UTF8"); } catch (UnsupportedEncodingException e) { _logger.error(e.getMessage()); str3 = null; } } builder.append(str3); } else if (num3 == 0) { builder.append(str2); } else { for (int j = 0; j < num3; j++) { if (j > 0) { builder.append('&'); } builder.append(str2); str3 = list.get(j).toString(); if (urlencoded) { try { byte[] utf8Bytes = str3.getBytes("UTF8"); str3 = new String(utf8Bytes, "UTF8"); } catch (UnsupportedEncodingException e) { _logger.error(e.getMessage()); str3 = null; } } builder.append(str3); } } } else { builder.append(str2); str3 = value.toString(); if (urlencoded) { try { byte[] utf8Bytes = str3.getBytes("UTF8"); str3 = new String(utf8Bytes, "UTF8"); } catch (UnsupportedEncodingException e) { _logger.error(e.getMessage()); str3 = null; } } builder.append(str3); } } } return builder.toString(); }