zoukankan      html  css  js  c++  java
  • JAXB

    Types for XML elements are constructed using xsd:complexType, even if they do not have content. The snippet below defines a simple element with two attributes and no sub-elements.

    <xsd:complexType name="RouteType">
        <xsd:attribute name="Pos" type="xsd:int" use="optional" default="1"/>
        <xsd:attribute name="Dir" type="DirType" use="required"/>
    </xsd:complexType>

    The compiler generates a class RouteType with getters and setters for the attributes.

    public class RouteType {
    
        protected Integer pos;
        protected String dir;
    
        public int getPos() {
            if (pos == null) {
                return  1;
            } else {
                return pos;
            }
        }
    
        public void setPos(Integer value) {
            this.pos = value;
        }
    
        public String getDir() {
            return dir;
        }
    
        public void setDir(String value) {
            this.dir = value;
        }
    }

    The absence of a value for the optional attribute Pos is represented by an object where the instance variable pos remains at null. Method getPos takes care of supplying the default value if the variable is null.

  • 相关阅读:
    cstc2018 混合果汁
    CF1086E Beautiful Matrix
    AT2000 Leftmost Ball
    CF1208E Let Them Slide
    CF1208D Restore Permutation
    【置顶】博客公告
    [NOI2015]软件包管理器
    【noip2018】积木大赛
    几天连测总结
    【ZJOI2007】棋盘制作
  • 原文地址:https://www.cnblogs.com/huey/p/5505179.html
Copyright © 2011-2022 走看看