it.avutils.jmapper.util
Class FilesManager

java.lang.Object
  extended by it.avutils.jmapper.util.FilesManager

public class FilesManager
extends Object

FilesManager provides all the operations that allow the manipulation of files.

Author:
Alessandro Vurro

Constructor Summary
FilesManager()
           
 
Method Summary
static void addConfigurationToClass(String path, List<Attribute> attributes, Class<?> aClass)
          This method adds the configurations present in the xml file in the Class.
static List<Class<?>> annotatedClasses()
          Returns a list with all annotated classes
static List<File> annotatedFiles()
          Returns a list with all annotated files.
static List<String> classesPath()
          Returns a list with the paths of all java classes.
static void cleanClass(File file, Class<?> aClass, boolean cleanAll)
          This method rewrite the file without JMap annotations.
static String fullPathOf(String fileName)
          Starting from filename returns its path.
static boolean isFileAnnotated(String path, Class<?> aClass)
          Returns true if the file, relative to path, containts the @JMap annotation.
static XmlJmapper readAtDevelopmentTime(String xmlPath)
          This method loads the xml file relative to xmlPath parameter.
static XmlJmapper readAtRuntime(String xmlPath)
          This method loads the xml file relative to xmlPath parameter.
static File searchFile(String name)
          Returns the file that has the name given as input, null otherwise.
static boolean verifyFileExistence(String path)
          Method used to check the file existence, for test purpose.
static void write(XmlJmapper jmapper, String xmlPath)
          This method writes the xml file starting from an XmlJmapper object, following the xmlPath.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilesManager

public FilesManager()
Method Detail

addConfigurationToClass

public static void addConfigurationToClass(String path,
                                           List<Attribute> attributes,
                                           Class<?> aClass)
                                    throws NoSuchFieldException,
                                           IOException
This method adds the configurations present in the xml file in the Class.

Parameters:
path - path of the file that represents the class
attributes - attributes of this Class
aClass - class to rewrite
Throws:
NoSuchFieldException
IOException

cleanClass

public static void cleanClass(File file,
                              Class<?> aClass,
                              boolean cleanAll)
                       throws IOException
This method rewrite the file without JMap annotations.

Parameters:
file - file to rewrite
aClass - Class that represent the file
cleanAll - true if all annotation should be delete, false otherwise
Throws:
IOException

verifyFileExistence

public static boolean verifyFileExistence(String path)
Method used to check the file existence, for test purpose.

Parameters:
path - Path of the file to check

searchFile

public static File searchFile(String name)
Returns the file that has the name given as input, null otherwise.

Parameters:
name - file name
Returns:
the File with this name

classesPath

public static List<String> classesPath()
                                throws FileNotFoundException,
                                       LoadingFileException
Returns a list with the paths of all java classes.

Returns:
a List with the paths of all java classes
Throws:
FileNotFoundException
LoadingFileException

annotatedFiles

public static List<File> annotatedFiles()
                                 throws FileNotFoundException,
                                        LoadingFileException,
                                        IOException
Returns a list with all annotated files.

Returns:
a List with all annotated files
Throws:
FileNotFoundException
LoadingFileException
IOException

annotatedClasses

public static List<Class<?>> annotatedClasses()
                                       throws LoadingFileException,
                                              IOException,
                                              ClassNotFoundException
Returns a list with all annotated classes

Returns:
a List with all annotated classes
Throws:
LoadingFileException
IOException
ClassNotFoundException

isFileAnnotated

public static boolean isFileAnnotated(String path,
                                      Class<?> aClass)
                               throws IOException
Returns true if the file, relative to path, containts the @JMap annotation.

Parameters:
path - file path
Returns:
true if the file, relative to path, contains the @JMap annotation
Throws:
IOException

write

public static void write(XmlJmapper jmapper,
                         String xmlPath)
                  throws IOException
This method writes the xml file starting from an XmlJmapper object, following the xmlPath.

Parameters:
jmapper - XmlJmapper object that will be used for write the xml mapping file
Throws:
IOException

readAtDevelopmentTime

public static XmlJmapper readAtDevelopmentTime(String xmlPath)
                                        throws FileNotFoundException
This method loads the xml file relative to xmlPath parameter. Read method is used for the xml manipulation at development time.

Parameters:
xmlPath - path to xml file
Returns:
XmlJmapper object
Throws:
FileNotFoundException

readAtRuntime

public static XmlJmapper readAtRuntime(String xmlPath)
                                throws MalformedURLException,
                                       IOException
This method loads the xml file relative to xmlPath parameter. Read method is used for the xml manipulation at runtime.

Parameters:
xmlPath - path to xml file
Returns:
XmlJmapper object
Throws:
IOException
MalformedURLException

fullPathOf

public static String fullPathOf(String fileName)
Starting from filename returns its path.

Parameters:
fileName - file name
Returns:
the absolute path


Copyright © 2013. All Rights Reserved.