咖啡伴侶

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

          用XMLEncode輸出時候,如果有BigDecimal有時候不好使。
          原因是:如果類的變量在定義時候有初始值,而不是null,就必須要重載DefaultPersistenceDelegate的mutatesTo方法。
          關于這個說明,在網上這里可以看到:
          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
          ????????? };

          網上的牛人說:

          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);
          }

          主站蜘蛛池模板: 湖北省| 富蕴县| 新余市| 延边| 突泉县| 游戏| 大埔县| 平昌县| 漠河县| 揭阳市| 华容县| 怀化市| 十堰市| 太康县| 砀山县| 邯郸县| 西盟| 桑植县| 辽宁省| 黄陵县| 扶风县| 东台市| 名山县| 卢龙县| 祁东县| 涞源县| 清远市| 黔南| 东光县| 长岭县| 云阳县| 永和县| 通榆县| 溧阳市| 沐川县| 壶关县| 隆尧县| 阿克苏市| 澳门| 仁寿县| 綦江县|