X-Git-Url: http://git.nikiroo.be/?p=nikiroo-utils.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fserial%2FSerialUtils.java;h=a1105a90d441352d71fa51faf5d56f8294f35318;hp=decf57525fb30336ab00dee5be5bb2952d5f8196;hb=f4053377fa15da2f11e82955bfab86e673fa371c;hpb=451f434bd60a354ae5928f5da36b76f24b7b423b diff --git a/src/be/nikiroo/utils/serial/SerialUtils.java b/src/be/nikiroo/utils/serial/SerialUtils.java index decf575..a1105a9 100644 --- a/src/be/nikiroo/utils/serial/SerialUtils.java +++ b/src/be/nikiroo/utils/serial/SerialUtils.java @@ -7,6 +7,7 @@ import java.lang.reflect.Array; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Modifier; +import java.net.URL; import java.util.HashMap; import java.util.Map; import java.util.UnknownFormatConversionException; @@ -37,6 +38,7 @@ import be.nikiroo.utils.ImageUtils; *
  • Enum (any enum whose name and value is known by the caller)
  • *
  • java.awt.image.BufferedImage (as a {@link CustomSerializer})
  • *
  • An array of the above (as a {@link CustomSerializer})
  • + *
  • URL
  • * * * @author niki @@ -106,6 +108,30 @@ public class SerialUtils { } }); + // URL: + customTypes.put("java.net.URL", new CustomSerializer() { + @Override + protected String toString(Object value) { + if (value != null) { + return ((URL) value).toString(); + } + return null; + } + + @Override + protected Object fromString(String content) throws IOException { + if (content != null) { + return new URL(content); + } + return null; + } + + @Override + protected String getType() { + return "java.net.URL"; + } + }); + // Images (this is currently the only supported image type by default) customTypes.put("java.awt.image.BufferedImage", new CustomSerializer() { @Override