X-Git-Url: http://git.nikiroo.be/?p=nikiroo-utils.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fserial%2FCustomSerializer.java;h=fe63f71903619c6ae49f7fa8d765ddf0b2858f0a;hp=c5876ce401b622788f53ca073ced5e89d7ca56c2;hb=dce410fec00030c0affde7b19bcde6de847fae13;hpb=bd86c2218b4a8befeb9b2789b62e1697993f0b5b diff --git a/src/be/nikiroo/utils/serial/CustomSerializer.java b/src/be/nikiroo/utils/serial/CustomSerializer.java index c5876ce..fe63f71 100644 --- a/src/be/nikiroo/utils/serial/CustomSerializer.java +++ b/src/be/nikiroo/utils/serial/CustomSerializer.java @@ -5,6 +5,7 @@ import java.io.InputStream; import java.io.OutputStream; import be.nikiroo.utils.IOUtils; +import be.nikiroo.utils.streams.BufferedInputStream; import be.nikiroo.utils.streams.NextableInputStream; import be.nikiroo.utils.streams.NextableInputStreamStep; import be.nikiroo.utils.streams.ReplaceInputStream; @@ -160,6 +161,8 @@ public abstract class CustomSerializer { } } + /** Use {@link CustomSerializer#isCustom(BufferedInputStream)}. */ + @Deprecated public static boolean isCustom(String encodedValue) { int pos1 = encodedValue.indexOf('^'); int pos2 = encodedValue.indexOf('^', pos1 + 1); @@ -167,6 +170,10 @@ public abstract class CustomSerializer { return pos1 >= 0 && pos2 >= 0 && encodedValue.startsWith("custom^"); } + public static boolean isCustom(BufferedInputStream in) throws IOException { + return in.startsWiths("custom^"); + } + public static String typeOf(String encodedValue) { int pos1 = encodedValue.indexOf('^'); int pos2 = encodedValue.indexOf('^', pos1 + 1); @@ -174,12 +181,4 @@ public abstract class CustomSerializer { 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; - } }