boolean needSpace = false;
    public static String encodeAttrs(String[] args, Map extraArgs) {        StringBuffer sb = new StringBuffer();        boolean needSpace = false;        for (int i=0; i < args.length; i += 2) {            if (needSpace) sb.append(' '); else needSpace = true;            encodeArg(sb, args[i], args[i+1]);        }        if (extraArgs != null) {            for (Iterator it=extraArgs.entrySet().iterator(); it.hasNext();) {                if (needSpace) sb.append(' '); else needSpace = true;                                Map.Entry entry = (Entry) it.next();                String name = (String) entry.getKey();                Object v = entry.getValue();                if (v == null) {                    encodeArg(sb, name, "");                } else if (v instanceof String) {                    encodeArg(sb, name, (String)v);                } else if (v instanceof String[]) {                    String values[] = (String[]) v;                    for (int i=0; i < values.length; i++) {                        encodeArg(sb, name, values[i]);                    }                }            }        }        return sb.toString();    }