Forge - Parent 1.0.6-SNAPSHOT

org.jboss.forge.maven.facets
Class MavenJavaSourceFacet

java.lang.Object
  extended by org.jboss.forge.project.facets.BaseFacet
      extended by org.jboss.forge.maven.facets.MavenJavaSourceFacet
All Implemented Interfaces:
Facet, JavaSourceFacet

@Dependent
@Alias(value="forge.maven.JavaSourceFacet")
@RequiresFacet(value=MavenCoreFacet.class)
public class MavenJavaSourceFacet
extends BaseFacet
implements JavaSourceFacet, Facet

Author:
Lincoln Baxter, III

Field Summary
 
Fields inherited from class org.jboss.forge.project.facets.BaseFacet
project
 
Constructor Summary
MavenJavaSourceFacet()
           
 
Method Summary
 String calculateName(JavaResource resource)
          Return the class name for the given JavaResource whether it exists or not.
 String calculatePackage(JavaResource resource)
          Return the package for the given JavaResource whether it exists or not.
 String getBasePackage()
          Return the base Java Package for this project, returned as a String
 DirectoryResource getBasePackageResource()
          Return the base Java Package for this project, returned as a directory File
 JavaResource getEnumTypeResource(JavaEnum javaEnum)
          Attempt to locate and re-parse the given JavaEnum from its location on disk, relative to JavaSourceFacet.getSourceFolder().
 JavaResource getEnumTypeResource(String relativePath)
          Return the JavaEnum at the given path relative to JavaSourceFacet.getSourceFolder().
 JavaResource getJavaResource(JavaSource<?> javaClass)
          Attempt to locate and re-parse the given JavaClass from its location on disk, relative to JavaSourceFacet.getSourceFolder().
 JavaResource getJavaResource(String relativePath)
          Return the JavaClass at the given path relative to JavaSourceFacet.getSourceFolder().
 DirectoryResource getSourceFolder()
          Get the DirectoryResource this Project uses to store package-able source documents (such as .java files.)
 List<DirectoryResource> getSourceFolders()
          Get a list of DirectoryResources this project uses to contain Project source documents (such as .java files.)
 JavaResource getTestJavaResource(JavaSource<?> javaClass)
          Attempt to locate and re-parse the given JavaClass from its location on disk, relative to JavaSourceFacet.getTestSourceFolder().
 JavaResource getTestJavaResource(String relativePath)
          Return the JavaClass at the given path relative to JavaSourceFacet.getTestSourceFolder().
 DirectoryResource getTestSourceFolder()
          Get the DirectoryResource this Project uses to store test-scoped source documents (such as .java files.) Files in this directory will never be packaged or deployed except when running Unit Tests.
 boolean install()
          Perform necessary setup for this Facet to be considered installed in the given Project.
 boolean isInstalled()
          Return true if the Facet is available for the given Project, false if otherwise.
 JavaResource saveEnumTypeSource(JavaEnum source)
          Create or update a Java file in the primary source directory: JavaSourceFacet.getSourceFolder() - use information in the given JavaEnum to determine the appropriate package; packages will be created if necessary.
 JavaResource saveJavaSource(JavaSource<?> source)
          Create or update a Java file in the primary source directory: JavaSourceFacet.getSourceFolder() - use information in the given JavaSource to determine the appropriate package; packages will be created if necessary.
 JavaResource saveTestJavaSource(JavaSource<?> source)
          Create or update a Java file in the primary test source directory: JavaSourceFacet.getTestSourceFolder() - use information in the given JavaSource to determine the appropriate package; packages will be created if necessary.
 void visitJavaSources(JavaResourceVisitor visitor)
          Recursively loops over all the source directories and for each java file it finds, calls the visitor.
 void visitJavaTestSources(JavaResourceVisitor visitor)
          Recursively loops over all the test source directories and for each java file it finds, calls the visitor.
 
Methods inherited from class org.jboss.forge.project.facets.BaseFacet
equals, getProject, hashCode, setProject, uninstall
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.forge.project.Facet
getProject, setProject, uninstall
 

Constructor Detail

MavenJavaSourceFacet

public MavenJavaSourceFacet()
Method Detail

getSourceFolders

public List<DirectoryResource> getSourceFolders()
Description copied from interface: JavaSourceFacet
Get a list of DirectoryResources this project uses to contain Project source documents (such as .java files.)

Specified by:
getSourceFolders in interface JavaSourceFacet

calculateName

public String calculateName(JavaResource resource)
Description copied from interface: JavaSourceFacet
Return the class name for the given JavaResource whether it exists or not.

Specified by:
calculateName in interface JavaSourceFacet

calculatePackage

public String calculatePackage(JavaResource resource)
Description copied from interface: JavaSourceFacet
Return the package for the given JavaResource whether it exists or not.

Specified by:
calculatePackage in interface JavaSourceFacet

getBasePackage

public String getBasePackage()
Description copied from interface: JavaSourceFacet
Return the base Java Package for this project, returned as a String

Specified by:
getBasePackage in interface JavaSourceFacet

getBasePackageResource

public DirectoryResource getBasePackageResource()
Description copied from interface: JavaSourceFacet
Return the base Java Package for this project, returned as a directory File

Specified by:
getBasePackageResource in interface JavaSourceFacet

getSourceFolder

public DirectoryResource getSourceFolder()
Description copied from interface: JavaSourceFacet
Get the DirectoryResource this Project uses to store package-able source documents (such as .java files.)

Specified by:
getSourceFolder in interface JavaSourceFacet

getTestSourceFolder

public DirectoryResource getTestSourceFolder()
Description copied from interface: JavaSourceFacet
Get the DirectoryResource this Project uses to store test-scoped source documents (such as .java files.) Files in this directory will never be packaged or deployed except when running Unit Tests.

Specified by:
getTestSourceFolder in interface JavaSourceFacet

isInstalled

public boolean isInstalled()
Description copied from interface: Facet
Return true if the Facet is available for the given Project, false if otherwise.

Specified by:
isInstalled in interface Facet

install

public boolean install()
Description copied from interface: Facet
Perform necessary setup for this Facet to be considered installed in the given Project. This method should NOT register the facet; facet registration is handled by the project if installation is successful.

Specified by:
install in interface Facet
Returns:
true if installation was successful, false if not.

getJavaResource

public JavaResource getJavaResource(JavaSource<?> javaClass)
                             throws FileNotFoundException
Description copied from interface: JavaSourceFacet
Attempt to locate and re-parse the given JavaClass from its location on disk, relative to JavaSourceFacet.getSourceFolder(). The given instance will not be modified, and a new instance will be returned.

Specified by:
getJavaResource in interface JavaSourceFacet
Parameters:
javaClass - The JavaClass to re-parse.
Throws:
FileNotFoundException - if the target JavaResource does not exist

getEnumTypeResource

public JavaResource getEnumTypeResource(JavaEnum javaEnum)
                                 throws FileNotFoundException
Description copied from interface: JavaSourceFacet
Attempt to locate and re-parse the given JavaEnum from its location on disk, relative to JavaSourceFacet.getSourceFolder(). The given instance will not be modified, and a new instance will be returned.

Specified by:
getEnumTypeResource in interface JavaSourceFacet
Throws:
FileNotFoundException - if the target JavaResource does not exist

getTestJavaResource

public JavaResource getTestJavaResource(JavaSource<?> javaClass)
                                 throws FileNotFoundException
Description copied from interface: JavaSourceFacet
Attempt to locate and re-parse the given JavaClass from its location on disk, relative to JavaSourceFacet.getTestSourceFolder(). The given instance will not be modified, and a new instance will be returned.

Specified by:
getTestJavaResource in interface JavaSourceFacet
Parameters:
javaClass - The JavaClass to re-parse.
Throws:
FileNotFoundException - if the target JavaResource does not exist

getJavaResource

public JavaResource getJavaResource(String relativePath)
                             throws FileNotFoundException
Description copied from interface: JavaSourceFacet
Return the JavaClass at the given path relative to JavaSourceFacet.getSourceFolder().

Specified by:
getJavaResource in interface JavaSourceFacet
Parameters:
relativePath - The file or package path of the target Java source file.
Throws:
FileNotFoundException - if the target JavaResource does not exist

getEnumTypeResource

public JavaResource getEnumTypeResource(String relativePath)
                                 throws FileNotFoundException
Description copied from interface: JavaSourceFacet
Return the JavaEnum at the given path relative to JavaSourceFacet.getSourceFolder().

Specified by:
getEnumTypeResource in interface JavaSourceFacet
Parameters:
relativePath - The file or package path of the target Java source file.
Throws:
FileNotFoundException - if the target JavaResource does not exist

getTestJavaResource

public JavaResource getTestJavaResource(String relativePath)
                                 throws FileNotFoundException
Description copied from interface: JavaSourceFacet
Return the JavaClass at the given path relative to JavaSourceFacet.getTestSourceFolder().

Specified by:
getTestJavaResource in interface JavaSourceFacet
Parameters:
relativePath - The package path of the target Java source JavaResource.
Throws:
FileNotFoundException

saveJavaSource

public JavaResource saveJavaSource(JavaSource<?> source)
                            throws FileNotFoundException
Description copied from interface: JavaSourceFacet
Create or update a Java file in the primary source directory: JavaSourceFacet.getSourceFolder() - use information in the given JavaSource to determine the appropriate package; packages will be created if necessary.

Specified by:
saveJavaSource in interface JavaSourceFacet
Parameters:
source - The java class to create
Returns:
The created or updated JavaResource
Throws:
FileNotFoundException

saveEnumTypeSource

public JavaResource saveEnumTypeSource(JavaEnum source)
                                throws FileNotFoundException
Description copied from interface: JavaSourceFacet
Create or update a Java file in the primary source directory: JavaSourceFacet.getSourceFolder() - use information in the given JavaEnum to determine the appropriate package; packages will be created if necessary.

Specified by:
saveEnumTypeSource in interface JavaSourceFacet
Parameters:
source - The java enum type to create
Returns:
The created or updated EnumTypeResource
Throws:
FileNotFoundException

saveTestJavaSource

public JavaResource saveTestJavaSource(JavaSource<?> source)
                                throws FileNotFoundException
Description copied from interface: JavaSourceFacet
Create or update a Java file in the primary test source directory: JavaSourceFacet.getTestSourceFolder() - use information in the given JavaSource to determine the appropriate package; packages will be created if necessary.

Specified by:
saveTestJavaSource in interface JavaSourceFacet
Parameters:
source - The java class to create
Returns:
The created or updated JavaResource
Throws:
FileNotFoundException

visitJavaSources

public void visitJavaSources(JavaResourceVisitor visitor)
Description copied from interface: JavaSourceFacet
Recursively loops over all the source directories and for each java file it finds, calls the visitor.

Specified by:
visitJavaSources in interface JavaSourceFacet
Parameters:
visitor - The JavaResourceVisitor that processes all the found java files. Cannot be null.

visitJavaTestSources

public void visitJavaTestSources(JavaResourceVisitor visitor)
Description copied from interface: JavaSourceFacet
Recursively loops over all the test source directories and for each java file it finds, calls the visitor.

Specified by:
visitJavaTestSources in interface JavaSourceFacet
Parameters:
visitor - The JavaResourceVisitor that processes all the found java files. Cannot be null.

Forge - Parent 1.0.6-SNAPSHOT

Copyright © 2012 JBoss, a division of Red Hat, Inc.. All Rights Reserved.