Class CPropertyInfo

    • Field Summary

      Fields 
      Modifier and Type Field Description
      JType baseType
      If the base type of the property is overriden, this field is set to non-null.
      CDefaultValue defaultValue
      If non-null, keeps the default value in Java representation.
      boolean inlineBinaryData
      Property annotated with XmlInlineBinaryData.
      java.lang.String javadoc
      Javadoc for this property.
      org.xml.sax.Locator locator  
      FieldRenderer realization
      Specifies how the field is generated by the backend.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected CPropertyInfo​(java.lang.String name, boolean collection, XSComponent source, CCustomizations customizations, org.xml.sax.Locator locator)  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      abstract <V> V accept​(CPropertyVisitor<V> visitor)  
      abstract <R,​P>
      R
      accept​(CPropertyVisitor2<R,​P> visitor, P p)  
      javax.xml.namespace.QName collectElementNames​(java.util.Map<javax.xml.namespace.QName,​CPropertyInfo> table)
      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.
      java.lang.String displayName()
      Gets the display name of the property.
      abstract CAdapter getAdapter()  
      CCustomizations getCustomizations()
      Gets the list of customizations attached to this model component.
      org.xml.sax.Locator getLocator()
      Gets the source location in the schema from which this model component is created.
      java.lang.String getName()
      Deprecated.
      marked as deprecated so that we can spot the use of this method.
      java.lang.String getName​(boolean isPublic)
      Gets the name of the property.
      XSComponent getSchemaComponent()
      If this model object is built from XML Schema, this property returns a schema component from which the model is built.
      boolean hasAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
      Returns true if the property has the specified annotation.
      boolean inlineBinaryData()
      If this is true and this property indeed represents a binary data, it should be always inlined.
      boolean isCollection()
      Returns true if this is a multi-valued collection property.
      boolean isOptionalPrimitive()
      Returns true if this property needs to represent null just for the purpose of representing an absence of the property.
      boolean isUnboxable()
      Returns true if this property is "unboxable".
      protected static boolean needsExplicitTypeName​(TypeUse type, javax.xml.namespace.QName typeName)
      Checks if the given TypeUse would need an explicit XmlSchemaType annotation with the given type name.
      CTypeInfo parent()
      Gets the ClassInfo or ElementInfo to which this property belongs.
      <A extends java.lang.annotation.Annotation>
      A
      readAnnotation​(java.lang.Class<A> annotationType)
      Gets the value of the specified annotation from the given property.
      abstract java.util.Collection<? extends CTypeInfo> ref()
      List of TypeInfos that this property references.
      void setName​(boolean isPublic, java.lang.String newName)
      Overrides the name of the property.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • locator

        public final org.xml.sax.Locator locator
      • baseType

        public JType baseType
        If the base type of the property is overriden, this field is set to non-null.
      • javadoc

        public java.lang.String javadoc
        Javadoc for this property. Must not be null.
      • inlineBinaryData

        public boolean inlineBinaryData
        Property annotated with XmlInlineBinaryData.
      • realization

        public FieldRenderer realization
        Specifies how the field is generated by the backend.
      • defaultValue

        public CDefaultValue defaultValue
        If non-null, keeps the default value in Java representation. If isCollection is true, this field is always null, for we don't handle default values for a list.
    • Constructor Detail

      • CPropertyInfo

        protected CPropertyInfo​(java.lang.String name,
                                boolean collection,
                                XSComponent source,
                                CCustomizations customizations,
                                org.xml.sax.Locator locator)
    • Method Detail

      • getLocator

        public org.xml.sax.Locator getLocator()
        Description copied from interface: CCustomizable
        Gets the source location in the schema from which this model component is created.
        Specified by:
        getLocator in interface CCustomizable
        Returns:
        never null.
      • getSchemaComponent

        public final XSComponent getSchemaComponent()
        If this model object is built from XML Schema, this property returns a schema component from which the model is built.
        Specified by:
        getSchemaComponent in interface CCustomizable
        Returns:
        null if the model is built from sources other than XML Schema (such as DTD.)
      • getName

        public java.lang.String getName()
        Deprecated.
        marked as deprecated so that we can spot the use of this method.
        Name of the property.

        This method is implemented to follow the contract of PropertyInfo.getName(), and therefore it always returns the name of the annotated field.

        This name is normally not useful for the rest of XJC, which usually wants to access the "public name" of the property. A "public name" of the property is a name like "FooBar" which is used as a seed for generating the accessor methods. This is the name controlled by the schema customization via users.

        If the caller is calling this method statically, it's usually the sign of a mistake. Use getName(boolean) method instead, which forces you to think about which name you want to get.

        Specified by:
        getName in interface PropertyInfo<NType,​NClass>
        See Also:
        getName(boolean)
      • getName

        public java.lang.String getName​(boolean isPublic)
        Gets the name of the property.
        Parameters:
        isPublic - if true, this method returns a name like "FooBar", which should be used as a seed for generating user-visible names (such as accessors like "getFooBar".)

        if false, this method returns the "name of the property" as defined in the j2s side of the spec. This name is usually something like "fooBar", which often corresponds to the XML element/attribute name of this property (for taking advantage of annotation defaulting as much as possible)

      • setName

        public void setName​(boolean isPublic,
                            java.lang.String newName)
        Overrides the name of the property. This method can be used from Plugin.postProcessModel(Model, ErrorHandler). But the caller should do so with the understanding that this is inherently dangerous method.
      • displayName

        public java.lang.String displayName()
        Description copied from interface: PropertyInfo
        Gets the display name of the property.

        This is a convenience method for parent().getName()+'#'+getName().

        Specified by:
        displayName in interface PropertyInfo<NType,​NClass>
      • isCollection

        public boolean isCollection()
        Description copied from interface: PropertyInfo
        Returns true if this is a multi-valued collection property. Otherwise false, in which case the property is a single value.
        Specified by:
        isCollection in interface PropertyInfo<NType,​NClass>
      • ref

        public abstract java.util.Collection<? extends CTypeInfo> 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>
        Returns:
        non-null read-only collection.
      • isUnboxable

        public boolean isUnboxable()
        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.

      • isOptionalPrimitive

        public boolean isOptionalPrimitive()
        Returns true if this property needs to represent null just for the purpose of representing an absence of the property.
      • inlineBinaryData

        public boolean inlineBinaryData()
        Description copied from interface: PropertyInfo
        If this is true and this property indeed represents a binary data, it should be always inlined.
        Specified by:
        inlineBinaryData in interface PropertyInfo<NType,​NClass>
      • accept

        public abstract <R,​P> R accept​(CPropertyVisitor2<R,​P> visitor,
                                             P p)
      • needsExplicitTypeName

        protected static boolean needsExplicitTypeName​(TypeUse type,
                                                       javax.xml.namespace.QName typeName)
        Checks if the given TypeUse would need an explicit XmlSchemaType annotation with the given type name.
      • collectElementNames

        public javax.xml.namespace.QName collectElementNames​(java.util.Map<javax.xml.namespace.QName,​CPropertyInfo> table)
        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.
        Returns:
        null if no conflict was found. Otherwise return the QName that has the collision.
      • readAnnotation

        public final <A extends java.lang.annotation.Annotation> A readAnnotation​(java.lang.Class<A> annotationType)
        Description copied from interface: AnnotationSource
        Gets the value of the specified annotation from the given property.

        When this method is used for a property that consists of a getter and setter, it returns the annotation on either of those methods. If both methods have the same annotation, it is an error.

        Specified by:
        readAnnotation in interface AnnotationSource
        Returns:
        null if the annotation is not present.
      • hasAnnotation

        public final boolean hasAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
        Description copied from interface: AnnotationSource
        Returns true if the property has the specified annotation.

        Short for readAnnotation(annotationType)!=null, but this method is typically faster.

        Specified by:
        hasAnnotation in interface AnnotationSource