本文整理汇总了Java中java.net.URI.getRawFragment方法的典型用法代码示例。如果您正苦于以下问题:Java URI.getRawFragment方法的具体用法?Java URI.getRawFragment怎么用?Java URI.getRawFragment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.net.URI
的用法示例。
在下文中一共展示了URI.getRawFragment方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: digestURI
import java.net.URI; //导入方法依赖的package包/类
private void digestURI(final URI uri) {
this.scheme = uri.getScheme();
this.encodedSchemeSpecificPart = uri.getRawSchemeSpecificPart();
this.encodedAuthority = uri.getRawAuthority();
this.host = uri.getHost();
this.port = uri.getPort();
this.encodedUserInfo = uri.getRawUserInfo();
this.userInfo = uri.getUserInfo();
this.encodedPath = uri.getRawPath();
this.path = uri.getPath();
this.encodedQuery = uri.getRawQuery();
this.queryParams = parseQuery(uri.getRawQuery(), Charset.forName(HTTP.UTF_8));
this.encodedFragment = uri.getRawFragment();
this.fragment = uri.getFragment();
}
示例2: digestURI
import java.net.URI; //导入方法依赖的package包/类
private void digestURI(final URI uri) {
this.scheme = uri.getScheme();
this.encodedSchemeSpecificPart = uri.getRawSchemeSpecificPart();
this.encodedAuthority = uri.getRawAuthority();
this.host = uri.getHost();
this.port = uri.getPort();
this.encodedUserInfo = uri.getRawUserInfo();
this.userInfo = uri.getUserInfo();
this.encodedPath = uri.getRawPath();
this.path = uri.getPath();
this.encodedQuery = uri.getRawQuery();
this.queryParams = parseQuery(uri.getRawQuery(), Consts.UTF_8);
this.encodedFragment = uri.getRawFragment();
this.fragment = uri.getFragment();
}
示例3: getRequestString
import java.net.URI; //导入方法依赖的package包/类
/**
* Generate an HMAC request string.
* <p>
* This method trusts its inputs to be valid as per the MAC Authentication spec.
*
* @param request HTTP request.
* @param timestamp to use.
* @param nonce to use.
* @param extra to use.
* @return request string.
*/
protected static String getRequestString(HttpUriRequest request, long timestamp, String nonce, String extra) {
String method = request.getMethod().toUpperCase();
URI uri = request.getURI();
String host = uri.getHost();
String path = uri.getRawPath();
if (uri.getRawQuery() != null) {
path += "?";
path += uri.getRawQuery();
}
if (uri.getRawFragment() != null) {
path += "#";
path += uri.getRawFragment();
}
int port = uri.getPort();
String scheme = uri.getScheme();
if (port != -1) {
} else if ("http".equalsIgnoreCase(scheme)) {
port = 80;
} else if ("https".equalsIgnoreCase(scheme)) {
port = 443;
} else {
throw new IllegalArgumentException("Unsupported URI scheme: " + scheme + ".");
}
String requestString = timestamp + "\n" +
nonce + "\n" +
method + "\n" +
path + "\n" +
host + "\n" +
port + "\n" +
extra + "\n";
return requestString;
}
示例4: checkUri
import java.net.URI; //导入方法依赖的package包/类
private void checkUri(URI uri) {
if (!uri.getScheme().equalsIgnoreCase(getScheme()))
throw new IllegalArgumentException("URI does not match this provider");
if (uri.getRawAuthority() != null)
throw new IllegalArgumentException("Authority component present");
String path = uri.getPath();
if (path == null)
throw new IllegalArgumentException("Path component is undefined");
if (!path.equals("/"))
throw new IllegalArgumentException("Path component should be '/'");
if (uri.getRawQuery() != null)
throw new IllegalArgumentException("Query component present");
if (uri.getRawFragment() != null)
throw new IllegalArgumentException("Fragment component present");
}
示例5: relativePath
import java.net.URI; //导入方法依赖的package包/类
public static String relativePath(String line) throws RuntimeException {
String connects[] = line.split(" +");
if (connects[1].toLowerCase().startsWith("http://")) {
URI uri = Uri.create(connects[1]);
String path = uri.getRawPath();
String query = uri.getRawQuery();
String frag = uri.getRawFragment();
if (path == null) {
path = "/";
}
if (query == null) {
query = "";
} else {
query = "?" + query;
}
if (frag == null) {
frag = "";
} else {
frag = "#" + frag;
}
return connects[0] + " " + path + query + frag + " " + connects[2];
} else {
return line;
}
}
示例6: HgURL
import java.net.URI; //导入方法依赖的package包/类
/**
*
* @param urlString
* @param username
* @param password value is cloned, if you want to null the field, call {@link #clearPassword()}
* @throws URISyntaxException
*/
public HgURL(String urlString, String username, char[] password) throws URISyntaxException {
URI originalUri;
if (urlString == null) {
throw new IllegalArgumentException("<null> URL string"); //NOI18N
}
if (urlString.length() == 0) {
throw new IllegalArgumentException("empty URL string"); //NOI18N
}
if (looksLikePlainFilePath(urlString)) {
originalUri = new File(urlString).toURI();
scheme = Scheme.FILE;
} else {
originalUri = new URI(urlString).parseServerAuthority();
String originalScheme = originalUri.getScheme();
scheme = (originalScheme != null) ? determineScheme(originalScheme)
: null;
}
if (scheme == null) {
throw new URISyntaxException(
urlString,
NbBundle.getMessage(HgURL.class,
"MSG_UNSUPPORTED_PROTOCOL", //NOI18N
originalUri.getScheme()));
}
verifyUserInfoData(scheme, username, password);
if (username != null) {
this.username = username;
this.password = password == null ? null : (char[])password.clone();
} else {
String rawUserInfo = originalUri.getRawUserInfo();
if (rawUserInfo == null) {
this.username = null;
this.password = null;
} else {
int colonIndex = rawUserInfo.indexOf(':');
if (colonIndex == -1) {
this.username = rawUserInfo;
this.password = null;
} else {
this.username = rawUserInfo.substring(0, colonIndex);
this.password = rawUserInfo.substring(colonIndex + 1).toCharArray();
}
}
}
host = originalUri.getHost();
port = originalUri.getPort();
rawPath = originalUri.getRawPath();
rawQuery = originalUri.getRawQuery();
rawFragment = originalUri.getRawFragment();
path = originalUri.getPath();
}
示例7: getRequestString
import java.net.URI; //导入方法依赖的package包/类
/**
* Generate a normalized Hawk request string. This is under-specified; the
* code here was reverse engineered from the code at
* <a href="https://github.com/hueniverse/hawk/blob/871cc597973110900467bd3dfb84a3c892f678fb/lib/crypto.js#L55">https://github.com/hueniverse/hawk/blob/871cc597973110900467bd3dfb84a3c892f678fb/lib/crypto.js#L55</a>.
* <p>
* This method trusts its inputs to be valid.
*/
protected static String getRequestString(HttpUriRequest request, String type, long timestamp, String nonce, String hash, String extra, String app, String dlg) {
String method = request.getMethod().toUpperCase(Locale.US);
URI uri = request.getURI();
String host = uri.getHost();
String path = uri.getRawPath();
if (uri.getRawQuery() != null) {
path += "?";
path += uri.getRawQuery();
}
if (uri.getRawFragment() != null) {
path += "#";
path += uri.getRawFragment();
}
int port = uri.getPort();
String scheme = uri.getScheme();
if (port != -1) {
} else if ("http".equalsIgnoreCase(scheme)) {
port = 80;
} else if ("https".equalsIgnoreCase(scheme)) {
port = 443;
} else {
throw new IllegalArgumentException("Unsupported URI scheme: " + scheme + ".");
}
StringBuilder sb = new StringBuilder();
sb.append("hawk.");
sb.append(HAWK_HEADER_VERSION);
sb.append('.');
sb.append(type);
sb.append('\n');
sb.append(timestamp);
sb.append('\n');
sb.append(nonce);
sb.append('\n');
sb.append(method);
sb.append('\n');
sb.append(path);
sb.append('\n');
sb.append(host);
sb.append('\n');
sb.append(port);
sb.append('\n');
if (hash != null) {
sb.append(hash);
}
sb.append("\n");
if (extra != null && extra.length() > 0) {
sb.append(escapeExtraString(extra));
}
sb.append("\n");
if (app != null) {
sb.append(app);
sb.append("\n");
if (dlg != null) {
sb.append(dlg);
}
sb.append("\n");
}
return sb.toString();
}
示例8: fromUri
import java.net.URI; //导入方法依赖的package包/类
/**
* Converts given URI to a Path
*/
static WindowsPath fromUri(WindowsFileSystem fs, URI uri) {
if (!uri.isAbsolute())
throw new IllegalArgumentException("URI is not absolute");
if (uri.isOpaque())
throw new IllegalArgumentException("URI is not hierarchical");
String scheme = uri.getScheme();
if ((scheme == null) || !scheme.equalsIgnoreCase("file"))
throw new IllegalArgumentException("URI scheme is not \"file\"");
if (uri.getRawFragment() != null)
throw new IllegalArgumentException("URI has a fragment component");
if (uri.getRawQuery() != null)
throw new IllegalArgumentException("URI has a query component");
String path = uri.getPath();
if (path.equals(""))
throw new IllegalArgumentException("URI path component is empty");
// UNC
String auth = uri.getRawAuthority();
if (auth != null && !auth.equals("")) {
String host = uri.getHost();
if (host == null)
throw new IllegalArgumentException("URI authority component has undefined host");
if (uri.getUserInfo() != null)
throw new IllegalArgumentException("URI authority component has user-info");
if (uri.getPort() != -1)
throw new IllegalArgumentException("URI authority component has port number");
// IPv6 literal
// 1. drop enclosing brackets
// 2. replace ":" with "-"
// 3. replace "%" with "s" (zone/scopeID delimiter)
// 4. Append .ivp6-literal.net
if (host.startsWith("[")) {
host = host.substring(1, host.length()-1)
.replace(':', '-')
.replace('%', 's');
host += IPV6_LITERAL_SUFFIX;
}
// reconstitute the UNC
path = "\\\\" + host + path;
} else {
if ((path.length() > 2) && (path.charAt(2) == ':')) {
// "/c:/foo" --> "c:/foo"
path = path.substring(1);
}
}
return WindowsPath.parse(fs, path);
}
示例9: File
import java.net.URI; //导入方法依赖的package包/类
/**
* Creates a new {@code File} instance by converting the given
* {@code file:} URI into an abstract pathname.
*
* <p> The exact form of a {@code file:} URI is system-dependent, hence
* the transformation performed by this constructor is also
* system-dependent.
*
* <p> For a given abstract pathname <i>f</i> it is guaranteed that
*
* <blockquote><code>
* new File(</code><i> f</i><code>.{@link #toURI()
* toURI}()).equals(</code><i> f</i><code>.{@link #getAbsoluteFile() getAbsoluteFile}())
* </code></blockquote>
*
* so long as the original abstract pathname, the URI, and the new abstract
* pathname are all created in (possibly different invocations of) the same
* Java virtual machine. This relationship typically does not hold,
* however, when a {@code file:} URI that is created in a virtual machine
* on one operating system is converted into an abstract pathname in a
* virtual machine on a different operating system.
*
* @param uri
* An absolute, hierarchical URI with a scheme equal to
* {@code "file"}, a non-empty path component, and undefined
* authority, query, and fragment components
*
* @throws NullPointerException
* If {@code uri} is {@code null}
*
* @throws IllegalArgumentException
* If the preconditions on the parameter do not hold
*
* @see #toURI()
* @see java.net.URI
* @since 1.4
*/
public File(URI uri) {
// Check our many preconditions
if (!uri.isAbsolute())
throw new IllegalArgumentException("URI is not absolute");
if (uri.isOpaque())
throw new IllegalArgumentException("URI is not hierarchical");
String scheme = uri.getScheme();
if ((scheme == null) || !scheme.equalsIgnoreCase("file"))
throw new IllegalArgumentException("URI scheme is not \"file\"");
if (uri.getRawAuthority() != null)
throw new IllegalArgumentException("URI has an authority component");
if (uri.getRawFragment() != null)
throw new IllegalArgumentException("URI has a fragment component");
if (uri.getRawQuery() != null)
throw new IllegalArgumentException("URI has a query component");
String p = uri.getPath();
if (p.equals(""))
throw new IllegalArgumentException("URI path component is empty");
// Okay, now initialize
p = fs.fromURIPath(p);
if (File.separatorChar != '/')
p = p.replace('/', File.separatorChar);
this.path = fs.normalize(p);
this.prefixLength = fs.prefixLength(this.path);
}