X-Git-Url: http://www2.svjatoslav.eu/gitweb/?p=meviz.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fmeviz%2Fhtmlindexer%2FUtils.java;h=41c2eedab08f8c2957c88ba4bbde143ce4e01f33;hp=028995b1b176818cb3e9db1c25bb885a5a5cccc9;hb=cf6e4ace4972f24f40f88ea12fcf99c763e4e40a;hpb=1b742640af99284aae1cd10c259254137316ba7c diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java index 028995b..41c2eed 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java @@ -1,6 +1,6 @@ /* * Meviz - Various tools collection to work with multimedia. - * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * Copyright (C) 2012 -- 2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public License @@ -13,8 +13,10 @@ import eu.svjatoslav.meviz.htmlindexer.layouts.MixedLayout; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; -import java.io.*; -import java.net.URLEncoder; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; import java.util.HashSet; import java.util.zip.CRC32; @@ -60,7 +62,7 @@ public class Utils { } public static HashSet getLayouts() { - final HashSet layouts = new HashSet(); + final HashSet layouts = new HashSet<>(); layouts.add(new MixedLayout()); return layouts; } @@ -76,13 +78,9 @@ public class Utils { crc.update(b); // note use crc.value, not crc.getValue() - final String hex = Integer.toHexString((int) crc.getValue()) - .toUpperCase(); - - // System.out.println("Input string: " + input); - // System.out.println("Result: " + hex); - return hex; + return Integer.toHexString((int) crc.getValue()) + .toUpperCase(); } public static File getThumbnailsDirectory(final File directoryToIndex) { @@ -122,14 +120,23 @@ public class Utils { return isMevizFile; } + /** + * TODO: URL path component is encoded differently from URL query parameter. + * Also some URL encoding might work for HTML on local filesystem, while other + * stuff works for web. Things must be cleared up here. Currently they are mixed and + * hacked together. + */ public static String urlEncode(String string) { if (string.startsWith("./")) string = string.substring(2); - try { - return URLEncoder.encode(string, UTF_8).replace("+", "%20"); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } + // TODO: get rid of UrlParamEncoder. + return UrlParamEncoder.encode(string); + // +// try { +// return URLEncoder.encode(string, UTF_8).replace("+", "%20"); +// } catch (UnsupportedEncodingException e) { +// throw new RuntimeException(e); +// } } }