From d3f82e2d308945201b261ff525ff374a36e496d7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Miqu=C3=A9e?= Date: Sun, 7 Feb 2010 20:00:22 +0100 Subject: [PATCH] Modification of Makefile and Utils. - Including the Javadoc generation in the Makefile; - Modifying the control on file's path in write/read methods for graph and grid. --- Makefile | 30 +++++++++++----- Manifest | 2 +- src/and/Mapping/Utils.java | 70 ++++++++++++++++++++++++++++++-------- 3 files changed, 78 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 3714bb6..0484f53 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,6 @@ JAVAC=javac BIN=bin -#LIB=lib SRC=src PACK=and PACKAGE=$(PACK)/Mapping @@ -13,27 +12,40 @@ JAR=Mapping.jar EXT=com/ JAVADOC=javadoc -compile:clean +compile: @echo - @echo "Compilation of Mapping library ..." + @echo "## Compilation of Mapping library ..." @echo - mkdir $(BIN) $(JAVAC) -d ./$(BIN) ./$(SRC)/$(PACKAGE)/*.java -jar:compile +jar:clean compile javadoc @echo - @echo "Creation of Mapping jar ..." + @echo "## Creation of Mapping jar ..." @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 - @echo "Cleaning project ..." + @echo "## Cleaning project ..." @echo - rm -rf bin $(JAR) + rm -rf ./$(BIN)/* ./$(JAR) ./$(JAVADOC)/* +cleanDoc: + @echo + @echo "## Cleaning Javadoc ..." + @echo + rm -rf ./$(JAVADOC)/* + # ## # diff --git a/Manifest b/Manifest index 10590c9..58630c0 100644 --- a/Manifest +++ b/Manifest @@ -1,2 +1,2 @@ Manifest-Version: 1.0 -Class-path: lib/* + diff --git a/src/and/Mapping/Utils.java b/src/and/Mapping/Utils.java index 57a87e2..25cd4a7 100644 --- a/src/and/Mapping/Utils.java +++ b/src/and/Mapping/Utils.java @@ -65,7 +65,7 @@ public class Utils 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 ) ; } @@ -173,7 +173,13 @@ public class Utils */ 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 } @@ -217,7 +223,13 @@ public class Utils */ 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 } @@ -257,28 +269,43 @@ public class Utils /** * Read an application Graph from a file. * @param _file File's name + * @param _path File's path * @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 ; } + 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 { - 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 ) { - 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 ; } @@ -290,28 +317,43 @@ public class Utils /** * Read a Grid graph from a file. * @param _file File's name + * @param _path File's path * @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 ; } + 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 { - 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 ) { - 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 ; } -- 2.20.1