public class DefaultJavaSource extends java.lang.Object implements JavaSource, java.io.Serializable
Modifier and Type | Field and 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 and Description |
---|
DefaultJavaSource(ClassLibrary classLibrary)
Default constructor for the Default JavaSource
|
Modifier and Type | Method and 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, never
null |
java.lang.String |
getClassNamePrefix()
If there's a package, return the packageName, followed by a dot, otherwise an empty String
|
java.lang.String |
getCodeBlock()
Complete code representation of this source
|
java.util.List<java.lang.String> |
getImports()
Retrieve all the import
|
ClassLibrary |
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 or
null |
java.lang.String |
getPackageName()
Returns the name of the package or an empty String if there's no package
|
java.net.URL |
getURL() |
void |
setModelWriterFactory(ModelWriterFactory modelWriterFactory) |
void |
setPackage(JavaPackage pkg) |
void |
setURL(java.net.URL url) |
java.lang.String |
toString() |
private final ClassLibrary classLibrary
private ModelWriterFactory modelWriterFactory
private JavaPackage pkg
private final java.util.List<java.lang.String> imports
private java.util.List<JavaClass> classes
private java.net.URL url
public DefaultJavaSource(ClassLibrary classLibrary)
classLibrary
- the classLibrary, should not be null
public void setURL(java.net.URL url)
url
- the URL of the source filepublic java.net.URL getURL()
getURL
in interface JavaSource
public JavaPackage getPackage()
null
getPackage
in interface JavaSource
public void setPackage(JavaPackage pkg)
public void addImport(java.lang.String imp)
public java.util.List<java.lang.String> getImports()
getImports
in interface JavaSource
null
public void addClass(JavaClass cls)
public java.util.List<JavaClass> getClasses()
null
getClasses
in interface JavaSource
null
public java.lang.String getCodeBlock()
getCodeBlock
in interface JavaSource
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getClassNamePrefix()
getClassNamePrefix
in interface JavaSource
public JavaClass getNestedClassByName(java.lang.String name)
getNestedClassByName
in interface JavaSource
name
- the name of the classnull
public JavaClass getClassByName(java.lang.String name)
getClassByName
in interface JavaSource
name
- the (fully qualified) name of the classnull
public ClassLibrary getJavaClassLibrary()
getJavaClassLibrary
in interface JavaSource
public java.lang.String getPackageName()
getPackageName
in interface JavaSource
public void setModelWriterFactory(ModelWriterFactory modelWriterFactory)
modelWriterFactory
- the modelWriterFactoryprivate ModelWriter getModelWriter()