当前位置: 首页>>代码示例>>Java>>正文


Java ParseException类代码示例

本文整理汇总了Java中org.apache.http.ParseException的典型用法代码示例。如果您正苦于以下问题:Java ParseException类的具体用法?Java ParseException怎么用?Java ParseException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ParseException类属于org.apache.http包,在下文中一共展示了ParseException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseHeader

import org.apache.http.ParseException; //导入依赖的package包/类
public HeaderElement parseHeader(
        final CharArrayBuffer buffer,
        final ParserCursor cursor) throws ParseException {
    if (buffer == null) {
        throw new IllegalArgumentException("Char array buffer may not be null");
    }
    if (cursor == null) {
        throw new IllegalArgumentException("Parser cursor may not be null");
    }
    NameValuePair nvp = parseNameValuePair(buffer, cursor);
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    while (!cursor.atEnd()) {
        NameValuePair param = parseNameValuePair(buffer, cursor);
        params.add(param);
    }
    return new BasicHeaderElement(
            nvp.getName(),
            nvp.getValue(), params.toArray(new NameValuePair[params.size()]));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:NetscapeDraftHeaderParser.java

示例2: getContentCharSet

import org.apache.http.ParseException; //导入依赖的package包/类
/**
 * Obtains character set of the entity, if known.
 *
 * @param entity must not be null
 * @return the character set, or null if not found
 * @throws ParseException if header elements cannot be parsed
 * @throws IllegalArgumentException if entity is null
 *
 * @deprecated (4.1.3) use {@link ContentType#getOrDefault(HttpEntity)}
 */
@Deprecated
public static String getContentCharSet(final HttpEntity entity) throws ParseException {
    if (entity == null) {
        throw new IllegalArgumentException("HTTP entity may not be null");
    }
    String charset = null;
    if (entity.getContentType() != null) {
        HeaderElement values[] = entity.getContentType().getElements();
        if (values.length > 0) {
            NameValuePair param = values[0].getParameterByName("charset");
            if (param != null) {
                charset = param.getValue();
            }
        }
    }
    return charset;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:EntityUtils.java

示例3: main

import org.apache.http.ParseException; //导入依赖的package包/类
public static void main(String[] args) throws ParseException, IOException {
	HttpRequestUtil util = new HttpRequestUtil();
	CloseableHttpClient client = util.setDoubleInit();
	
	Map<String,String> map = new HashMap<>();
	CloseableHttpResponse httpPost = util.httpPost(client, "https://127.0.0.1:8443/pwp-web/login.do", map);
	
	HttpEntity entity = httpPost.getEntity();
	String string = EntityUtils.toString(entity, Charset.defaultCharset());
	
	System.out.println(string);
}
 
开发者ID:strictnerd,项目名称:LearningSummary,代码行数:13,代码来源:HttpRequestUtil.java

示例4: getByteArray

import org.apache.http.ParseException; //导入依赖的package包/类
/**
 * 获取响应内容为字节数组
 * 
 * 
 * @date 2015年7月17日
 * @return
 */
public byte[] getByteArray() {
	try {
		return EntityUtils.toByteArray(entity);
	} catch (ParseException | IOException e) {
		logger.error(e.getMessage(), e);
		throw new RuntimeException(e.getMessage(), e);
	}
}
 
开发者ID:swxiao,项目名称:bubble2,代码行数:16,代码来源:ResponseWrap.java

示例5: apiDataCubeGetInterfaceSummaryHour

import org.apache.http.ParseException; //导入依赖的package包/类
/**
 * 获取接口分析小时数据。
 * 
 * @param date
 * @return
 * @throws AccessTokenFailException
 * @throws ParseException
 * @throws IOException
 * @throws URISyntaxException
 */
public DataCubeGetInterfaceSummaryHourResp apiDataCubeGetInterfaceSummaryHour(java.sql.Date date)
		throws AccessTokenFailException, ParseException, IOException, URISyntaxException {
	MpAccessToken token = mpApi.apiToken();
	String path = String.format("/datacube/getinterfacesummaryhour?access_token=%s", token.getAccessToken());
	TreeMap<String, Object> reqMap = new TreeMap<String, Object>();
	reqMap.put("begin_date", date);
	reqMap.put("end_date", date);
	String respText = HttpUtil.post(mpApi.config.getApiHttps(), path, reqMap);
	DataCubeGetInterfaceSummaryHourResp resp = new Gson().fromJson(respText,
			DataCubeGetInterfaceSummaryHourResp.class);
	if (mpApi.log.isInfoEnabled()) {
		mpApi.log.info(String.format("apiDataCubeGetInterfaceSummaryHour %s", resp));
	}
	return resp;
}
 
开发者ID:AlexLee-CN,项目名称:weixin_api,代码行数:26,代码来源:MpDataCubeApi.java

示例6: apiSnsOAuth2RefreshToken

import org.apache.http.ParseException; //导入依赖的package包/类
/**
 * 刷新微信用户网页授权AccessToken。如果是开放平台模式则此方法内部会调用OpenApi中获取。
 * 由于此api使用频次比较低,因此未进行缓存,要求业务系统保存OAuthAccessToken,特别是其中的refresh_token。
 * 
 * @param refreshToken
 * @return
 * @throws AccessTokenFailException
 * @throws URISyntaxException
 * @throws IOException
 * @throws ParseException
 */
public OAuthAccessToken apiSnsOAuth2RefreshToken(String refreshToken)
		throws AccessTokenFailException, ParseException, IOException, URISyntaxException {
	if (mpApi.config.isOpenMode()) {// 公众平台模式
		return OpenApi.getInstance().apiSnsOAuth2ComponentRefreshToken(mpApi.appid, refreshToken);
	}
	String path = String.format("/oauth2/refresh_token?mpApi.appid=%s&grant_type=refresh_token&refresh_token=%s",
			mpApi.config.getAppId(), refreshToken);
	String respText = HttpUtil.get(mpApi.config.getApiOAuth(), path);
	OAuthAccessToken resp = new Gson().fromJson(respText, OAuthAccessToken.class);
	if (mpApi.log.isInfoEnabled()) {
		mpApi.log.info(String.format("apiSnsOAuth2RefreshToken %s", resp));
	}
	return resp;

}
 
开发者ID:AlexLee-CN,项目名称:weixin_api,代码行数:27,代码来源:MpWebApi.java

示例7: apiSnsOAuth2ComponentAccessToken

import org.apache.http.ParseException; //导入依赖的package包/类
/**
 * 获取微信用户网页授权AccessToken。
 * 由于此api使用频次比较低,因此要求业务系统保存OAuthAccessToken,特别是其中的refresh_token。
 * 如果网页授权的作用域为snsapi_base,则本步骤中获取到网页授权access_token的同时,也获取到了openid,snsapi_base式的网页授权流程即到此为止。
 * 
 * @param mpAppid
 * @param code
 * 
 * @return
 * @throws AccessTokenFailException
 * @throws URISyntaxException
 * @throws IOException
 * @throws ParseException
 */
public OAuthAccessToken apiSnsOAuth2ComponentAccessToken(String mpAppid, String code)
		throws AccessTokenFailException, ParseException, IOException, URISyntaxException {
	ComponentAccessToken caToken = apiComponentToken();
	String path = String.format(
			"/oauth2/component/access_token?appid=%s&code=%s&grant_type=authorization_code&component_appid=%s&component_access_token=%s",
			mpAppid, code, config.getComponentAppid(), caToken.getComponentAccessToken());

	String respText = HttpUtil.get(config.getApiOAuth(), path);
	OAuthAccessToken resp = new Gson().fromJson(respText, OAuthAccessToken.class);
	if (log.isInfoEnabled()) {
		log.info(String.format("apiOAuth2ComponentAccessToken %s", resp));
	}
	return resp;

}
 
开发者ID:AlexLee-CN,项目名称:weixin_api,代码行数:30,代码来源:OpenApi.java

示例8: waitForContent

import org.apache.http.ParseException; //导入依赖的package包/类
protected Optional<String> waitForContent(String url) {
    return Stream.generate(() -> {
                try {
                    Thread.sleep(1000);
                    System.out.println(url);
                    return getUrlContentPage(url);
                } catch (ParseException | IOException | InterruptedException e) {
                    return null;
                } finally {
                    
                }
            })
        .limit(TestUtils.NB_ITERATION_MAX)
        .filter(content -> content != null && !content.contains("404"))
        .findFirst();
}
 
开发者ID:oncecloud,项目名称:devops-cstack,代码行数:17,代码来源:AbstractDeploymentControllerIT.java

示例9: deserialize

import org.apache.http.ParseException; //导入依赖的package包/类
/**
 * Deserializes an HTTP response entity to a given class.
 * 
 * @param entity
 *            the HTTP response entity to be deserialized.
 * @param cls
 *            the target class.
 * @return the response deserialized to the target class.
 * @throws HttpResponseException
 *             when the response cannot be deserialized to the given entity
 *             class.
 */
static <T> T deserialize(HttpEntity entity, Class<T> cls) throws HttpResponseException {
	if (entity == null) {
		logger.error(ERROR_ENTITY_CANNOT_BE_NULL);

		throw new IllegalArgumentException(ERROR_ENTITY_CANNOT_BE_NULL);
	}

	T result = null;
	try {
		logger.debug(DEBUG_CONVERTING_HTTP_ENTITY);
		result = GsonProvider.getInstance().fromJson(EntityUtils.toString(entity, StandardCharsets.UTF_8), cls);
	} catch (ParseException | IOException e) {
		String errorMessage = MessageFormat
				.format(ERROR_PROBLEM_OCCURED_WHILE_CONVERTING_RESPONSE_ENTITY_TO_CLASS_MESSAGE, cls.getName());
		logger.error(errorMessage);
		throw new HttpResponseException(errorMessage, e);
	}

	logger.debug(DEBUG_CONVERTED_HTTP_ENTITY);
	return result;
}
 
开发者ID:SAP,项目名称:cloud-ariba-partner-flow-extension-ext,代码行数:34,代码来源:HttpResponseUtils.java

示例10: parseElements

import org.apache.http.ParseException; //导入依赖的package包/类
/**
 * Parses elements with the given parser.
 *
 * @param value     the header value to parse
 * @param parser    the parser to use, or <code>null</code> for default
 *
 * @return  array holding the header elements, never <code>null</code>
 */
public final static
    HeaderElement[] parseElements(final String value,
                                  HeaderValueParser parser)
    throws ParseException {

    if (value == null) {
        throw new IllegalArgumentException
            ("Value to parse may not be null");
    }

    if (parser == null)
        parser = BasicHeaderValueParser.DEFAULT;

    CharArrayBuffer buffer = new CharArrayBuffer(value.length());
    buffer.append(value);
    ParserCursor cursor = new ParserCursor(0, value.length());
    return parser.parseElements(buffer, cursor);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:BasicHeaderValueParser.java

示例11: parseHeaderElement

import org.apache.http.ParseException; //导入依赖的package包/类
/**
 * Parses an element with the given parser.
 *
 * @param value     the header element to parse
 * @param parser    the parser to use, or <code>null</code> for default
 *
 * @return  the parsed header element
 */
public final static
    HeaderElement parseHeaderElement(final String value,
                                     HeaderValueParser parser)
    throws ParseException {

    if (value == null) {
        throw new IllegalArgumentException
            ("Value to parse may not be null");
    }

    if (parser == null)
        parser = BasicHeaderValueParser.DEFAULT;

    CharArrayBuffer buffer = new CharArrayBuffer(value.length());
    buffer.append(value);
    ParserCursor cursor = new ParserCursor(0, value.length());
    return parser.parseHeaderElement(buffer, cursor);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:BasicHeaderValueParser.java

示例12: parseParameters

import org.apache.http.ParseException; //导入依赖的package包/类
/**
 * Parses parameters with the given parser.
 *
 * @param value     the parameter list to parse
 * @param parser    the parser to use, or <code>null</code> for default
 *
 * @return  array holding the parameters, never <code>null</code>
 */
public final static
    NameValuePair[] parseParameters(final String value,
                                    HeaderValueParser parser)
    throws ParseException {

    if (value == null) {
        throw new IllegalArgumentException
            ("Value to parse may not be null");
    }

    if (parser == null)
        parser = BasicHeaderValueParser.DEFAULT;

    CharArrayBuffer buffer = new CharArrayBuffer(value.length());
    buffer.append(value);
    ParserCursor cursor = new ParserCursor(0, value.length());
    return parser.parseParameters(buffer, cursor);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:BasicHeaderValueParser.java

示例13: parseNameValuePair

import org.apache.http.ParseException; //导入依赖的package包/类
/**
 * Parses a name-value-pair with the given parser.
 *
 * @param value     the NVP to parse
 * @param parser    the parser to use, or <code>null</code> for default
 *
 * @return  the parsed name-value pair
 */
public final static
   NameValuePair parseNameValuePair(final String value,
                                    HeaderValueParser parser)
    throws ParseException {

    if (value == null) {
        throw new IllegalArgumentException
            ("Value to parse may not be null");
    }

    if (parser == null)
        parser = BasicHeaderValueParser.DEFAULT;

    CharArrayBuffer buffer = new CharArrayBuffer(value.length());
    buffer.append(value);
    ParserCursor cursor = new ParserCursor(0, value.length());
    return parser.parseNameValuePair(buffer, cursor);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:BasicHeaderValueParser.java

示例14: findNext

import org.apache.http.ParseException; //导入依赖的package包/类
/**
 * Determines the next token.
 * If found, the token is stored in {@link #currentToken}.
 * The return value indicates the position after the token
 * in {@link #currentHeader}. If necessary, the next header
 * will be obtained from {@link #headerIt}.
 * If not found, {@link #currentToken} is set to <code>null</code>.
 *
 * @param from      the position in the current header at which to
 *                  start the search, -1 to search in the first header
 *
 * @return  the position after the found token in the current header, or
 *          negative if there was no next token
 *
 * @throws ParseException   if an invalid header value is encountered
 */
protected int findNext(int from)
    throws ParseException {

    if (from < 0) {
        // called from the constructor, initialize the first header
        if (!this.headerIt.hasNext()) {
            return -1;
        }
        this.currentHeader = this.headerIt.nextHeader().getValue();
        from = 0;
    } else {
        // called after a token, make sure there is a separator
        from = findTokenSeparator(from);
    }

    int start = findTokenStart(from);
    if (start < 0) {
        this.currentToken = null;
        return -1; // nothing found
    }

    int end = findTokenEnd(start);
    this.currentToken = createToken(this.currentHeader, start, end);
    return end;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:42,代码来源:BasicTokenIterator.java

示例15: BufferedHeader

import org.apache.http.ParseException; //导入依赖的package包/类
/**
 * Creates a new header from a buffer.
 * The name of the header will be parsed immediately,
 * the value only if it is accessed.
 *
 * @param buffer    the buffer containing the header to represent
 *
 * @throws ParseException   in case of a parse error
 */
public BufferedHeader(final CharArrayBuffer buffer)
    throws ParseException {

    super();
    if (buffer == null) {
        throw new IllegalArgumentException
            ("Char array buffer may not be null");
    }
    int colon = buffer.indexOf(':');
    if (colon == -1) {
        throw new ParseException
            ("Invalid header: " + buffer.toString());
    }
    String s = buffer.substringTrimmed(0, colon);
    if (s.length() == 0) {
        throw new ParseException
            ("Invalid header: " + buffer.toString());
    }
    this.buffer = buffer;
    this.name = s;
    this.valuePos = colon + 1;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:BufferedHeader.java


注:本文中的org.apache.http.ParseException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。