Attempts to parse the provided {@link BufferedString} as
a UUID into hash value in two longs.

Warning: as written, this method does modify the state
of the passed in BufferedString.

@param str
@return A parsed UUID, or a null if parsing failed.
973248
public static UUID attemptUUIDParse(BufferedString str) {
    Long lo = attemptUUIDParseLow(str);
    Long hi = attemptUUIDParseHigh(str);
    return (str.getOffset() == -1) ? null : buildUUID(lo, hi);
  }
824345
public static String decode(String str) {
		try {
			return URLDecoder.decode(str, "UTF-8");
		} catch (UnsupportedEncodingException e) {
			//should never happen
			throw new RuntimeException(e);
		}
	}
1263077
public static byte[] sha256Bytes(String str) {
        if (str == null) return null;
        MessageDigest digester;
        try {
            digester = MessageDigest.getInstance("SHA-256");
        } catch (NoSuchAlgorithmException ex) {
            throw new RuntimeException(ex);
        }
        return digester.digest(str.getBytes());
    }
1122680
public static String decodeString(String str) {
		try {
			return new String(Base64.decode(str));
		} catch (IOException io) {
			throw new RuntimeException(io.getMessage(), io.getCause());
		}
	}
1265736
public static final String toUrlEncoded(String str) {
    try {
      return URLEncoder.encode(str, "UTF-8");
    } catch (UnsupportedEncodingException exception) {
      // Ignore
    }
    return null;
  }
935887
private static Long attemptUUIDParseLow(BufferedString str) {
    final byte[] buf = str.getBuffer();
    int i=str.getOffset();
    if( i+36 > buf.length ) return markBad(str);
    long lo=0;
    lo = get2(lo,buf,(i+=2)-2);
    lo = get2(lo,buf,(i+=2)-2);
    lo = get2(lo,buf,(i+=2)-2);
    lo = get2(lo,buf,(i+=2)-2);
    if( buf[i++]!='-' ) return markBad(str);
    lo = get2(lo,buf,(i+=2)-2);
    lo = get2(lo,buf,(i+=2)-2);
    if( buf[i++]!='-' ) return markBad(str);
    lo = get2(lo,buf,(i+=2)-2);
    return attemptUUIDParseEnd(str, lo, buf, i);
  }
194978
@Nullable
  public static Long parseLongObj (@Nullable final String sStr)
  {
    return parseLongObj (sStr, DEFAULT_RADIX, null);
  }
17252
public static final String base64Decode(String str) {
        if (str == null) {
            return null;
        } else {
            byte data[] = getBytes(str);
            return toString(base64Decode(data));
        }
    }
1351968
public static String urlEncode(String str) throws UnsupportedEncodingException {
    // Preserve original behavior that passing null for an object id will lead
    // to us actually making a request to /v1/foo/null
    if (str == null) {
      return null;
    } else {
      // Don't use strict form encoding by changing the square bracket control
      // characters back to their literals. This is fine by the server, and
      // makes these parameter strings easier to read.
      return URLEncoder.encode(str, CHARSET)
        .replaceAll("%5B", "[")
        .replaceAll("%5D", "]");
    }
  }
784110
public HashSet<String> getStringsWithSubstring(String str)
    {
        HashSet<String> strHashSet = new HashSet<String>();

        if (sourceNode != null)      //if the MDAG hasn't been simplified
            getStrings(strHashSet, SearchCondition.SUBSTRING_SEARCH_CONDITION, str, "", sourceNode.getOutgoingTransitions());
        else
            getStrings(strHashSet, SearchCondition.SUBSTRING_SEARCH_CONDITION, str, "", simplifiedSourceNode);

        return strHashSet;
    }
1063659
public static String encode(String str)
	{
		try
		{
			return java.net.URLEncoder.encode(str, "UTF-8");
		}
		catch(java.io.UnsupportedEncodingException ue)
		{
			return str;
		}
	}
416709
public static Integer str2state(String str)
    {
        Integer state;

        if (str == null)
        {
            return null;
        }

        state = inverseStateMap.get(str);

        if (state == null)
        {
            Matcher matcher = UNKNOWN_STATE_PATTERN.matcher(str);
            if (matcher.matches())
            {
                try
                {
                    state = Integer.valueOf(matcher.group(1));
                }
                catch (NumberFormatException e)
                {
                    // should not happen as the pattern requires \d+ for the state.
                    throw new IllegalArgumentException("Unable to convert state '" + str + "' to integer representation", e);
                }
            }
        }

        return state;
    }
789823
public static long parseLong(final String str, final long def) {
        final Long ret = parseLong(str);
        if (ret == null) {
            return def;
        } else {
            return ret.longValue();
        }
    }
776204
public static String encodeString(String str) {
        if (str == null)
            return str;
        if (str.equals("-1"))
            return str;
        try {
            Long lo = new Long(str);
            return encodeLong(lo.longValue());
        } catch (NumberFormatException nfe) {
            // do nothing -- this is expected on zOS, results in string being returned unchanged  242544
        } catch (Throwable th) {
            com.ibm.ws.ffdc.FFDCFilter.processException(th, "com.ibm.ws.session.utils.EncodeCloneID.encodeString", "56", str);
        }
        return str;
    }
170151
public static byte[] hex2byte(String str) {
        byte[] bytes = str.getBytes();
        if ((bytes.length % 2) != 0) {
            throw new IllegalArgumentException();
        }
        byte[] b2 = new byte[bytes.length / 2];
        for (int n = 0; n < bytes.length; n += 2) {
            String item = new String(bytes, n, 2);
            b2[n / 2] = (byte) Integer.parseInt(item, 16);
        }
        return b2;
    }
950411
public static final String decode(String str)
    {
        Matcher m = ENT.matcher(str);
        StringBuffer sb = new StringBuffer();
        while (m.find())
        {
            String entity = m.group(1);
            Matcher m2 = HENT.matcher(entity);
            Integer codePoint = null;
            if (m2.matches())
            {
                codePoint = Integer.parseInt(m2.group(1));
            }
            else
            {
                codePoint = codePointMap.get(entity);
            }
            if (codePoint == null)
            {
                m.appendReplacement(sb, m.group());
            }
            else
            {
                String s = new String(new int[] {codePoint.intValue()}, 0, 1);
                m.appendReplacement(sb, s);
            }
        }
        m.appendTail(sb);
        return sb.toString();
    }
1295806
public static String fingerprint(String str) {
		try {
			MessageDigest md = MessageDigest.getInstance("SHA-1");
			return byteArrayToHexString(md.digest(str.getBytes()));
		}
		catch (NoSuchAlgorithmException nsae) {
			LOGGER.warning("Unable to calculate the fingerprint for string [" + str + "].");
			return null;
		}
	}