Simpleframework xml属性为空

时间:2015-02-07 17:16:37

标签: java xml simple-framework

我有自定义LayoutTree,我想添加属性"说"在XMLLayout类中如下:

<layout stroke="NORTH_WEST">
      <XMLLayout label=".,!" speak="Знаки препинания">
         <characters stroke="EAST">
            <XMLCharacterGroup>.</XMLCharacterGroup>
         </characters>
      </XMLLayout>
   </layout>

所以我在课堂上添加了fild(没有我的成瘾它完美无缺):

@Root
    private static class XMLLayout {

        private static final String EMPTY_LABEL = "";

        @Attribute(required=false)
        private String label;
        @Attribute(required=false)
        private String speak;

        @ElementMapUnion({
            @ElementMap(entry="characters", key="stroke", attribute=true, inline=true, valueType=XMLCharacterGroup.class),
            @ElementMap(entry="controlCharacter", key="stroke", attribute=true, inline=true, valueType=XMLControlCharacter.class)
        })
        private Map<StrokeType, XMLStrokeCharacters> strokeToCharacters =
                new HashMap<StrokeType, XMLStrokeCharacters>(StrokeType.values().length);

    // constructors


        public String getLabel() {
            if (label == null)
                label = generateDefaultLabel();

            return label;
        }

        public void setLabel(String label) {
            if (label == null)
                throw new AssertionError();

            this.label = label;
        }

        public String getSpeak() {
            if(speak == null)
               speak = "Тэг пуст";

            return speak;
        }

        public void setSpeak(String speak)
        {
            if(speak == null)
                throw new AssertionError();

            this.speak = speak;
        }
// other functions...
    }

所以&#34;说&#34;总是空的。如果我使required = true,那么everithing就是粉碎,而cos布局是空的。怎么了?

0 个答案:

没有答案