if語句在下面的代碼中做了什麼?在if語句中使用return時會做什麼?
public void startElement(String namespaceURI, String localName,String qName,
Attributes atts) throws SAXException
{
depth++;
if (localName.equals("channel"))
{
currentstate = 0;
return;
}
if (localName.equals("image"))
{
// record our feed data - you temporarily stored it in the item :)
_feed.setTitle(_item.getTitle());
_feed.setPubDate(_item.getPubDate());
}
if (localName.equals("item"))
{
// create a new item
_item = new RSSItem();
return;
}
if (localName.equals("title"))
{
currentstate = RSS_TITLE;
return;
}
if (localName.equals("description"))
{
currentstate = RSS_DESCRIPTION;
return;
}
if (localName.equals("link"))
{
currentstate = RSS_LINK;
return;
}
if (localName.equals("category"))
{
currentstate = RSS_CATEGORY;
return;
}
if (localName.equals("pubDate"))
{
currentstate = RSS_PUBDATE;
return;
}
// if you don't explicitly handle the element, make sure you don't wind
// up erroneously storing a newline or other bogus data into one of our
// existing elements
currentstate = 0;
}
它是否將我們從if語句中移出並進入下一條語句,或者將我們帶出了startElement方法?
好像這裏被張貼在同一時間和同一內容的所有的答案! – medopal