咖啡伴侶

          呆在上海
          posts - 163, comments - 156, trackbacks - 0, articles - 2

          用XMLEncode輸出時(shí)候,如果有BigDecimal有時(shí)候不好使。
          原因是:如果類(lèi)的變量在定義時(shí)候有初始值,而不是null,就必須要重載DefaultPersistenceDelegate的mutatesTo方法。
          關(guān)于這個(gè)說(shuō)明,在網(wǎng)上這里可以看到:
          http://forum.java.sun.com/thread.jspa?threadID=631299&messageID=3642493

          有興趣的可以看看:
          //setup big decimal delegate.
          ????????? DefaultPersistenceDelegate bigDecimalDelegate = new DefaultPersistenceDelegate() {
          ????????????? protected Expression instantiate(Object oldInstance, Encoder out) {
          ????????????????? BigDecimal decimal = (BigDecimal) oldInstance;
          ????????????????? return new Expression(oldInstance, oldInstance.getClass(), "new", new Object[] {decimal.toString()});
          ????????????? }
          ????????????? //must override this method.
          ????????????? // see http://forum.java.sun.com/thread.jspa?threadID=631299&messageID=3642493
          ????????????? protected boolean mutatesTo(Object oldInstance, Object newInstance) {
          ????????????????? return oldInstance.equals(newInstance);
          ????????????? }
          ????????????? //--- Joshua
          ????????? };

          網(wǎng)上的牛人說(shuō):

          This works for BigDecimal properties that aren't initialized, i.e. null. But if you initialize the property, then this won't work unless you override mutatesTo in addition to instantiate mentioned above:

          protected boolean mutatesTo(Object oldInstance, Object newInstance) {
          return oldInstance.equals(newInstance);
          }

          主站蜘蛛池模板: 澎湖县| 双桥区| 通城县| 五台县| 尼玛县| 信阳市| 柏乡县| 崇州市| 金坛市| 镇沅| 瑞安市| 盐源县| 棋牌| 托克托县| 乐至县| 华池县| 镇宁| 博客| 固镇县| 德化县| 云和县| 开化县| 鹰潭市| 东乌珠穆沁旗| 重庆市| 易门县| 江门市| 中西区| 肥西县| 乐山市| 清流县| 曲水县| 安福县| 安岳县| 鲜城| 宣武区| 来安县| 合川市| 兴隆县| 南陵县| 麻城市|