Class DefaultJavaSource

java.lang.Object
com.thoughtworks.qdox.model.impl.DefaultJavaSource
All Implemented Interfaces:
JavaSource, Serializable

public class DefaultJavaSource extends Object implements JavaSource, Serializable
See Also:
  • Field Details

  • Constructor Details

    • DefaultJavaSource

      public DefaultJavaSource(ClassLibrary classLibrary)
      Default constructor for the Default JavaSource
      Parameters:
      classLibrary - the classLibrary, should not be null
  • Method Details

    • setURL

      public void setURL(URL url)
      Parameters:
      url - the URL of the source file
      Since:
      1.4
    • getURL

      public URL getURL()
      Specified by:
      getURL in interface JavaSource
      Returns:
      the URL of the source file
    • getPackage

      public JavaPackage getPackage()
      The package of this source or null
      Specified by:
      getPackage in interface JavaSource
      Returns:
      the package
    • setPackage

      public void setPackage(JavaPackage pkg)
    • addImport

      public void addImport(String imp)
    • getImports

      public List<String> getImports()
      Retrieve all the import
      Specified by:
      getImports in interface JavaSource
      Returns:
      the imports, never null
    • addClass

      public void addClass(JavaClass cls)
    • getClasses

      public List<JavaClass> getClasses()
      A List with all direct classes of this source, never null
      Specified by:
      getClasses in interface JavaSource
      Returns:
      a list of JavaClasses, never null
    • getCodeBlock

      public String getCodeBlock()
      Complete code representation of this source
      Specified by:
      getCodeBlock in interface JavaSource
      Returns:
      the code block of this source
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getClassNamePrefix

      public String getClassNamePrefix()
      If there's a package, return the packageName, followed by a dot, otherwise an empty String
      Specified by:
      getClassNamePrefix in interface JavaSource
      Returns:
      the class name prefix, otherwise an empty String
    • getNestedClassByName

      public JavaClass getNestedClassByName(String name)
      Try to get the JavaClass child based on its name relative to the package. This doesn't try to resolve it by recursion.
      Specified by:
      getNestedClassByName in interface JavaSource
      Parameters:
      name - the name of the class
      Returns:
      the resolved JavaClass, otherwise null
    • getClassByName

      public JavaClass getClassByName(String name)
      Try to get any class of this source by name. The name can be both the fully qualified name or just the name of the class.
      Specified by:
      getClassByName in interface JavaSource
      Parameters:
      name - the (fully qualified) name of the class
      Returns:
      the matching class, otherwise null
    • getJavaClassLibrary

      public ClassLibrary getJavaClassLibrary()
      Specified by:
      getJavaClassLibrary in interface JavaSource
    • getPackageName

      public String getPackageName()
      Returns the name of the package or an empty String if there's no package
      Specified by:
      getPackageName in interface JavaSource
      Returns:
      the package name, otherwise an empty String
    • setModelWriterFactory

      public void setModelWriterFactory(ModelWriterFactory modelWriterFactory)
      Parameters:
      modelWriterFactory - the modelWriterFactory
      Since:
      2.0
    • getModelWriter

      private ModelWriter getModelWriter()