Mercurial > dive4elements > framework
view artifact-database/src/main/java/de/intevation/artifactdatabase/StringUtils.java @ 80:8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
artifacts/trunk@799 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 19 Mar 2010 09:34:40 +0000 |
parents | f69e5b87f05f |
children | 0f48188a6e02 |
line wrap: on
line source
package de.intevation.artifactdatabase; import java.io.UnsupportedEncodingException; import java.util.UUID; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.binary.Hex; import org.apache.log4j.Logger; /** * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> */ public final class StringUtils { private static Logger logger = Logger.getLogger(StringUtils.class); public static final String newUUID() { return UUID.randomUUID().toString(); } public static final boolean checkUUID(String uuid) { try { UUID.fromString(uuid); } catch (IllegalArgumentException iae) { logger.warn(iae.getLocalizedMessage()); return false; } return true; } public static final byte [] getUTF8Bytes(String s) { try { return s.getBytes("UTF-8"); } catch (UnsupportedEncodingException usee) { logger.error(usee.getLocalizedMessage(), usee); return s.getBytes(); } } public static final byte [] decodeHex(String s) { try { return Hex.decodeHex(s.toCharArray()); } catch (DecoderException de) { return null; } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :