Implement NDEF URI Identifier Code.

        This is a small hack to replace some well known prefixes (such as http://)
        with a one byte code. If the prefix is not known, 0x00 is used.
1135
def _encode_ndef_uri_type(self, data):
        
        t = 0x0
        for (code, prefix) in uri_identifiers:
            if data[:len(prefix)].decode('latin-1').lower() == prefix:
                t = code
                data = data[len(prefix):]
                break
        data = yubico_util.chr_byte(t) + data
        return data
352393
function baseStringUri(uri) {
    var parsed = url.parse(uri);

    //  The port MUST be included if it is not the default port for the
    //  scheme, and MUST be excluded if it is the default.
    if (parsed.protocol === 'https:/') {
        parsed.host = parsed.host.replace(/:443$/, '');
    } else if (parsed.protocol === 'http:/') {
        parsed.host = parsed.host.replace(/:80$/, '');
    }

    return url.format({
        protocol: parsed.protocol,
        host: parsed.host,
        auth: parsed.auth,
        pathname: parsed.pathname
    });
}
492978
@Override
    public final String getNamespaceURI(String prefix)
    {
        if (prefix.length() == 0) { //default NS
            return mDefaultNsURI;
        }
        if (mNsMapping != null) {
            String uri = mNsMapping.findUriByPrefix(prefix);
            if (uri != null) {
                return uri;
            }
        }
        return (mRootNsContext != null) ?
            mRootNsContext.getNamespaceURI(prefix) : null;
    }
113852
def addBarcodesToIdentifier(read, UMI, cell):
    ''''''

    read_id = read.identifier.split(" ")

    if cell == "":
        read_id[0] = read_id[0] + "_" + UMI
    else:
        read_id[0] = read_id[0] + "_" + cell + "_" + UMI

    identifier = " ".join(read_id)

    return identifier
1323115
public static String decodeUrl(String stringToDecode) {
        try {
            return URLDecoder.decode(stringToDecode, "UTF-8");
        } catch (UnsupportedEncodingException e1) {
            throw new RuntimeException(e1);
        }
    }
1212850
private static String decodeUrl(String endcodedUrl) {
		String imageSize = "z"; // [mstzb]
		String[] parts = endcodedUrl.split("_");
		String farmId = parts[0];
		String serverId = parts[1];
		String identidier = parts[2];
		String secret = parts[3];
		// String isVideo = parts[4];

		String url = "https://farm" + farmId + ".staticflickr.com/" + serverId + "/" + identidier + "_"
				+ secret + "_" + imageSize + ".jpg";
		return url;
	}
181002
private String encodeUri( String uri )
	{
		StringBuilder newUri = new StringBuilder();
		StringTokenizer st = new StringTokenizer( uri, "/ ", true );
		while ( st.hasMoreTokens())
		{
			String tok = st.nextToken();
			if ( tok.equals( "/" )) {
				newUri.append('/');
			} else if ( tok.equals( " " )) {
				newUri.append("%20");
			} else {
				try {
					newUri.append(URLEncoder.encode( tok, "UTF-8" ));
				} catch ( UnsupportedEncodingException uee ) { // NOPMD - imported code
					// imported code
				}
			}
		}
		return newUri.toString();
	}
580869
public static String urlDecode(String string) {
		try {
			return URLDecoder.decode(string, "utf-8");
		} catch (UnsupportedEncodingException e) {
			throw new RuntimeException(e);
		}
	}
151829
def make_es_id(uri):
    
    try:
        uri = uri.clean_uri
    except AttributeError:
        pass
    return sha1(uri.encode()).hexdigest()
887118
private static String massageURI(String uri) {
    uri = uri.trim();
    int protocolEnd = uri.indexOf(':');
    if (protocolEnd < 0 || isColonFollowedByPortNumber(uri, protocolEnd)) {
      // No protocol, or found a colon, but it looks like it is after the host, so the protocol is still missing,
      // so assume http
      uri = "http://" + uri;
    }
    return uri;
  }
21076
private URI decodeHarURI(URI rawURI, Configuration conf) throws IOException {
    String tmpAuth = rawURI.getAuthority();
    //we are using the default file
    //system in the config
    //so create a underlying uri and
    //return it
    if (tmpAuth == null) {
      //create a path
      return FileSystem.getDefaultUri(conf);
    }
    String host = rawURI.getHost();
    String[] str = host.split("-", 2);
    if (str[0] == null) {
      throw new IOException("URI: " + rawURI + " is an invalid Har URI.");
    }
    String underLyingScheme = str[0];
    String underLyingHost = (str.length > 1)? str[1]:null;
    int underLyingPort = rawURI.getPort();
    String auth = (underLyingHost == null && underLyingPort == -1)?
                  null:(underLyingHost+":"+underLyingPort);
    URI tmp = null;
    if (rawURI.getQuery() != null) {
      // query component not allowed
      throw new IOException("query component in Path not supported  " + rawURI);
    }
    try {
      tmp = new URI(underLyingScheme, auth, rawURI.getPath(),
            rawURI.getQuery(), rawURI.getFragment());
    } catch (URISyntaxException e) {
        // do nothing should not happen
    }
    return tmp;
  }
64467
function full_uri_encode(string) {
  string = encodeURIComponent(string);
  string = string.replace(/\./g, '%2E');
  return(string);
}
1308126
protected void checkHttpSchemeSpecificPartSlashPrefix(final URI base,
            final String scheme, final String schemeSpecificPart)
    throws URIException {
        if (scheme == null || scheme.length() <= 0) {
            return;
        }
        if (!scheme.equals("http") && !scheme.equals("https")) {
            return;
        }
        if ( schemeSpecificPart == null 
                || !schemeSpecificPart.startsWith("//")) {
            // only acceptable if schemes match
            if (base == null || !scheme.equals(base.getScheme())) {
                throw new URIException(
                        "relative URI with scheme only allowed for " +
                        "scheme matching base");
            } 
            return; 
        }
        if (schemeSpecificPart.length() <= 2) {
            throw new URIException("http scheme specific part is " +
                "too short: " + schemeSpecificPart);
        }
    }
814472
def parse_prefix(identifier):
    
    pf, id = (), identifier
    if "|" in identifier:
        pf, id = tuple(identifier.split('|')[:-1]), identifier.split('|')[-1]

    return pf, id
577762
def uri_tree_precode_check(uri_tree, type_host = HOST_REG_NAME):
    
    scheme, authority, path, query, fragment = uri_tree # pylint: disable-msg=W0612
    if scheme:
        if not valid_scheme(scheme):
            raise InvalidSchemeError, "Invalid scheme %r" % (scheme,)
    if authority:
        user, passwd, host, port = authority # pylint: disable-msg=W0612
        if port and not __all_in(port, DIGIT):
            raise InvalidPortError, "Invalid port %r" % (port,)
        if type_host == HOST_IP_LITERAL:
            if host and (not __valid_IPLiteral(host)):
                raise InvalidIPLiteralError, "Invalid IP-literal %r" % (host,)
        elif type_host == HOST_IPV4_ADDRESS:
            if host and (not __valid_IPv4address(host)):
                raise InvalidIPv4addressError, "Invalid IPv4address %r" % (host,)
    if path:
        if authority and path[0] != '/':
            raise InvalidPathError, "Invalid path %r - non-absolute path can't be used with an authority" % (path,)
    return uri_tree
701194
function urlEncodeIfNecessary(s) {
		var regex = /[\\\"<>\.;]/;
		var hasBadChars = regex.exec(s) != null;
		return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) : s;
	}
96444
def identifier_md5(self):
        
        as_int = (self.identifier * 1e4).astype(np.int64)
        hashed = util.md5_object(as_int.tostring(order='C'))
        return hashed