Class ClassHolder

    • Field Detail

      • COLLECTION_VARIABLE_TYPE

        protected static final java.lang.String COLLECTION_VARIABLE_TYPE
        See Also:
        Constant Field Values
      • COLLECTION_VARIABLE_NAME

        protected static final java.lang.String COLLECTION_VARIABLE_NAME
        See Also:
        Constant Field Values
      • s_logger

        private static final Logger s_logger
        Logger for class.
      • s_transformer

        private static final javax.xml.transform.Transformer s_transformer
        Null transformer used to output text form of documentation.
      • m_name

        private final java.lang.String m_name
        Simple class name.
      • m_superClass

        private TypeData m_superClass
        Superclass to be extended as part of schema model (null if none).
      • m_superName

        private java.lang.String m_superName
        Superclass name to be extended if extension not required by model (null if none).
      • m_generated

        private boolean m_generated
        Class generated flag.
      • m_classBuilder

        private ClassBuilder m_classBuilder
        Builder for class.
      • m_schemaCustom

        private SchemaCustom m_schemaCustom
        Customizations for the schema containing the schema component matching this class.
      • m_package

        protected final PackageHolder m_package
        Package containing class.
      • m_holder

        protected final BindingHolder m_holder
        Holder for class binding definition.
      • m_nameConverter

        protected final NameConverter m_nameConverter
        Name conversion handler.
      • m_baseName

        protected final java.lang.String m_baseName
        Base class name (for use when generating separate classes for nested structures).
      • m_decorators

        protected final ClassDecorator[] m_decorators
        Decorators to be called in order during class code generation.
      • m_useInnerClasses

        protected final boolean m_useInnerClasses
        Use inner classes for substructures flag.
      • m_inners

        protected final LazyList m_inners
        Holders for inner classes defined within this class (null if an inner class).
      • m_outerClass

        protected final ClassHolder m_outerClass
        Containing class (null if not an inner class).
      • m_importsTracker

        protected final ImportsTracker m_importsTracker
        Tracker for imports.
      • m_listImplClass

        protected java.lang.String m_listImplClass
        Class used for initializing list instances.
      • m_nameSet

        protected UniqueNameSet m_nameSet
        Value names used in class.
    • Constructor Detail

      • ClassHolder

        public ClassHolder​(java.lang.String name,
                           java.lang.String base,
                           PackageHolder pack,
                           BindingHolder holder,
                           NameConverter nconv,
                           ClassDecorator[] decorators,
                           boolean inner,
                           boolean simple)
        Constructor.
        Parameters:
        name - class name
        base - base class name
        pack - package information
        holder - binding holder
        nconv - name converter
        decorators - class decorators
        inner - use inner classes for substructures
        simple - simple value flag
      • ClassHolder

        protected ClassHolder​(java.lang.String name,
                              ClassHolder context,
                              boolean simple)
        Constructor for creating a child inner class definition.
        Parameters:
        name - class name
        context - parent class
        simple - simple value flag
    • Method Detail

      • buildName

        private static java.lang.String buildName​(java.lang.String name,
                                                  PackageHolder pack)
        Build fully-qualified class name
        Parameters:
        name - simple class name
        pack - package information
        Returns:
        fully-qualified class name
      • getSchemaCustom

        public SchemaCustom getSchemaCustom()
        Get the schema customization associated with root schema component matching this class.
        Returns:
        schema customization
      • extractDocumentation

        protected java.lang.String extractDocumentation​(AnnotatedBase element)
        Extract schema documentation from an element. This just checks for an annotation element on the supplied element, and if found returns a text string consisting of the content of all documentation element(s). The returned documentation text is suitable for use as JavaDoc content, with any JavaDoc end sequences ('*' followed by '/') substituted with a space added.
        Parameters:
        element -
        Returns:
        content of documentation elements, or null if none
      • describe

        protected static java.lang.String describe​(ClassHolder.DataNode node)
        Describe the schema component associated with a node. If the component for the supplied node is a named element or attribute, this just returns a combination of the name and type of that component. Otherwise, it moves up the node tree until it finds a named element or attribute, terminating if any parent has more than one child. If it can't find an element or attribute name but does find a named type, it uses that type as the name. If all else fails, it just returns the type of the highest level component found.
        Parameters:
        node -
        Returns:
        name
      • importValueType

        protected void importValueType​(ClassHolder.DataNode value)
        Import the type associated with an item, if not directly accessible
        Parameters:
        value -
      • buildDataStructure

        public void buildDataStructure​(GroupItem group,
                                       BindingHolder bindhold)
        Convert an item structure to a class representation. Subclasses need to override this method for thie own handling, but should call the base class implementatino first to initialize the schema customization link.
        Parameters:
        group - item group
        bindhold - associated binding definition holder
      • getPackage

        public PackageHolder getPackage()
        Get containing package.
        Returns:
        package
      • getName

        public java.lang.String getName()
        Get simple name.
        Specified by:
        getName in interface IClassHolder
        Returns:
        name
      • getOuterClass

        public IClassHolder getOuterClass()
        Get containing class of inner class.
        Specified by:
        getOuterClass in interface IClassHolder
        Returns:
        outer containing class, or null if not an inner class
      • getSuperClass

        public TypeData getSuperClass()
        Get base class to be extended.
        Returns:
        base (null if none)
      • setSuperClass

        public void setSuperClass​(TypeData sclas)
        Set superclass to be extended.
        Parameters:
        sclas - (null if none)
      • isSuperClassForced

        public boolean isSuperClassForced()
        Check if superclass is forced by schema model.
        Specified by:
        isSuperClassForced in interface IClassHolder
        Returns:
        true if superclass forced, false if not
      • getSuperClassName

        public java.lang.String getSuperClassName()
        Get name of base class to be extended.
        Specified by:
        getSuperClassName in interface IClassHolder
        Returns:
        base (null if none)
      • setSuperClassName

        public void setSuperClassName​(java.lang.String base)
        Set name of base class to be extended. This method can only be used if a superclass has not been forced by the schema model. It is always safe to use this method if getSuperClassName() returns null.
        Specified by:
        setSuperClassName in interface IClassHolder
        Parameters:
        base - fully-qualified class name of base class (null if none)
      • setListImplementation

        public void setListImplementation​(java.lang.String list)
        Set name of list implementation class to be used for initializing instances.
        Specified by:
        setListImplementation in interface IClassHolder
        Parameters:
        list - fully-qualified class name of list implementation (non-null)
      • isGenerated

        public boolean isGenerated()
        Check if the class has been generated. This should always be called before calling generate(boolean, SourceBuilder), in order to prevent multiple generation passes over the same class.
        Returns:
        true if generated, false if not
      • getBuilder

        protected ClassBuilder getBuilder()
        Get the builder for this class.
        Returns:
        builder
      • getInterfaces

        public java.lang.String[] getInterfaces()
        Get the interfaces implemented by this class.
        Specified by:
        getInterfaces in interface IClassHolder
        Returns:
        interface names
      • getImports

        public ImportsTracker getImports()
        Get imports information.
        Returns:
        imports
      • getFields

        public FieldDeclaration[] getFields()
        Get the fields defined in this class.
        Specified by:
        getFields in interface IClassHolder
        Returns:
        fields
      • getMethods

        public MethodDeclaration[] getMethods()
        Get the methods defined in this class.
        Specified by:
        getMethods in interface IClassHolder
        Returns:
        methods
      • addImport

        public boolean addImport​(java.lang.String fqname)
        Add import for class. If the requested import doesn't conflict with the current set it's added, otherwise it's ignored.
        Specified by:
        addImport in interface IClassHolder
        Parameters:
        fqname - fully qualified class name
        Returns:
        true if added as import
      • getTypeName

        public java.lang.String getTypeName​(java.lang.String type)
        Get the name to be used for a type. If the type has been imported this returns the short form of the name; otherwise it just returns the fully-qualified name.
        Specified by:
        getTypeName in interface IClassHolder
        Parameters:
        type - fully qualified class name
        Returns:
        name
      • addInterface

        public void addInterface​(java.lang.String interf)
        Add an interface to this class definition.
        Specified by:
        addInterface in interface IClassHolder
        Parameters:
        interf - interface type
      • addField

        public void addField​(FieldDeclaration field)
        Add separately-constructed field to this class definition.
        Specified by:
        addField in interface IClassHolder
        Parameters:
        field -
      • addMethod

        public void addMethod​(MethodDeclaration method)
        Add separately-constructed method declaration to this class definition.
        Specified by:
        addMethod in interface IClassHolder
        Parameters:
        method -
      • addType

        public void addType​(TypeDeclaration type)
        Add separately-constructed inner class declaration to this class definition.
        Specified by:
        addType in interface IClassHolder
        Parameters:
        type -
      • getSortedFields

        public StringPair[] getSortedFields()
        Get a sorted array of the field names and types defined in this class.
        Returns:
        sorted pairs
      • initClass

        protected void initClass​(boolean verbose,
                                 ClassBuilder builder,
                                 ClassHolder.ParentNode root)
        Initialize the class construction. This is a support method for use by subclasses, which handles common setup including superclass generation.
        Parameters:
        verbose -
        builder -
        root - data structure tree root node
      • finishClass

        protected void finishClass​(ElementBase binding)
        Finish class construction. This is a support method for use by subclasses, which handles common completion processing
        Parameters:
        binding - binding definition component for this class
      • generateInner

        protected void generateInner​(boolean verbose,
                                     SourceBuilder builder)
        Generate any inner classes of this class.
        Parameters:
        verbose -
        builder - class source file builder
      • generate

        public abstract void generate​(boolean verbose,
                                      SourceBuilder builder)
        Generate this class. Subclasses must implement this method to first do the appropriate setup and then call initClass(boolean, ClassBuilder, ParentNode) before doing their own code generation.
        Parameters:
        verbose -
        builder - class source file builder