All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.bristleback.server.bristle.utils.StringUtil Maven / Gradle / Ivy

// Bristleback plugin - Copyright (c) 2010 bristleback.googlecode.com
// ---------------------------------------------------------------------------
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 3 of the License, or (at your
// option) any later version.
// This library is distributed in the hope that it will be useful,
// but without any warranty; without even the implied warranty of merchantability
// or fitness for a particular purpose.
// You should have received a copy of the GNU Lesser General Public License along
// with this program; if not, see .
// ---------------------------------------------------------------------------
package pl.bristleback.server.bristle.utils;

import org.apache.log4j.Logger;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

/**
 * This class is a part of Stripes Framework, version 1.5, www.stripesframework.org.
 * Class is modified by Wojciech Niemiec.
 * Provides utility methods for manipulating and parsing Strings.
 *
 * @author Tim Fennell
 * @since Stripes 1.4.2
 */
public final class StringUtil {
  private static Logger log = Logger.getLogger(StringUtil.class.getName());

  private StringUtil() {
    throw new UnsupportedOperationException();
  }

  /**
   * URL-decodes {@code value} using the UTF-8 charset. Using this method eliminates the need for
   * a try/catch since UTF-8 is guaranteed to exist.
   *
   * @see java.net.URLDecoder#decode(String, String)
   */
  public static String urlDecode(String value) {
    try {
      return URLDecoder.decode(value, "UTF-8");
    } catch (UnsupportedEncodingException e) {
      throw new RuntimeException("Unsupported encoding?  UTF-8?  That's unpossible.");
    }
  }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy