package com.futureplatforms.kirin.dependencies;

import java.math.BigDecimal;
import java.util.Date;

import com.futureplatforms.kirin.dependencies.AsyncCallback.AsyncCallback1;
import com.google.common.io.BaseEncoding;

public abstract class Formatter {
	
	/**
	 * 
	 * @param format
	 * @param text
	 * @return Date object with values parsed from text, with default values 00:00 1 Jan 1970
	 */
	
    public abstract Date parseDate(String format, String text);
    public abstract String format(String string, Object... args);
    public abstract String formatDate(String format, Date date);
    public abstract String formatLocalisedShortTime(Date date);
    public abstract String formatLocalisedLongDateAndTime(Date date);
    public abstract String formatNumber(String format, Number number);
    public abstract String formatCurrency(String currency, BigDecimal amount);
    public abstract String urlDecode(String toDecode);
    public abstract String urlEncode(String toEncode);
    public abstract String encodeURIComponent(String str);
    public abstract byte[] hmacSHA1(String message, String passphrase);
    public abstract String sha512B64(String toEncode);
    public abstract String decryptAES(String encodedB64, String password);
    
    /**
     * Returns BASE64-Encoded PBKDF2 HMAC-SHA1
     * @param plaintext
     * @param salt
     * @param iterations
     * @param keyLenBytes
     * @param cb
     */
	public abstract void pbkdf2(String plaintext, String salt, int iterations, int keyLenBytes,
			AsyncCallback1<byte[]> cb);
}

@@ -93,16 +93,66 @@
 il.Date;
+%0Aimport java.util.Map;%0Aimport java.util.Map.Entry;
 %0A%0Aimport
@@ -224,50 +224,8 @@
 ck1;
-%0Aimport com.google.common.io.BaseEncoding;
 %0A%0Apu
@@ -1553,10 +1553,327 @@
 %5D%3E cb);%0A
+%09%0A%09public String urlEncodedForm(Map%3CString, String%3E params) %7B%0A%09%09StringBuilder sb = new StringBuilder();%0A%09%09for (Entry%3CString, String%3E entry : params.entrySet()) %7B%0A%09%09%09sb.append(entry.getKey() + %22=%22 + urlEncode(entry.getValue()) + %22&%22);%0A%09%09%7D%0A%09%09// remove last &%0A%09%09sb.setLength(sb.length() - 1);%0A%09%09return sb.toString();%0A%09%7D%0A
 %7D%0A

introduce URLEncodedForm method to Formatter