安卓的URLConnection的调用setRequestProperty功能,这是什么方法呢? [英] Android: setRequestProperty function of URLConnection, what does this method do?

查看:938
本文介绍了安卓的URLConnection的调用setRequestProperty功能,这是什么方法呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然我知道计算器早已<一个href=\"http://stackoverflow.com/questions/15334920/setrequestproperty-function-of-httpurlconnection\">setRequestProperty HttpURLConnection的问题的功能,我真不明白这是什么方法做。我不能 步入它在调试时(F7)。我pressed Ctrl-B键来查看方法的身体,但它只具有以下code:

Although I know that StackOverflow has already setRequestProperty function of HttpURLConnection question, I really don't understand what this method does. I cannot "step into" it (F7) when debugging. I pressed Ctrl-B to view the method's body, but it only has the following code:

public void setRequestProperty(String field, String newValue) {
        checkNotConnected();
        if (field == null) {
            throw new NullPointerException("field == null");
        }
    }

checkNotConnected

private void checkNotConnected() {
        if (connected) {
            throw new IllegalStateException("Already connected");
        }
    }

我的意思是在哪里code,它会将价值的领域呢?任何的解释是AP preciated。

I mean that where is the code that puts the value to the field? Any explanation is appreciated.

更新(2015年8月8日):
我发现,查看其执行的方式。由于它是抽象的,必须使用Ctrl-Alt键-B,而不是按Ctrl-B来查看。

UPDATE (2015/08/08): I have found the way to view its implementation. Since it's abstract, must use Ctrl-Alt-B instead of Ctrl-B to view.

推荐答案

我猜你是访问了错误的方式,还是有某种保护code的...

I guess you are accessing the wrong way, or have some kind of protected code...

最初的功能是这样的:

/**
 * Sets the general request property. If a property with the key already
 * exists, overwrite its value with the new value.
 * ...
 */
public void setRequestProperty(String key, String value) {
    if (connected)
        throw new IllegalStateException("Already connected");
    if (key == null)
        throw new NullPointerException ("key is null");

    if (requests == null)
        requests = new MessageHeader();

    requests.set(key, value);
}

其中, requests.set(键,值)做什么你问的!)

这篇关于安卓的URLConnection的调用setRequestProperty功能,这是什么方法呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆