本文整理汇总了Java中android.sax.RootElement类的典型用法代码示例。如果您正苦于以下问题:Java RootElement类的具体用法?Java RootElement怎么用?Java RootElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RootElement类属于android.sax包,在下文中一共展示了RootElement类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import android.sax.RootElement; //导入依赖的package包/类
/**
* Parses the xml String targets
*
* @param xml the xml
* @return the list©
* @author RayBa
* @throws org.xml.sax.SAXException
* @date 11.01.2015
*/
public List<String> parse(InputStream xml) throws SAXException, IOException {
RootElement root = new RootElement("targets");
Element targetElement = root.getChild("target");
root.setStartElementListener(new StartElementListener() {
@Override
public void start(Attributes attributes) {
targets = new ArrayList<String>();
}
});
targetElement.setEndTextElementListener(new EndTextElementListener() {
@Override
public void end(String body) {
targets.add(body);
}
});
Xml.parse(xml, Xml.Encoding.UTF_8, root.getContentHandler());
return targets;
}
示例2: getContentHandler
import android.sax.RootElement; //导入依赖的package包/类
@NonNull
private ContentHandler getContentHandler() {
RootElement root = new RootElement("version");
root.setEndTextElementListener(new EndTextElementListener() {
@Override
public void end(String body) {
result = body;
}
});
return root.getContentHandler();
}
示例3: contentHandler
import android.sax.RootElement; //导入依赖的package包/类
@Override
protected ContentHandler contentHandler()
{
photos_ = new Photos();
final RootElement root = new RootElement("markers");
final Element item = root.getChild("marker");
item.setStartElementListener(new StartElementListener() {
@Override
public void start(final Attributes attributes)
{
final String id = attributes.getValue("id");
final String feature = attributes.getValue("feature");
final String caption = attributes.getValue("caption");
final String url = attributes.getValue("shortlink");
final String thumbnailUrl = attributes.getValue("thumbnailUrl");
final String lat = attributes.getValue("latitude");
final String lon = attributes.getValue("longitude");
try {
final Photo newPhoto = new Photo(Integer.parseInt(id),
feature,
caption,
url,
thumbnailUrl,
new GeoPoint(Double.parseDouble(lat),
Double.parseDouble(lon)));
photos_.add(newPhoto);
} // try
catch(Exception e) {
// never mind
} // catch
} // start
});
return root.getContentHandler();
}
示例4: contentHandler
import android.sax.RootElement; //导入依赖的package包/类
@Override
protected ContentHandler contentHandler()
{
cats_ = new PhotomapCategories();
final RootElement root = new RootElement("photomapcategories");
final Element cat = root.getChild("categories").getChild("category");
final Element metaCat = root.getChild("metacategories").getChild("metacategory");
final Listener listener = new Listener();
cat.setStartElementListener(listener.start());
metaCat.setStartElementListener(listener.start());
for(final String n : listener.endListeners().keySet())
{
final EndTextElementListener l = listener.endListeners().get(n);
cat.getChild(n).setEndTextElementListener(l);
metaCat.getChild(n).setEndTextElementListener(l);
} // for ...
cat.setEndElementListener(new EndElementListener(){
public void end() {
cats_.addCategory(listener.tag(),
listener.name(),
listener.description(),
listener.ordering());
} // end
});
metaCat.setEndElementListener(new EndElementListener(){
public void end() {
cats_.addMetaCategory(listener.tag(),
listener.name(),
listener.description(),
listener.ordering());
} // end
});
return root.getContentHandler();
}
示例5: getContent
import android.sax.RootElement; //导入依赖的package包/类
@Override
public Object getContent(URLConnection connection) throws IOException {
final Directory directory = new Directory();
RootElement root = new RootElement("", "root");
Element element = root.getChild("", "element");
element.setStartElementListener(new StartElementListener() {
/** {@inheritDoc} */
public void start(Attributes attributes) {
File file = createFile(attributes);
directory.add(file);
}
});
parse(connection, root.getContentHandler());
return directory;
}