package com.jxml.quick.editors;

import com.jxml.quick.*;
import java.beans.PropertyEditorSupport;

/**
 * A PropertyEditor for binary data (byte[]).
 * <p>Quick 1.1
 */
public class Base64Editor extends PropertyEditorSupport 
{
    public String getAsText() 
    {
        byte[] v=(byte[])getValue();
        return new String(Base64.binToAsc(v));
    }

    public void setAsText(String value) 
        throws IllegalArgumentException 
    {
	try
	{
	    setValue(Base64.ascToBin(value.getBytes()));
	}
	catch (Invalid64Exception e)
	{
	    throw new IllegalArgumentException(e.toString());
	}
    }
}
