是否有适用于Java的RFC 2397数据URI解析器? [英] Any RFC 2397 Data URI Parser for Java?

查看:112
本文介绍了是否有适用于Java的RFC 2397数据URI解析器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

   dataurl    := "data:" [ mediatype ] [ ";base64" ] "," data
   mediatype  := [ type "/" subtype ] *( ";" parameter )
   data       := *urlchar
   parameter  := attribute "=" value

   value := token / quoted-string

根据RFC中的这些BNF,将数据与mime类型分开的逗号实际上可以同时出现在mime类型和数据中,因此没有简单的方法(即reg ex)将URI分成多个部分.因此,需要完整的解析器.

According to these BNF from the RFCs, the comma that separates the data from the mime type can actually appear in both the mime type and the data, so there's no simple way (i.e. reg ex) to break the URI into parts. Thus a full parser is needed.

我想知道是否有人知道Java中的任何数据URI库?我的Google搜索没有任何结果.

I am wondering does any one know any data URI libraries in Java? My Google search didn't yield anything.

推荐答案

我最终不得不实现自己的解析器. RFC提供了BNF,因此可以实现完整的词法分析器和语法分析器.但是,对于这种简单的情况,我认为使用简单的扫描+堆栈机制可以跟踪引用的字符串并找到分隔的逗号. javax.activation的MimeType用于实际的Mime解析.

I ended up having to implement my own parser. The RFCs provided BNFs, so it's possible to implement full lexers and syntax analysers. However, for this simple case, I jused used a simple scanning + stack mechamism to trace the quoted strings and locate the separating comma. javax.activation's MimeType is used for actual Mime parsing.

这篇关于是否有适用于Java的RFC 2397数据URI解析器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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