Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Modification of Makefile and Utils.
authorSébastien Miquée <sebastien.miquee@univ-fcomte.fr>
Sun, 7 Feb 2010 19:00:22 +0000 (20:00 +0100)
committerSébastien Miquée <sebastien.miquee@univ-fcomte.fr>
Sun, 7 Feb 2010 19:00:22 +0000 (20:00 +0100)
- Including the Javadoc generation in the Makefile;

- Modifying the control on file's path in write/read methods for
graph and grid.

Makefile
Manifest
src/and/Mapping/Utils.java

index 3714bb6..0484f53 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,6 @@
 
 JAVAC=javac
 BIN=bin
 
 JAVAC=javac
 BIN=bin
-#LIB=lib
 SRC=src
 PACK=and
 PACKAGE=$(PACK)/Mapping
 SRC=src
 PACK=and
 PACKAGE=$(PACK)/Mapping
@@ -13,27 +12,40 @@ JAR=Mapping.jar
 EXT=com/
 JAVADOC=javadoc
 
 EXT=com/
 JAVADOC=javadoc
 
-compile:clean
+compile:
        @echo
        @echo
-       @echo "Compilation of Mapping library ..."
+       @echo "## Compilation of Mapping library ..."
        @echo
        @echo
-       mkdir $(BIN)
        $(JAVAC) -d ./$(BIN) ./$(SRC)/$(PACKAGE)/*.java
 
 
        $(JAVAC) -d ./$(BIN) ./$(SRC)/$(PACKAGE)/*.java
 
 
-jar:compile
+jar:clean compile javadoc
        @echo
        @echo
-       @echo "Creation of Mapping jar ..."
+       @echo "## Creation of Mapping jar ..."
        @echo
        @echo
-       jar -cvfm $(JAR) Manifest $(EXT) $(JAVADOC) -C $(BIN) $(PACK)/ #$(LIB)  
+       jar -cvfm ./$(JAR) Manifest ./$(EXT) ./$(JAVADOC) -C ./$(BIN) ./$(PACK)/
+
+
+javadoc:cleanDoc
+       @echo
+       @echo "## Generating Javadoc ..."
+       @echo 
+       javadoc -d ./$(JAVADOC) ./$(SRC)/$(PACKAGE)/*.java
+
 
 clean:
        @echo
 
 clean:
        @echo
-       @echo "Cleaning project ..."
+       @echo "## Cleaning project ..."
        @echo
        @echo
-       rm -rf bin $(JAR)
+       rm -rf ./$(BIN)/* ./$(JAR) ./$(JAVADOC)/*
 
 
 
 
+cleanDoc:
+       @echo
+       @echo "## Cleaning Javadoc ..."
+       @echo
+       rm -rf ./$(JAVADOC)/*
+
 #
 ##
 #
 #
 ##
 #
index 10590c9..58630c0 100644 (file)
--- a/Manifest
+++ b/Manifest
@@ -1,2 +1,2 @@
 Manifest-Version: 1.0\r
 Manifest-Version: 1.0\r
-Class-path: lib/*\r
+\r
index 57a87e2..25cd4a7 100644 (file)
@@ -65,7 +65,7 @@ public class Utils
                        InetAddress addr = InetAddress.getLocalHost() ;
                        name = new String( addr.getCanonicalHostName() ) ;
                } catch( final Exception e ) {
                        InetAddress addr = InetAddress.getLocalHost() ;
                        name = new String( addr.getCanonicalHostName() ) ;
                } catch( final Exception e ) {
-                       System.err.println( "Unalbe to retrieve host name !" ) ;
+                       System.err.println( "Unalbe to retrieve host's name !" ) ;
                        e.printStackTrace();
                        System.exit( 1 ) ;
                } 
                        e.printStackTrace();
                        System.exit( 1 ) ;
                } 
@@ -173,7 +173,13 @@ public class Utils
         */
        public static void writeGrid( Grid _gl, String _file, String _path )
        {
         */
        public static void writeGrid( Grid _gl, String _file, String _path )
        {
-               if ( ! _file.equals( "" ) && ! _file.endsWith( ".xml" ) )
+               if( _file.equals( "" ) )
+               {
+                       System.err.println( "No file's name !\n" ) ;
+                       return ;
+               }
+               
+               if ( ! _file.endsWith( ".xml" ) )
                {
                        _file = _file + ".xml"; // On ajoute l'extension xml au nom du fichier
                }
                {
                        _file = _file + ".xml"; // On ajoute l'extension xml au nom du fichier
                }
@@ -217,7 +223,13 @@ public class Utils
         */
        public static void writeGraph( Graph _gr, String _file, String _path )
        {
         */
        public static void writeGraph( Graph _gr, String _file, String _path )
        {
-               if ( ! _file.equals( "" ) && ! _file.endsWith( ".xml" ) )
+               if( _file.equals( "" ) )
+               {
+                       System.err.println( "No file's name !\n" ) ;
+                       return ;
+               }
+               
+               if ( ! _file.endsWith( ".xml" ) )
                {
                        _file = _file + ".xml"; // On ajoute l'extension xml au nom du fichier
                }
                {
                        _file = _file + ".xml"; // On ajoute l'extension xml au nom du fichier
                }
@@ -257,28 +269,43 @@ public class Utils
        /**
         * Read an application Graph from a file.
         * @param _file File's name
        /**
         * Read an application Graph from a file.
         * @param _file File's name
+        * @param _path File's path
         * @return The application Graph read
         */
         * @return The application Graph read
         */
-       public static Graph readGraph( String _file )
+       public static Graph readGraph( String _path, String _file )
        {
        {
-               if ( _file.equals( "" ) || ! _file.endsWith( ".xml" ) )
+               if ( _file.equals( "" ) )
                {
                {
-                       System.err.println( "Bad file !\n" ) ;
+                       System.err.println( "No file's name !\n" ) ;
                        return null ;
                }       
                
                        return null ;
                }       
                
+               if ( ! _file.endsWith( ".xml" ) )
+               {
+                       _file = _file + ".xml"; // On ajoute l'extension xml au nom du fichier
+               }
+               
+               String path = "" ;
+               
+               if( _path.length() != 0 )
+               {
+                       path = _path+"/"+_file ;
+               } else {
+                       path = new String( "./" + _file ) ;
+               }       
+                       
                Graph gr = null ;
                
                XStream xstream = new XStream( new DomDriver() ) ;
                
                try {
                Graph gr = null ;
                
                XStream xstream = new XStream( new DomDriver() ) ;
                
                try {
-                       gr = (Graph) xstream.fromXML( new FileInputStream( _file ) ) ;
+                       gr = (Graph) xstream.fromXML( new FileInputStream( path ) ) ;
                } catch( FileNotFoundException e ) {
                        System.err.println( "File not found !\n" ) ;
                        e.printStackTrace();
                        return null ;
                } catch( ClassCastException e ) {
                } catch( FileNotFoundException e ) {
                        System.err.println( "File not found !\n" ) ;
                        e.printStackTrace();
                        return null ;
                } catch( ClassCastException e ) {
-                       System.err.println( "The file does not contain a Graph" ) ;
+                       System.err.println( "The file does not contain a valid Graph" ) ;
                        e.printStackTrace() ;
                        return null ;
                }
                        e.printStackTrace() ;
                        return null ;
                }
@@ -290,28 +317,43 @@ public class Utils
        /**
         * Read a Grid graph from a file.
         * @param _file File's name
        /**
         * Read a Grid graph from a file.
         * @param _file File's name
+        * @param _path File's path
         * @return The Grid graph read
         */
         * @return The Grid graph read
         */
-       public static Grid readGrid( String _file )
-       {
-               if ( _file.equals( "" ) || ! _file.endsWith( ".xml" ) )
+       public static Grid readGrid( String _path, String _file )
+       {       
+               if ( _file.equals( "" ) )
                {
                {
-                       System.err.println( "Bad file !\n" ) ;
+                       System.err.println( "No file's name !\n" ) ;
                        return null ;
                }       
                
                        return null ;
                }       
                
+               if ( ! _file.endsWith( ".xml" ) )
+               {
+                       _file = _file + ".xml"; // On ajoute l'extension xml au nom du fichier
+               }
+
+               String path = "" ;
+               
+               if( _path.length() != 0 )
+               {
+                       path = _path+"/"+_file ;
+               } else {
+                       path = new String( "./" + _file ) ;
+               }       
+               
                Grid gr = null ;
                
                XStream xstream = new XStream( new DomDriver() ) ;
                
                try {
                Grid gr = null ;
                
                XStream xstream = new XStream( new DomDriver() ) ;
                
                try {
-                       gr = (Grid) xstream.fromXML( new FileInputStream( _file ) ) ;
+                       gr = (Grid) xstream.fromXML( new FileInputStream( path ) ) ;
                } catch( FileNotFoundException e ) {
                        System.err.println( "File not found !\n" ) ;
                        e.printStackTrace();
                        return null ;
                } catch( ClassCastException e ) {
                } catch( FileNotFoundException e ) {
                        System.err.println( "File not found !\n" ) ;
                        e.printStackTrace();
                        return null ;
                } catch( ClassCastException e ) {
-                       System.err.println( "The file does not contain a Grid" ) ;
+                       System.err.println( "The file does not contain a valid Grid" ) ;
                        e.printStackTrace() ;
                        return null ;
                }
                        e.printStackTrace() ;
                        return null ;
                }