2006/unicorn/org/w3c/unicorn/index IndexGenerator.java,1.1.1.1,1.2

Update of /sources/public/2006/unicorn/org/w3c/unicorn/index
In directory hutz:/tmp/cvs-serv11946/org/w3c/unicorn/index

Modified Files:
	IndexGenerator.java 
Log Message:
Updating the javadoc for all the project

Index: IndexGenerator.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/index/IndexGenerator.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- IndexGenerator.java	31 Aug 2006 09:09:25 -0000	1.1.1.1
+++ IndexGenerator.java	17 Jun 2008 13:41:12 -0000	1.2
@@ -29,115 +29,121 @@
 /**
  * IndexGenerator<br />
  * Created: Jun 20, 2006 3:07:09 PM<br />
+ * 
  * @author Jean-Guilhem Rouel
  */
 public class IndexGenerator {
 
+	/**
+	 * Object used for complex logging purpose
+	 */
 	public static final Log logger = LogFactory.getLog("org.w3c.unicorn.index");
 
+	/**
+	 * Context to generate pages using Apache Velocity
+	 */
 	private static VelocityContext aVelocityContext;
+
+	/**
+	 * Properties of the index generator framework
+	 */
 	private static Properties aProperties = new Properties();
+
+	/**
+	 * Velocity Engine to create pages from the templates
+	 */
 	private static VelocityEngine aVelocityEngine = new VelocityEngine();
-	
+
+	/**
+	 * Load the properties and initialize apache velocity
+	 */
 	static {
-		/*
-		Properties props = new Properties();
 		try {
-			props.load(Configuration.class.getResource("unicorn.properties").openStream());
-			System.out.println("Properties : "+props);
-		}
-		catch (IOException e1) {
-			IndexGenerator.logger.error("IOException : "+e1.getMessage()+".");
-			// TODO Auto-generated catch block
-			e1.printStackTrace();
-		}
-		Configuration.loadConfiguration(props);*/
-		try {
-			IndexGenerator.aProperties.load(
-					new URL(
-							"file:" +
-							Property.get("VELOCITY_CONFIG_FILE")).openStream());
-			IndexGenerator.aProperties.put(
-					Velocity.FILE_RESOURCE_LOADER_PATH, 
+			IndexGenerator.aProperties.load(new URL("file:"
+					+ Property.get("VELOCITY_CONFIG_FILE")).openStream());
+			IndexGenerator.aProperties.put(Velocity.FILE_RESOURCE_LOADER_PATH,
 					Property.get("PATH_TO_INDEX_TEMPLATES"));
 			IndexGenerator.aVelocityEngine.init(IndexGenerator.aProperties);
 		} catch (final MalformedURLException e) {
-			IndexGenerator.logger.error("MalformedURLException : "+e.getMessage(), e);
+			IndexGenerator.logger.error("MalformedURLException : "
+					+ e.getMessage(), e);
 			e.printStackTrace();
 		} catch (final IOException e) {
-			IndexGenerator.logger.error("IOException : "+e.getMessage(), e);
+			IndexGenerator.logger.error("IOException : " + e.getMessage(), e);
 			e.printStackTrace();
 		} catch (final Exception e) {
-			IndexGenerator.logger.error("Exception : "+e.getMessage(), e);
+			IndexGenerator.logger.error("Exception : " + e.getMessage(), e);
 			e.printStackTrace();
 		}
-		
+
 		IndexGenerator.aVelocityContext = new VelocityContext();
 		IndexGenerator.aVelocityContext.put("tasklist", Framework.mapOfTask);
-		
+
 		IndexGenerator.aVelocityContext.put("dropdown", ParameterType.DROPDOWN);
 		IndexGenerator.aVelocityContext.put("checkbox", ParameterType.CHECKBOX);
-		IndexGenerator.aVelocityContext.put("checkboxlist", ParameterType.CHECKBOXLIST);
+		IndexGenerator.aVelocityContext.put("checkboxlist",
+				ParameterType.CHECKBOXLIST);
 		IndexGenerator.aVelocityContext.put("radio", ParameterType.RADIO);
 		IndexGenerator.aVelocityContext.put("textarea", ParameterType.TEXTAREA);
-		IndexGenerator.aVelocityContext.put("textfield", ParameterType.TEXTFIELD);
-		
+		IndexGenerator.aVelocityContext.put("textfield",
+				ParameterType.TEXTFIELD);
+
 		IndexGenerator.aVelocityContext.put("simple", TUi.SIMPLE);
 		IndexGenerator.aVelocityContext.put("advanced", TUi.ADVANCED);
 		IndexGenerator.aVelocityContext.put("none", TUi.NONE);
 	}
-	
-	public static void generateIndexes () throws
-	ResourceNotFoundException, ParseErrorException, Exception {
+
+	/**
+	 * Generate the multiple indexes for unicorn
+	 * 
+	 * @throws ResourceNotFoundException
+	 *             when templates not found
+	 * @throws ParseErrorException
+	 *             when error while parsing the configuration
+	 * @throws Exception
+	 *             any unknown error
+	 */
+	public static void generateIndexes() throws ResourceNotFoundException,
+			ParseErrorException, Exception {
 		IndexGenerator.logger.trace("generateIndexes");
 
-		final File[] tFile = ListFiles.listFiles(Property.get("PATH_TO_INDEX_TEMPLATES"), "\\.vm$");
+		final File[] tFile = ListFiles.listFiles(Property
+				.get("PATH_TO_INDEX_TEMPLATES"), "\\.vm$");
 		for (final File aFile : tFile) {
 			final String sName = aFile.getName();
-			final String sOutputName = sName.substring(0, sName.length() - 3);	
-			
-			final Template aTemplate = IndexGenerator.aVelocityEngine.getTemplate(sName, "UTF-8");
-			
-			final FileWriter aFileWriter = new FileWriter(
-					Property.get("PATH_TO_INDEX_OUTPUT") + 
-					sOutputName);			
+			final String sOutputName = sName.substring(0, sName.length() - 3);
+
+			final Template aTemplate = IndexGenerator.aVelocityEngine
+					.getTemplate(sName, "UTF-8");
+
+			final FileWriter aFileWriter = new FileWriter(Property
+					.get("PATH_TO_INDEX_OUTPUT")
+					+ sOutputName);
 			aTemplate.merge(IndexGenerator.aVelocityContext, aFileWriter);
 			aFileWriter.close();
-			
-			IndexGenerator.logger.debug(
-					"Index file " +
-					Property.get("PATH_TO_INDEX_OUTPUT") + 
-					sOutputName +
-					" generated.");
+
+			IndexGenerator.logger.debug("Index file "
+					+ Property.get("PATH_TO_INDEX_OUTPUT") + sOutputName
+					+ " generated.");
 		}
 	}
-	
-	public static void main (final String[] args) {
+
+	/**
+	 * Launch the creation of the indexes
+	 * 
+	 * @param args
+	 */
+	public static void main(final String[] args) {
 		try {
-			/*
-			Properties props = new Properties();
-			try {
-				props.load(Configuration.class.getResource("unicorn.properties").openStream());
-			}
-			catch (IOException e1) {
-				// TODO Auto-generated catch block
-				e1.printStackTrace();
-			}
-			Configuration.loadConfiguration(props);*/
 			IndexGenerator.generateIndexes();
-		}
-		catch (final FileNotFoundException e) {
+		} catch (final FileNotFoundException e) {
 			e.printStackTrace();
-		}
-		catch (final ResourceNotFoundException e) {
+		} catch (final ResourceNotFoundException e) {
 			e.printStackTrace();
-		}
-		catch (final ParseErrorException e) {
+		} catch (final ParseErrorException e) {
 			e.printStackTrace();
-		}
-		catch (final Exception e) {
+		} catch (final Exception e) {
 			e.printStackTrace();
 		}
 	}
 }
-

Received on Tuesday, 17 June 2008 13:41:52 UTC