Package com.thoughtworks.qdox.model.impl
Class DefaultJavaSource
- java.lang.Object
-
- com.thoughtworks.qdox.model.impl.DefaultJavaSource
-
- All Implemented Interfaces:
JavaSource
,java.io.Serializable
public class DefaultJavaSource extends java.lang.Object implements JavaSource, java.io.Serializable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<JavaClass>
classes
private ClassLibrary
classLibrary
private java.util.List<java.lang.String>
imports
private ModelWriterFactory
modelWriterFactory
private JavaPackage
pkg
private java.net.URL
url
-
Constructor Summary
Constructors Constructor Description DefaultJavaSource(ClassLibrary classLibrary)
Default constructor for the Default JavaSource
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addClass(JavaClass cls)
void
addImport(java.lang.String imp)
JavaClass
getClassByName(java.lang.String name)
Try to get any class of this source by name.java.util.List<JavaClass>
getClasses()
A List with all direct classes of this source, nevernull
java.lang.String
getClassNamePrefix()
If there's a package, return the packageName, followed by a dot, otherwise an empty Stringjava.lang.String
getCodeBlock()
Complete code representation of this sourcejava.util.List<java.lang.String>
getImports()
Retrieve all the importClassLibrary
getJavaClassLibrary()
private ModelWriter
getModelWriter()
JavaClass
getNestedClassByName(java.lang.String name)
Try to get the JavaClass child based on its name relative to the package.JavaPackage
getPackage()
The package of this source ornull
java.lang.String
getPackageName()
Returns the name of the package or an empty String if there's no packagejava.net.URL
getURL()
void
setModelWriterFactory(ModelWriterFactory modelWriterFactory)
void
setPackage(JavaPackage pkg)
void
setURL(java.net.URL url)
java.lang.String
toString()
-
-
-
Field Detail
-
classLibrary
private final ClassLibrary classLibrary
-
modelWriterFactory
private ModelWriterFactory modelWriterFactory
-
pkg
private JavaPackage pkg
-
imports
private final java.util.List<java.lang.String> imports
-
classes
private java.util.List<JavaClass> classes
-
url
private java.net.URL url
-
-
Constructor Detail
-
DefaultJavaSource
public DefaultJavaSource(ClassLibrary classLibrary)
Default constructor for the Default JavaSource- Parameters:
classLibrary
- the classLibrary, should not benull
-
-
Method Detail
-
setURL
public void setURL(java.net.URL url)
- Parameters:
url
- the URL of the source file- Since:
- 1.4
-
getURL
public java.net.URL getURL()
- Specified by:
getURL
in interfaceJavaSource
- Returns:
- the URL of the source file
-
getPackage
public JavaPackage getPackage()
The package of this source ornull
- Specified by:
getPackage
in interfaceJavaSource
- Returns:
- the package
-
setPackage
public void setPackage(JavaPackage pkg)
-
addImport
public void addImport(java.lang.String imp)
-
getImports
public java.util.List<java.lang.String> getImports()
Retrieve all the import- Specified by:
getImports
in interfaceJavaSource
- Returns:
- the imports, never
null
-
addClass
public void addClass(JavaClass cls)
-
getClasses
public java.util.List<JavaClass> getClasses()
A List with all direct classes of this source, nevernull
- Specified by:
getClasses
in interfaceJavaSource
- Returns:
- a list of JavaClasses, never
null
-
getCodeBlock
public java.lang.String getCodeBlock()
Complete code representation of this source- Specified by:
getCodeBlock
in interfaceJavaSource
- Returns:
- the code block of this source
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getClassNamePrefix
public java.lang.String getClassNamePrefix()
If there's a package, return the packageName, followed by a dot, otherwise an empty String- Specified by:
getClassNamePrefix
in interfaceJavaSource
- Returns:
- the class name prefix, otherwise an empty String
-
getNestedClassByName
public JavaClass getNestedClassByName(java.lang.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 interfaceJavaSource
- Parameters:
name
- the name of the class- Returns:
- the resolved JavaClass, otherwise
null
-
getClassByName
public JavaClass getClassByName(java.lang.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 interfaceJavaSource
- Parameters:
name
- the (fully qualified) name of the class- Returns:
- the matching class, otherwise
null
-
getJavaClassLibrary
public ClassLibrary getJavaClassLibrary()
- Specified by:
getJavaClassLibrary
in interfaceJavaSource
-
getPackageName
public java.lang.String getPackageName()
Returns the name of the package or an empty String if there's no package- Specified by:
getPackageName
in interfaceJavaSource
- 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()
-
-