Package org.altbeacon.beacon.utils
Class UrlBeaconUrlCompressor
- java.lang.Object
-
- org.altbeacon.beacon.utils.UrlBeaconUrlCompressor
-
public class UrlBeaconUrlCompressor extends Object
Provides encoding / decoding functions for the URL beacon https://github.com/google/uribeacon
-
-
Constructor Summary
Constructors Constructor Description UrlBeaconUrlCompressor()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]compress(String urlString)Converts the given URL string into a byte array "compressed" version of the URL.static Stringuncompress(byte[] compressedURL)
-
-
-
Method Detail
-
compress
public static byte[] compress(String urlString) throws MalformedURLException
Converts the given URL string into a byte array "compressed" version of the URL. The regex needs to determine what the URL starts with and what the hostname ends with. The URL must start with one of the following: http://www. https://www. http:// https:// The hostname may end with one of the following TLDs: .com .org .edu .net .info .biz .gov If the path component of the URL is non-empty, then the "slash" version of the matching TLD can be used. Otherwise, the "non-slash" version of the TLD is used. If the hostname doesn't end with a TLD, that's fine; it just isn't compressed into a single byte. Therefore, the following regex should tell me what I need to know about the URL: ^(http|https):\/\/(www.)?((?:[0-9a-z_-]+\.??)+)(\.[0-9a-z_-]+\/?)(.*)$ Groups: 1: http or https 2: www. or empty 3: hostname including optional leading www. but excluding trailing dot up to but not including TLD 4: TLD with leading dot and optional trailing slash 5: path without leading slash or empty- Parameters:
urlString-- Returns:
- Throws:
MalformedURLException
-
uncompress
public static String uncompress(byte[] compressedURL)
-
-