首页 \ 问答 \ 从同一代码库编译J2ME和J2SE应用程序的最佳方法是什么?(What is the best way to compile J2ME and J2SE apps from the same codebase?)

从同一代码库编译J2ME和J2SE应用程序的最佳方法是什么?(What is the best way to compile J2ME and J2SE apps from the same codebase?)

我正在尝试为J2ME和J2SE构建一个应用程序。 演示代码显然会有所不同,但我希望尽可能保持逻辑的共性。

我的计划是使用Ant或Antenna的预处理器来选择J2ME或J2SE Graphics对象,该类是我的逻辑和显示代码之间的唯一交集。 我需要的是在Ant / Antenna构建任务期间在一些文件中交换一行或两行导入。

我想就如何设置这个问题提出一些建议。

我目前有两个Eclipse项目,一个J2ME和一个J2SE。 我对如何设置预处理器有几点想法:

  • 将J2SE代码作为缺省值,并且仅预处理J2SE代码以交换J2SE特定的导入
  • 对J2ME和J2SE项目使用Antenna预处理器
  • 使用Ant文本替换来进行必要的源修改

    一世。 看起来很难设置正确
    II。 感觉有点笨拙
    III。 看起来最不好,因为我认为自己不需要使用比一些条件导入更多的东西。

有没有人有这种事情的经验? 一些建议将非常感谢。


I'm trying to build an app for both J2ME and J2SE. The presentation code will obviously be different, but I'm hoping to keep the logic common, as much as possible.

My plan is to use Ant or Antenna's preprocessor to select either the J2ME or J2SE Graphics object, with that class being the only intersection between my logic and display code. All I need is to swap a line or two of imports in a few files during my Ant/Antenna build task.

I'd like some advice on how to get this set up.

I've currently got two Eclipse projects, one J2ME and one J2SE. I have a couple ideas for how I could set up the preprocessor:

  • Have the J2SE code be the default, and only preprocess the J2SE code to swap in the J2SE specific imports
  • Use the Antenna preprocessor for both the J2ME and J2SE projects
  • Use Ant text substitution to make the necessary source modifications

    i. looks hard to get set up right
    ii. feels a bit kludgy
    iii. seems least bad, because I don't see myself ever needing to use much more than a few conditional imports.

Has anyone had experience with this sort of thing? Some advice would be much appreciated.


原文:https://stackoverflow.com/questions/1290600
更新时间:2022-10-16 19:10

最满意答案

给定样本XML文档,以下XPath 1.0表达式将输出68

//span[contains(., '/123')]/following-sibling::span/text()

您可能需要调整参数的查找方式,但您应该明白这一点。


Given your sample XML document, following XPath 1.0 expression will output 68:

//span[contains(., '/123')]/following-sibling::span/text()

You likely need to adapt how the parameter is found, but you should get the idea.

相关问答

更多
  • 我会提供我的解决方案,它不像你最初那样简约。 有时在C ++模板中元编程代码增长得非常快。 但是,除了解决问题之外,我的解决方案还有另一个优点 - 它可以检查函数的返回类型。 您可以考虑使用预处理器来减少代码冗余。 template struct to_string_checker { template
  • 你不能在xml过滤器中的if else循环。 但是你可以有两个xml过滤器和if else循环,唯一的区别就是xpath创建的变量。 在这里,它将字符串Finch检查为消息值的正则表达式模式,以决定使用哪个xml过滤器。 if [message] =~ "Finch" { xml { source => "message" store_xml => false target => "stations" xpath => [ ...
  • 这个XPath返回toto : //*[local-name()='contribute'][*[local-name()='role']/*[local-name()='value'] = 'author']/*[local-name()='entity']/text() 如果删除最后一个/text() ,它将返回包含文本toto的entity元素。 我不确定你在找哪一个。 This XPath returns toto: //*[local-name()='contribute'][*[local-n ...
  • 如果你想选择那种效率不高的方式 ,你可以使用prevAll所有方法: $('a.selected').parent().prevAll('li:has("a.done")').find('a').attr('rel'); http://jsfiddle.net/pn72t/ 要么: $('a.selected').closest('ul').find("a.done:first").attr('rel') If you want to select the element that way which ...
  • 另一种方法 df <- data.frame(a=c(0, 1, 2, 2, 3), b=c(1, 3, 2, 4, 4)) df$a[c(df$b[-1], 0) == 2] <- df$a[c(df$b[-1], 0) == 2] + 3 Another approach df <- data.frame(a=c(0, 1, 2, 2, 3), b=c(1, 3, 2, 4, 4)) df$a[c(df$b[-1], 0) == 2] <- df ...
  • 另一个使用data.table选项 library(data.table) library(xts) dt <- data.table(df) dt[, Price := na.locf(Price, fromLast = TRUE), by = Meal] Another option using data.table library(data.table) library(xts) dt <- data.table(df) dt[, Price := na.locf(Price, fromLa ...
  • 给定样本XML文档,以下XPath 1.0表达式将输出68 : //span[contains(., '/123')]/following-sibling::span/text() 您可能需要调整参数的查找方式,但您应该明白这一点。 Given your sample XML document, following XPath 1.0 expression will output 68: //span[contains(., '/123')]/following-sibling::span/text() ...
  • 看看这个: http : //www.w3schools.com/xpath/xpath_syntax.asp 。 您正在请求的示例: XML文件: Harry Potter 29.99 Learning XML</ti ... </div> </div> </li> <li class="tw_li clearfix"> <div class="tw_li_con"> <div class="tw_li_title"> <h2><a href="/wenda/tiaojianxpathfanhuizhi_518" target="_blank">复杂条件和使用xpath返回的值(Complex condition and returned value using xpath)</a><i>[2022-07-31] </i></h2> </div> <div class="tw_li_cont"> 简单的xpath表达式: //Doc/*[text() != '0']/text() XPath结果: 150.0 45 I found a great and readable solution: Docs/Doc/*[starts-with(name(), 'tag') and .!=0][1]/text() </div> </div> </li> <li class="tw_li clearfix"> <div class="tw_li_con"> <div class="tw_li_title"> <h2><a href="/wenda/huozaixixpathzhongtiaojian_572" target="_blank">或在硒xpath中的条件(or condition in selenium xpath)</a><i>[2021-12-29] </i></h2> </div> <div class="tw_li_cont"> 使用烟斗| 选择更多节点: //tr/td[@class='name']/a | //tr/td[@class='name']/span[@class='complete'] 请参阅不同节点的XPath或运算符 Use pipe | to select more nodes: //tr/td[@class='name']/a | //tr/td[@class='name']/span[@class='complete'] See XPath or operator for different nodes ... </div> </div> </li> </ul> </div> <div class="main_right"> <div class="search-out"> <div class="search"> <form action="/wenda" target="_blank" method="get"> <input type="search" autocorrect="off" autocomplete="off" placeholder="请输入关键词" id="q" name="q" value=""> <button class="btn_s" type="submit">搜索</button> </form> </div> </div> <div class="commonh"> <h2>相关文章</h2> <span class="fr"><a href="/jiaocheng" target="_blank">更多</a></span> </div> <div class="right_list"> <li> <a title="J2EE J2SE J2ME到底何去何从?" href="/article/J2EEJ2SEJ2MEdaodihequhecong_5" target="_blank">J2EE J2SE J2ME到底何去何从?</a> </li> <li> <a title="《J2ME开发大全》(J2ME TheCompleteReference)中英文版[PDF]" href="/article/J2MEkfdqJ2METheCompleteReferencezywbPDF_0" target="_blank">《J2ME开发大全》(J2ME TheCompleteReference)中英文版[PDF]</a> </li> <li> <a title="孔浩J2SE项目视频教程(雇员管理项目视频教程)" href="/article/khJ2SExmspjcgyglxmspjc_1" target="_blank">孔浩J2SE项目视频教程(雇员管理项目视频教程)</a> </li> <li> <a title="Java codebase的Hadoop应用中使用Darts" href="/article/JavacodebasedHadoopyyzsyDarts_0" target="_blank">Java codebase的Hadoop应用中使用Darts</a> </li> <li> <a title="请教:log4j 问题" href="/article/qingjiaolog4jwenti_5" target="_blank">请教:log4j 问题</a> </li> <li> <a title="Solr 使用 Log4j" href="/article/SolrshiyongLog4j3482_2" target="_blank">Solr 使用 Log4j</a> </li> <li> <a title="问个log4j的应用一个问题。" href="/article/wengelog4jdeyingyongyigewenti_5" target="_blank">问个log4j的应用一个问题。</a> </li> <li> <a title="Solr 使用 Log4j" href="/article/SolrshiyongLog4j_2" target="_blank">Solr 使用 Log4j</a> </li> <li> <a title="Log4j 随笔" href="/article/Log4jsuibi_2" target="_blank">Log4j 随笔</a> </li> <li> <a title="mmseg4j相关" href="/article/mmseg4jxiangguan_2" target="_blank">mmseg4j相关</a> </li> </div> <div class="commonh"> <h2>最新问答</h2> <span class="fr"><a href="/wenda" target="_blank">更多</a></span> </div> <div class="right_list"> <li> <a title="您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)" href="/wenda/gitdiffwjbjyyyyckfbfz_166" target="_blank">您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)</a> </li> <li> <a title="将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)" href="/wenda/zfdzjqxsdfzdzfsz_208" target="_blank">将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)</a> </li> <li> <a title="OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)" href="/wenda/octobercmscebianlanchengxian_358" target="_blank">OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)</a> </li> <li> <a title="页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)" href="/wenda/ymjzdxzgljhs_380" target="_blank">页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)</a> </li> <li> <a title="codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)" href="/wenda/codeigniterzyybnayqgz_201" target="_blank">codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)</a> </li> <li> <a title="在计算机拍照在哪里进入" href="/wenda/jisuanjipaizhaozaina_8" target="_blank">在计算机拍照在哪里进入</a> </li> <li> <a title="使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)" href="/wenda/cingetczsrlzdqbxyzfdiscardunwant_470" target="_blank">使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)</a> </li> <li> <a title="No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)" href="/wenda/forxhjzforxhyx_517" target="_blank">No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)</a> </li> <li> <a title="单页应用程序:页面重新加载(Single Page Application: page reload)" href="/wenda/danyeyingyongchengxuyemianjiazai_103" target="_blank">单页应用程序:页面重新加载(Single Page Application: page reload)</a> </li> <li> <a title="在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)" href="/wenda/xunhuanzhongxuanmoshilieming_433" target="_blank">在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)</a> </li> <li> <a title="System.StackOverflow错误(System.StackOverflow error)" href="/wenda/systemstackoverflowcuowu_431" target="_blank">System.StackOverflow错误(System.StackOverflow error)</a> </li> <li> <a title="KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)" href="/wenda/knockoutjswzqtmbbeforeremoveafte_429" target="_blank">KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)</a> </li> <li> <a title="散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)" href="/wenda/sanliebaokuofangfaqiantaoshuxing_254" target="_blank">散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)</a> </li> <li> <a title="android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)" href="/wenda/androidsamsungrfswjxtycdj_556" target="_blank">android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)</a> </li> <li> <a title="TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)" href="/wenda/tensorflowsylbcjxz_538" target="_blank">TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)</a> </li> <li> <a title="企业安全培训的各项内容" href="/wenda/qiyeanquanpeixungexiangneirong_20" target="_blank">企业安全培训的各项内容</a> </li> <li> <a title="错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)" href="/wenda/cuowurpcshibai_88" target="_blank">错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)</a> </li> <li> <a title="C#类名中允许哪些字符?(What characters are allowed in C# class name?)" href="/wenda/cleimingzhongyunzifu_157" target="_blank">C#类名中允许哪些字符?(What characters are allowed in C# class name?)</a> </li> <li> <a title="NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)" href="/wenda/numpyint64zccnparrayzdtypefloat6_310" target="_blank">NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)</a> </li> <li> <a title="注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)" href="/wenda/zhuxiaoyinzangdaohangportlet_526" target="_blank">注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)</a> </li> <li> <a title="将多个行和可变行移动到列(moving multiple and variable rows to columns)" href="/wenda/duogexingkebianxingdongdaolie_442" target="_blank">将多个行和可变行移动到列(moving multiple and variable rows to columns)</a> </li> <li> <a title="提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)" href="/wenda/tjbdshljchrefbsjavascript_382" target="_blank">提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)</a> </li> <li> <a title="对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)" href="/wenda/setoninfowindowclicklisteneryitu_249" target="_blank">对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)</a> </li> <li> <a title="Angular $资源不会改变方法(Angular $resource doesn't change method)" href="/wenda/angularziyuanhuigaifangfa_275" target="_blank">Angular $资源不会改变方法(Angular $resource doesn't change method)</a> </li> <li> <a title="在Angular 5中不是一个函数(is not a function in Angular 5)" href="/wenda/angularzhonghanshu_308" target="_blank">在Angular 5中不是一个函数(is not a function in Angular 5)</a> </li> <li> <a title="如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)" href="/wenda/pzcompositec1mzmyzdtgfw_354" target="_blank">如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)</a> </li> <li> <a title="不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])" href="/wenda/bsxtxtsysfz_203" target="_blank">不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])</a> </li> <li> <a title="常见的python rpc和cli接口(Common python rpc and cli interface)" href="/wenda/changjianpythonrpcclijiekou_315" target="_blank">常见的python rpc和cli接口(Common python rpc and cli interface)</a> </li> <li> <a title="Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)" href="/wenda/mysqldbdgzdppdgzd_259" target="_blank">Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)</a> </li> <li> <a title="产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)" href="/wenda/chanpinyemianmagentochushouduiqi_417" target="_blank">产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)</a> </li> </div> </div> </div> </div> <div style="clear:both;"></div> <div class="footer"> <div class="mainbox"> <div class="info"> <p>Copyright ©2023 <a href="https://www.peixunduo.com" target="_blank">peixunduo.com</a> All Rights Reserved.<a href="https://beian.miit.gov.cn/" target="_blank">粤ICP备14003112号</a> </p> <p>本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!</p> </div> </div> </div> <script type="text/javascript" src="/resources/js/common.js?v=324"></script> <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https'){ bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else{ bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?9eebaceb5e4371a0aad59712a1a1ecff"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </body> </html>