热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

okhttp3.internal.Util.delimiterOffset()方法的使用及代码示例

本文整理了Java中okhttp3.internal.Util.delimiterOffset()方法的一些代码示例,展示了Util.delimiterOf

本文整理了Java中okhttp3.internal.Util.delimiterOffset()方法的一些代码示例,展示了Util.delimiterOffset()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.delimiterOffset()方法的具体详情如下:
包路径:okhttp3.internal.Util
类名称:Util
方法名:delimiterOffset

Util.delimiterOffset介绍

[英]Returns the index of the first character in input that is delimiter. Returns limit if there is no such character.
[中]返回输入中作为分隔符的第一个字符的索引。如果没有这样的字符,则返回limit。

代码示例

代码示例来源:origin: square/okhttp

/**
* Returns the username, or an empty string if none is set.
*
*


*

*

*

*

*

*
URL{@code encodedUsername()}
{@code http://host/}{@code ""}
{@code http://username@host/}{@code "username"}
{@code http://username:password@host/}{@code "username"}
{@code http://a%20b:c%20d@host/}{@code "a%20b"}

*/
public String encodedUsername() {
if (username.isEmpty()) return "";
int usernameStart = scheme.length() + 3; // "://".length() == 3.
int usernameEnd = delimiterOffset(url, usernameStart, url.length(), ":@");
return url.substring(usernameStart, usernameEnd);
}

代码示例来源:origin: square/okhttp

/**
* Returns the entire path of this URL encoded for use in HTTP resource resolution. The returned
* path will start with {@code "/"}.
*
*


*

*

*

*

*
URL{@code encodedPath()}
{@code http://host/}{@code "/"}
{@code http://host/a/b/c}{@code "/a/b/c"}
{@code http://host/a/b%20c/d}{@code "/a/b%20c/d"}

*/
public String encodedPath() {
int pathStart = url.indexOf('/', scheme.length() + 3); // "://".length() == 3.
int pathEnd = delimiterOffset(url, pathStart, url.length(), "?#");
return url.substring(pathStart, pathEnd);
}

代码示例来源:origin: square/okhttp

private Builder addPathSegments(String pathSegments, boolean alreadyEncoded) {
int offset = 0;
do {
int segmentEnd = delimiterOffset(pathSegments, offset, pathSegments.length(), "/\\");
boolean addTrailingSlash = segmentEnd push(pathSegments, offset, segmentEnd, addTrailingSlash, alreadyEncoded);
offset = segmentEnd + 1;
} while (offset <= pathSegments.length());
return this;
}

代码示例来源:origin: square/okhttp

/**
* Returns a list of encoded path segments like {@code ["a", "b", "c"]} for the URL {@code
* http://host/a/b/c}. This list is never empty though it may contain a single empty string.
*
*


*

*

*

*

*
URL{@code encodedPathSegments()}
{@code http://host/}{@code [""]}
{@code http://host/a/b/c}{@code ["a", "b", "c"]}
{@code http://host/a/b%20c/d}{@code ["a", "b%20c", "d"]}

*/
public List encodedPathSegments() {
int pathStart = url.indexOf('/', scheme.length() + 3);
int pathEnd = delimiterOffset(url, pathStart, url.length(), "?#");
List result = new ArrayList<>();
for (int i = pathStart; i i++; // Skip the '/'.
int segmentEnd = delimiterOffset(url, i, pathEnd, '/');
result.add(url.substring(i, segmentEnd));
i = segmentEnd;
}
return result;
}

代码示例来源:origin: square/okhttp

/**
* Returns the query of this URL, encoded for use in HTTP resource resolution. The returned string
* may be null (for URLs with no query), empty (for URLs with an empty query) or non-empty (all
* other URLs).
*
*


*

*

*

*

*

*

*
URL{@code encodedQuery()}
{@code http://host/}null
{@code http://host/?}{@code ""}
{@code http://host/?a=apple&k=key+lime}{@code
* "a=apple&k=key+lime"}
{@code http://host/?a=apple&a=apricot}{@code "a=apple&a=apricot"}
{@code http://host/?a=apple&b}{@code "a=apple&b"}

*/
public @Nullable String encodedQuery() {
if (queryNamesAndValues == null) return null; // No query.
int queryStart = url.indexOf('?') + 1;
int queryEnd = delimiterOffset(url, queryStart, url.length(), '#');
return url.substring(queryStart, queryEnd);
}

代码示例来源:origin: square/okhttp

private void resolvePath(String input, int pos, int limit) {
// Read a delimiter.
if (pos == limit) {
// Empty path: keep the base path as-is.
return;
}
char c = input.charAt(pos);
if (c == '/' || c == '\\') {
// Absolute path: reset to the default "/".
encodedPathSegments.clear();
encodedPathSegments.add("");
pos++;
} else {
// Relative path: clear everything after the last '/'.
encodedPathSegments.set(encodedPathSegments.size() - 1, "");
}
// Read path segments.
for (int i = pos; i int pathSegmentDelimiterOffset = delimiterOffset(input, i, limit, "/\\");
boolean segmentHasTrailingSlash = pathSegmentDelimiterOffset push(input, i, pathSegmentDelimiterOffset, segmentHasTrailingSlash, true);
i = pathSegmentDelimiterOffset;
if (segmentHasTrailingSlash) i++;
}
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

/**
* Returns the entire path of this URL encoded for use in HTTP resource resolution. The returned
* path will start with {@code "/"}.
*
*


*

*

*

*

*
URL{@code encodedPath()}
{@code http://host/}{@code "/"}
{@code http://host/a/b/c}{@code "/a/b/c"}
{@code http://host/a/b%20c/d}{@code "/a/b%20c/d"}

*/
public String encodedPath() {
int pathStart = url.indexOf('/', scheme.length() + 3); // "://".length() == 3.
int pathEnd = delimiterOffset(url, pathStart, url.length(), "?#");
return url.substring(pathStart, pathEnd);
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

/**
* Returns the username, or an empty string if none is set.
*
*


*

*

*

*

*

*
URL{@code encodedUsername()}
{@code http://host/}{@code ""}
{@code http://username@host/}{@code "username"}
{@code http://username:password@host/}{@code "username"}
{@code http://a%20b:c%20d@host/}{@code "a%20b"}

*/
public String encodedUsername() {
if (username.isEmpty()) return "";
int usernameStart = scheme.length() + 3; // "://".length() == 3.
int usernameEnd = delimiterOffset(url, usernameStart, url.length(), ":@");
return url.substring(usernameStart, usernameEnd);
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

private Builder addPathSegments(String pathSegments, boolean alreadyEncoded) {
int offset = 0;
do {
int segmentEnd = delimiterOffset(pathSegments, offset, pathSegments.length(), "/\\");
boolean addTrailingSlash = segmentEnd push(pathSegments, offset, segmentEnd, addTrailingSlash, alreadyEncoded);
offset = segmentEnd + 1;
} while (offset <= pathSegments.length());
return this;
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

/**
* Returns the query of this URL, encoded for use in HTTP resource resolution. The returned string
* may be null (for URLs with no query), empty (for URLs with an empty query) or non-empty (all
* other URLs).
*
*


*

*

*

*

*

*

*
URL{@code encodedQuery()}
{@code http://host/}null
{@code http://host/?}{@code ""}
{@code http://host/?a=apple&k=key+lime}{@code
* "a=apple&k=key+lime"}
{@code http://host/?a=apple&a=apricot}{@code "a=apple&a=apricot"}
{@code http://host/?a=apple&b}{@code "a=apple&b"}

*/
public @Nullable String encodedQuery() {
if (queryNamesAndValues == null) return null; // No query.
int queryStart = url.indexOf('?') + 1;
int queryEnd = delimiterOffset(url, queryStart, url.length(), '#');
return url.substring(queryStart, queryEnd);
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

/**
* Returns a list of encoded path segments like {@code ["a", "b", "c"]} for the URL {@code
* http://host/a/b/c}. This list is never empty though it may contain a single empty string.
*
*


*

*

*

*

*
URL{@code encodedPathSegments()}
{@code http://host/}{@code [""]}
{@code http://host/a/b/c}{@code ["a", "b", "c"]}
{@code http://host/a/b%20c/d}{@code ["a", "b%20c", "d"]}

*/
public List encodedPathSegments() {
int pathStart = url.indexOf('/', scheme.length() + 3);
int pathEnd = delimiterOffset(url, pathStart, url.length(), "?#");
List result = new ArrayList<>();
for (int i = pathStart; i i++; // Skip the '/'.
int segmentEnd = delimiterOffset(url, i, pathEnd, '/');
result.add(url.substring(i, segmentEnd));
i = segmentEnd;
}
return result;
}

代码示例来源:origin: square/okhttp

List result = new ArrayList<>();
for (int pos = 0, limit = header.length(), pairEnd; pos pairEnd = delimiterOffset(header, pos, limit, ";,");
int equalsSign = delimiterOffset(header, pos, pairEnd, '=');
String name = trimSubstring(header, pos, equalsSign);
if (name.startsWith("$")) continue;

代码示例来源:origin: com.squareup.okhttp3/okhttp

private void resolvePath(String input, int pos, int limit) {
// Read a delimiter.
if (pos == limit) {
// Empty path: keep the base path as-is.
return;
}
char c = input.charAt(pos);
if (c == '/' || c == '\\') {
// Absolute path: reset to the default "/".
encodedPathSegments.clear();
encodedPathSegments.add("");
pos++;
} else {
// Relative path: clear everything after the last '/'.
encodedPathSegments.set(encodedPathSegments.size() - 1, "");
}
// Read path segments.
for (int i = pos; i int pathSegmentDelimiterOffset = delimiterOffset(input, i, limit, "/\\");
boolean segmentHasTrailingSlash = pathSegmentDelimiterOffset push(input, i, pathSegmentDelimiterOffset, segmentHasTrailingSlash, true);
i = pathSegmentDelimiterOffset;
if (segmentHasTrailingSlash) i++;
}
}

代码示例来源:origin: square/okhttp

static @Nullable COOKIE parse(long currentTimeMillis, HttpUrl url, String setCOOKIE) {
int pos = 0;
int limit = setCOOKIE.length();
int COOKIEPairEnd = delimiterOffset(setCOOKIE, pos, limit, ';');
int pairEqualsSign = delimiterOffset(setCOOKIE, pos, COOKIEPairEnd, '=');
if (pairEqualsSign == COOKIEPairEnd) return null;
int attributePairEnd = delimiterOffset(setCOOKIE, pos, limit, ';');
int attributeEqualsSign = delimiterOffset(setCOOKIE, pos, attributePairEnd, '=');
String attributeName = trimSubstring(setCOOKIE, pos, attributeEqualsSign);
String attributeValue = attributeEqualsSign

代码示例来源:origin: square/okhttp

authority:
while (true) {
int compOnentDelimiterOffset= delimiterOffset(input, pos, limit, "@/\\?#");
int c = componentDelimiterOffset != limit
? input.charAt(componentDelimiterOffset)
int passwordColOnOffset= delimiterOffset(
input, pos, componentDelimiterOffset, ':');
String canOnicalUsername= canonicalize(input, pos, passwordColonOffset,
int pathDelimiterOffset = delimiterOffset(input, pos, limit, "?#");
resolvePath(input, pos, pathDelimiterOffset);
pos = pathDelimiterOffset;
int queryDelimiterOffset = delimiterOffset(input, pos, limit, '#');
this.encodedQueryNamesAndValues = queryStringToNamesAndValues(canonicalize(
input, pos + 1, queryDelimiterOffset, QUERY_ENCODE_SET, true, false, true, true, null));

代码示例来源:origin: com.squareup.okhttp3/okhttp

static @Nullable COOKIE parse(long currentTimeMillis, HttpUrl url, String setCOOKIE) {
int pos = 0;
int limit = setCOOKIE.length();
int COOKIEPairEnd = delimiterOffset(setCOOKIE, pos, limit, ';');
int pairEqualsSign = delimiterOffset(setCOOKIE, pos, COOKIEPairEnd, '=');
if (pairEqualsSign == COOKIEPairEnd) return null;
int attributePairEnd = delimiterOffset(setCOOKIE, pos, limit, ';');
int attributeEqualsSign = delimiterOffset(setCOOKIE, pos, attributePairEnd, '=');
String attributeName = trimSubstring(setCOOKIE, pos, attributeEqualsSign);
String attributeValue = attributeEqualsSign

代码示例来源:origin: com.squareup.okhttp3/okhttp

authority:
while (true) {
int compOnentDelimiterOffset= delimiterOffset(input, pos, limit, "@/\\?#");
int c = componentDelimiterOffset != limit
? input.charAt(componentDelimiterOffset)
int passwordColOnOffset= delimiterOffset(
input, pos, componentDelimiterOffset, ':');
String canOnicalUsername= canonicalize(input, pos, passwordColonOffset,
int pathDelimiterOffset = delimiterOffset(input, pos, limit, "?#");
resolvePath(input, pos, pathDelimiterOffset);
pos = pathDelimiterOffset;
int queryDelimiterOffset = delimiterOffset(input, pos, limit, '#');
this.encodedQueryNamesAndValues = queryStringToNamesAndValues(canonicalize(
input, pos + 1, queryDelimiterOffset, QUERY_ENCODE_SET, true, false, true, true, null));

代码示例来源:origin: duzechao/OKHttpUtils

public List encodedPathSegments() {
int pathStart = url.indexOf('/', scheme.length() + 3);
int pathEnd = delimiterOffset(url, pathStart, url.length(), "?#");
List result = new ArrayList<>();
for (int i = pathStart; i i++; // Skip the '/'.
int segmentEnd = delimiterOffset(url, i, pathEnd, '/');
result.add(url.substring(i, segmentEnd));
i = segmentEnd;
}
return result;
}

代码示例来源:origin: duzechao/OKHttpUtils

/**
* Returns the query of this URL, encoded for use in HTTP resource resolution. The returned string
* may be null (for URLs with no query), empty (for URLs with an empty query) or non-empty (all
* other URLs).
*/
public String encodedQuery() {
if (queryNamesAndValues == null) return null; // No query.
int queryStart = url.indexOf('?') + 1;
int queryEnd = delimiterOffset(url, queryStart + 1, url.length(), '#');
return url.substring(queryStart, queryEnd);
}

代码示例来源:origin: duzechao/OKHttpUtils

/** Returns the username, or an empty string if none is set. */
public String encodedUsername() {
if (username.isEmpty()) return "";
int usernameStart = scheme.length() + 3; // "://".length() == 3.
int usernameEnd = delimiterOffset(url, usernameStart, url.length(), ":@");
return url.substring(usernameStart, usernameEnd);
}

推荐阅读
  • 电话号码的字母组合解题思路和代码示例
    本文介绍了力扣题目《电话号码的字母组合》的解题思路和代码示例。通过使用哈希表和递归求解的方法,可以将给定的电话号码转换为对应的字母组合。详细的解题思路和代码示例可以帮助读者更好地理解和实现该题目。 ... [详细]
  • VScode格式化文档换行或不换行的设置方法
    本文介绍了在VScode中设置格式化文档换行或不换行的方法,包括使用插件和修改settings.json文件的内容。详细步骤为:找到settings.json文件,将其中的代码替换为指定的代码。 ... [详细]
  • 本文介绍了如何在给定的有序字符序列中插入新字符,并保持序列的有序性。通过示例代码演示了插入过程,以及插入后的字符序列。 ... [详细]
  • 个人学习使用:谨慎参考1Client类importcom.thoughtworks.gauge.Step;importcom.thoughtworks.gauge.T ... [详细]
  • CF:3D City Model(小思维)问题解析和代码实现
    本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ... [详细]
  • [大整数乘法] java代码实现
    本文介绍了使用java代码实现大整数乘法的过程,同时也涉及到大整数加法和大整数减法的计算方法。通过分治算法来提高计算效率,并对算法的时间复杂度进行了研究。详细代码实现请参考文章链接。 ... [详细]
  • 如何使用Java获取服务器硬件信息和磁盘负载率
    本文介绍了使用Java编程语言获取服务器硬件信息和磁盘负载率的方法。首先在远程服务器上搭建一个支持服务端语言的HTTP服务,并获取服务器的磁盘信息,并将结果输出。然后在本地使用JS编写一个AJAX脚本,远程请求服务端的程序,得到结果并展示给用户。其中还介绍了如何提取硬盘序列号的方法。 ... [详细]
  • Python语法上的区别及注意事项
    本文介绍了Python2x和Python3x在语法上的区别,包括print语句的变化、除法运算结果的不同、raw_input函数的替代、class写法的变化等。同时还介绍了Python脚本的解释程序的指定方法,以及在不同版本的Python中如何执行脚本。对于想要学习Python的人来说,本文提供了一些注意事项和技巧。 ... [详细]
  • HDFS2.x新特性
    一、集群间数据拷贝scp实现两个远程主机之间的文件复制scp-rhello.txtroothadoop103:useratguiguhello.txt推pushscp-rr ... [详细]
  • springmvc学习笔记(十):控制器业务方法中通过注解实现封装Javabean接收表单提交的数据
    本文介绍了在springmvc学习笔记系列的第十篇中,控制器的业务方法中如何通过注解实现封装Javabean来接收表单提交的数据。同时还讨论了当有多个注册表单且字段完全相同时,如何将其交给同一个控制器处理。 ... [详细]
  • 本文介绍了南邮ctf-web的writeup,包括签到题和md5 collision。在CTF比赛和渗透测试中,可以通过查看源代码、代码注释、页面隐藏元素、超链接和HTTP响应头部来寻找flag或提示信息。利用PHP弱类型,可以发现md5('QNKCDZO')='0e830400451993494058024219903391'和md5('240610708')='0e462097431906509019562988736854'。 ... [详细]
  • 本文介绍了一个题目的解法,通过二分答案来解决问题,但困难在于如何进行检查。文章提供了一种逃逸方式,通过移动最慢的宿管来锁门时跑到更居中的位置,从而使所有合格的寝室都居中。文章还提到可以分开判断两边的情况,并使用前缀和的方式来求出在任意时刻能够到达宿管即将锁门的寝室的人数。最后,文章提到可以改成O(n)的直接枚举来解决问题。 ... [详细]
  • Ihavethefollowingonhtml我在html上有以下内容<html><head><scriptsrc..3003_Tes ... [详细]
  • Imtryingtofigureoutawaytogeneratetorrentfilesfromabucket,usingtheAWSSDKforGo.我正 ... [详细]
  • 李逍遥寻找仙药的迷阵之旅
    本文讲述了少年李逍遥为了救治婶婶的病情,前往仙灵岛寻找仙药的故事。他需要穿越一个由M×N个方格组成的迷阵,有些方格内有怪物,有些方格是安全的。李逍遥需要避开有怪物的方格,并经过最少的方格,找到仙药。在寻找的过程中,他还会遇到神秘人物。本文提供了一个迷阵样例及李逍遥找到仙药的路线。 ... [详细]
author-avatar
贰少爷闯天涯_964
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有