Maven 文档

  • e4_564700
    了解作者
  • 202.4KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-15 02:49
    上传日期
NULL 博文链接:https://snowelf.iteye.com/blog/1403222
mvnex-examples.zip
内容介绍
package org.sonatype.mavenbook.weather; import java.io.InputStream; import java.util.Date; import java.util.HashMap; import java.util.Map; import org.apache.log4j.Logger; import org.dom4j.Document; import org.dom4j.DocumentFactory; import org.dom4j.io.SAXReader; import org.sonatype.mavenbook.weather.model.Location; import org.sonatype.mavenbook.weather.model.Condition; import org.sonatype.mavenbook.weather.model.Atmosphere; import org.sonatype.mavenbook.weather.model.Wind; import org.sonatype.mavenbook.weather.model.Weather; public class YahooParser { private static Logger log = Logger.getLogger(YahooParser.class); public Weather parse(String zip, InputStream inputStream) throws Exception { Weather weather = new Weather(); log.info( "Creating XML Reader" ); SAXReader xmlReader = createXmlReader(); Document doc = xmlReader.read( inputStream ); log.info( "Parsing XML Response" ); Location location = new Location(); location.setCity( doc.valueOf("/rss/channel/y:location/@city") ); location.setRegion( doc.valueOf("/rss/channel/y:location/@region") ); location.setCountry( doc.valueOf("/rss/channel/y:location/@country") ); location.setZip( zip ); weather.setLocation( location ); Condition condition = new Condition(); condition.setText( doc.valueOf("/rss/channel/item/y:condition/@text") ); condition.setTemp( doc.valueOf("/rss/channel/item/y:condition/@temp") ); condition.setCode( doc.valueOf("/rss/channel/item/y:condition/@code") ); condition.setDate( doc.valueOf("/rss/channel/item/y:condition/@date") ); condition.setWeather( weather ); weather.setCondition( condition ); Atmosphere atmosphere = new Atmosphere(); atmosphere.setHumidity( doc.valueOf("/rss/channel/y:atmosphere/@humidity") ); atmosphere.setVisibility( doc.valueOf("/rss/channel/y:atmosphere/@visibility") ); atmosphere.setPressure( doc.valueOf("/rss/channel/y:atmosphere/@pressure") ); atmosphere.setRising( doc.valueOf("/rss/channel/y:atmosphere/@rising") ); atmosphere.setWeather( weather ); weather.setAtmosphere( atmosphere ); Wind wind = new Wind(); wind.setChill( doc.valueOf("/rss/channel/y:wind/@chill") ); wind.setDirection( doc.valueOf("/rss/channel/y:wind/@direction") ); wind.setSpeed( doc.valueOf("/rss/channel/y:wind/@speed") ); wind.setWeather( weather ); weather.setWind( wind ); weather.setDate( new Date() ); return weather; } private SAXReader createXmlReader() { Map<String,String> uris = new HashMap<String,String>(); uris.put( "y", "http://xml.weather.yahoo.com/ns/rss/1.0" ); DocumentFactory factory = new DocumentFactory(); factory.setXPathNamespaceURIs( uris ); SAXReader xmlReader = new SAXReader(); xmlReader.setDocumentFactory( factory ); return xmlReader; } }
评论
    相关推荐
    • CasseBrique:https
      CasseBrique:https
    • plaintextoffenders:https
      纯文字罪犯 向报告的域的公开列表
    • 使用socket post 数据到httphttps
      使用socket post 数据到httphttps
    • nodejs http-server开启https的证书
      https证书文件,nodejs http-server开启https的证书,可以直接在本地启动https的协议,方便部署和使用。
    • http https 切换
      http https切换代码,能够实现网站在传输信息的过程中不易遭人盗取
    • Http2Https-crx插件
      将书签中的http转换为https 害怕用https书签替换旧的http书签? 随着许多网站迁移到https,旧的http书签使星标图像为空。 搜索并转换为https! ****************************************************** ***********...
    • LocomotiveCMS https to http-crx插件
      语言:English 将登录网址从https替换为http以进行开发 此扩展程序供使用机车cms开发应用程序时供个人使用。 为了易于在开发模式下使用,此扩展程序将https登录网址替换为http
    • http:https的镜像
      框架HTTP
    • CookieIsolator:分离 HTTPHTTPS cookie
      松散隔离:HTTP cookie 只能在 HTTP 通道中发送,而 HTTPS cookie 可以在 HTTP(不带安全标志)和 HTTPS 通道中发送。 严格隔离:HTTP cookie 和 HTTPS cookie 只能分别在 HTTPHTTPS 通道中发送。 Ext Secure...
    • https协议
      NULL 博文链接:https://willwen.iteye.com/blog/1988199