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
-
-
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 voidaddClass(JavaClass cls)voidaddImport(java.lang.String imp)JavaClassgetClassByName(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, nevernulljava.lang.StringgetClassNamePrefix()If there's a package, return the packageName, followed by a dot, otherwise an empty Stringjava.lang.StringgetCodeBlock()Complete code representation of this sourcejava.util.List<java.lang.String>getImports()Retrieve all the importClassLibrarygetJavaClassLibrary()JavaClassgetNestedClassByName(java.lang.String name)Try to get the JavaClass child based on its name relative to the package.JavaPackagegetPackage()The package of this source ornulljava.lang.StringgetPackageName()Returns the name of the package or an empty String if there's no packagejava.net.URLgetURL()voidsetModelWriterFactory(ModelWriterFactory modelWriterFactory)voidsetPackage(JavaPackage pkg)voidsetURL(java.net.URL url)java.lang.StringtoString()
-
-
-
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:
getURLin interfaceJavaSource- Returns:
- the URL of the source file
-
getPackage
public JavaPackage getPackage()
The package of this source ornull- Specified by:
getPackagein 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:
getImportsin 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:
getClassesin interfaceJavaSource- Returns:
- a list of JavaClasses, never
null
-
getCodeBlock
public java.lang.String getCodeBlock()
Complete code representation of this source- Specified by:
getCodeBlockin interfaceJavaSource- Returns:
- the code block of this source
-
toString
public java.lang.String toString()
- Overrides:
toStringin 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:
getClassNamePrefixin 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:
getNestedClassByNamein 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:
getClassByNamein interfaceJavaSource- Parameters:
name- the (fully qualified) name of the class- Returns:
- the matching class, otherwise
null
-
getJavaClassLibrary
public ClassLibrary getJavaClassLibrary()
- Specified by:
getJavaClassLibraryin interfaceJavaSource
-
getPackageName
public java.lang.String getPackageName()
Returns the name of the package or an empty String if there's no package- Specified by:
getPackageNamein interfaceJavaSource- Returns:
- the package name, otherwise an empty String
-
setModelWriterFactory
public void setModelWriterFactory(ModelWriterFactory modelWriterFactory)
- Parameters:
modelWriterFactory- the modelWriterFactory- Since:
- 2.0
-
-