[MAJOR: classes needed by the new architectural design.
nickel@x9c.fr**20080831135146] {
addfile ./src/fr/x9c/nickel/AbstractModuleProducer.java
hunk ./src/fr/x9c/nickel/AbstractModuleProducer.java 1
+/*
+ * This file is part of Nickel.
+ * Copyright (C) 2007-2008 Xavier Clerc.
+ *
+ * Nickel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Nickel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package fr.x9c.nickel;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * This abstract class defines a minimal module producer, only holding values
+ * for meta properties.
+ *
+ * @author Xavier Clerc
+ * @version 1.1
+ * @since 1.1
+ */
+public abstract class AbstractModuleProducer implements ModuleProducer {
+
+ /** Map from meta keys to their associated values. */
+ protected final Map< String, List > meta;
+
+ /**
+ * Constructs a module with no meta property.
+ */
+ public AbstractModuleProducer() {
+ this.meta = new HashMap< String, List >();
+ } // end empty constructor
+
+ /**
+ * {@inheritDoc}
+ */
+ public List getMeta(final String key) {
+ assert key != null : "null key";
+ return this.meta.get(key);
+ } // end method 'getMeta(String)'
+
+} // end class 'AbstractModuleProducer'
addfile ./src/fr/x9c/nickel/ModuleProducer.java
hunk ./src/fr/x9c/nickel/ModuleProducer.java 1
+/*
+ * This file is part of Nickel.
+ * Copyright (C) 2007-2008 Xavier Clerc.
+ *
+ * Nickel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Nickel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package fr.x9c.nickel;
+
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.util.List;
+
+/**
+ * This class defines an interface representing a module producer.
+ * A module producer is a stateful object whose methods should be called
+ * in the following order (the call chain should of course stops if any
+ * method throws an exception):
+ *
+ * - parse(-) to parse XML data from a given stream;
+ *
- resolve(-) to resolve the references from the XML data;
+ *
- generate(-) to generate the code from the references.
+ *
+ *
+ * @author Xavier Clerc
+ * @version 1.1
+ * @since 1.1
+ */
+public interface ModuleProducer {
+
+ /**
+ * Returns the value of a meta property, as found in the XML data.
+ * @param key meta key - should not be null
+ * @return the value for the passed meta key,
+ * null if such a key is not mapped
+ */
+ List getMeta(final String key);
+
+ /**
+ * Parses XML data.
+ * @param is stream to read XML data from - should not be null
+ * @param verbose where comments should be printed during process
+ * (null if such print should not occur)
+ * @param debug where debug elements (e.g. stack traces)
+ * should be printed when an error occurs
+ * (null if such print should not occur)
+ * @throws NickelException if an error occurs during parse
+ */
+ void parse(final InputStream is, final PrintStream verbose, final PrintStream debug)
+ throws NickelException;
+
+ /**
+ * Resolves references from XML data.
+ * @param cl classloader used to resolve references - should not be null
+ * @param verbose where comments should be printed during process
+ * (null if such print should not occur)
+ * @param debug where debug elements (e.g. stack traces)
+ * should be printed when an error occurs
+ * (null if such print should not occur)
+ * @throws NickelException if an error occurs during resolution
+ */
+ void resolve(final ClassLoader cl, final PrintStream verbose, final PrintStream debug)
+ throws NickelException;
+
+ /**
+ * Generates the code for the resolved references.
+ * @param params parameters defining the output process (e. g. paths)
+ * @throws NickelException if an error occurs during code generation
+ */
+ void generate(final Parameters params)
+ throws NickelException;
+
+} // end interface 'ModuleProducer'
}