X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fserial%2FCustomSerializer.java;h=e58ccf2af5945eab2ba4b508bd9d04c9213c56f1;hb=919bbc354cd2555eb0955be0ef2dcf338047d022;hp=b6928eec7685b853aff33537cd2844e0bfcc24d8;hpb=db31c35860081535d6e7ddc83ab4af573bb0522e;p=fanfix.git diff --git a/src/be/nikiroo/utils/serial/CustomSerializer.java b/src/be/nikiroo/utils/serial/CustomSerializer.java deleted file mode 100644 index b6928ee..0000000 --- a/src/be/nikiroo/utils/serial/CustomSerializer.java +++ /dev/null @@ -1,43 +0,0 @@ -package be.nikiroo.utils.serial; - -public abstract class CustomSerializer { - - protected abstract String toString(Object value); - - protected abstract Object fromString(String content); - - protected abstract String getType(); - - public void encode(StringBuilder builder, Object value) { - String customString = toString(value); - builder.append("custom:").append(getType()).append(":"); - SerialUtils.encode(builder, customString); - } - - public Object decode(String encodedValue) { - return fromString((String) SerialUtils.decode(contentOf(encodedValue))); - } - - public static boolean isCustom(String encodedValue) { - int pos1 = encodedValue.indexOf(':'); - int pos2 = encodedValue.indexOf(':', pos1 + 1); - - return pos1 >= 0 && pos2 >= 0 && encodedValue.startsWith("custom:"); - } - - public static String typeOf(String encodedValue) { - int pos1 = encodedValue.indexOf(':'); - int pos2 = encodedValue.indexOf(':', pos1 + 1); - String type = encodedValue.substring(pos1 + 1, pos2); - - return type; - } - - public static String contentOf(String encodedValue) { - int pos1 = encodedValue.indexOf(':'); - int pos2 = encodedValue.indexOf(':', pos1 + 1); - String encodedContent = encodedValue.substring(pos2 + 1); - - return encodedContent; - } -}