Class CElementPropertyInfo

    • Method Detail

      • getTypes

        public List<CTypeRef> getTypes()
        Description copied from interface: ElementPropertyInfo
        Returns the information about the types allowed in this property.

        In a simple case like the following, an element property only has one TypeRef that points to String and tag name "foo".

         @XmlElement
         String abc;
         

        However, in a general case an element property can be heterogeneous, meaning you can put different types in it, each with a different tag name (and a few other settings.)

        
         // list can contain String or Integer.
         @XmlElements({
           @XmlElement(name="a",type=String.class),
           @XmlElement(name="b",type=Integer.class),
         })
         List<Object> abc;
         

        In this case this method returns a list of two TypeRefs.

        Specified by:
        getTypes in interface ElementPropertyInfo<NType,​NClass>
        Returns:
        Always non-null. Contains at least one entry. If ElementPropertyInfo.isValueList()==true, there's always exactly one type.
      • ref

        public List<CNonElement> ref()
        Description copied from interface: PropertyInfo
        List of TypeInfos that this property references. This allows the caller to traverse the reference graph without getting into the details of each different property type.
        Specified by:
        ref in interface PropertyInfo<NType,​NClass>
        Specified by:
        ref in class CPropertyInfo
        Returns:
        non-null read-only collection.
      • getSchemaType

        public QName getSchemaType()
        Description copied from interface: PropertyInfo
        The effective value of XmlSchemaType annotation, if any.

        If the property doesn't have XmlSchemaType annotation, this method returns null.

        Since a type name is a property of a Java type, not a Java property, A schema type name of a Java type should be primarily obtained by using NonElement.getTypeName(). This method is to correctly implement the ugly semantics of XmlSchemaType (namely when this returns non-null, it overrides the type names of all types that are in this property.)

        Specified by:
        getSchemaType in interface PropertyInfo<NType,​NClass>
      • isCollectionNillable

        public boolean isCollectionNillable()
        Description copied from interface: ElementPropertyInfo
        Returns true if this property is nillable (meaning the absence of the value is treated as nil='true')

        This method is only used when this property is a collection.

        Specified by:
        isCollectionNillable in interface ElementPropertyInfo<NType,​NClass>
      • isRequired

        public boolean isRequired()
        Description copied from interface: ElementPropertyInfo
        Returns true if this element is mandatory. For collections, this property isn't used. TODO: define the semantics when this is a collection
        Specified by:
        isRequired in interface ElementPropertyInfo<NType,​NClass>
      • isUnboxable

        public boolean isUnboxable()
        Description copied from class: CPropertyInfo
        Returns true if this property is "unboxable".

        In general, a property often has to be capable of representing null to indicate the absence of the value. This requires properties to be generated as @XmlElement Float f, not as @XmlElement float f;. But this is slow.

        Fortunately, there are cases where we know that the property can never legally be absent. When this condition holds we can generate the optimized "unboxed form".

        The exact such conditions depend on the kind of properties, so refer to the implementation code for the details.

        This method returns true when the property can be generated as "unboxed form", false otherwise.

        When this property is a collection, this method returns true if items in the collection is unboxable. Obviously, the collection itself is always a reference type.

        Overrides:
        isUnboxable in class CPropertyInfo
      • isOptionalPrimitive

        public boolean isOptionalPrimitive()
        Description copied from class: CPropertyInfo
        Returns true if this property needs to represent null just for the purpose of representing an absence of the property.
        Overrides:
        isOptionalPrimitive in class CPropertyInfo
      • setAdapter

        public void setAdapter​(CAdapter a)
      • collectElementNames

        public QName collectElementNames​(Map<QName,​CPropertyInfo> table)
        Description copied from class: CPropertyInfo
        Puts the element names that this property possesses to the map, so that we can find two properties that own the same element name, which is an error.
        Overrides:
        collectElementNames in class CPropertyInfo
        Returns:
        null if no conflict was found. Otherwise return the QName that has the collision.