checkstyleZZ
[utils] / crawler / basic / src / org / wamblee / crawler / impl / ConfigurationParser.java
index 2f2e5f5bf95cdf9cc866c182551da757de820769..e9dc4013b5c3025817e5c6daaba1fe5537733fba 100644 (file)
@@ -62,11 +62,21 @@ public class ConfigurationParser {
     private static final int MAX_DELAY = 5000;
 
     private PrintStream _os;
-
+    
+    /**
+     * Constructs the configuration parser. 
+     * @param aOs The stream for logging requests.
+     * TODO plain java logging should be used instead of this awkward mechanism. 
+     */
     public ConfigurationParser(PrintStream aOs) {
         _os = aOs;
     }
 
+    /**
+     * Parses the configuration from an input stream.
+     * @param aStream Input file. 
+     * @return Configuration. 
+     */
     public Configuration parse(InputStream aStream) {
         try {
             SAXReader reader = new SAXReader();
@@ -82,8 +92,9 @@ public class ConfigurationParser {
     }
 
     /**
-     * @param aRoot
-     * @return
+     * Parses the URL-based configuration. 
+     * @param aRoot Root of the configuration file document. 
+     * @return List of URL-based configurations. 
      */
     private List<UrlConfig> parseUrlConfigs(Element aRoot) {
         List<UrlConfig> configs = new ArrayList<UrlConfig>();
@@ -95,6 +106,11 @@ public class ConfigurationParser {
         return configs;
     }
 
+    /**
+     * Parses the page type based configurations. 
+     * @param aRoot Root of the configuration file document. 
+     * @return LIst of page type based configurations. 
+     */
     private List<PageTypeConfig> parsePageTypeConfigs(Element aRoot) {
         List<PageTypeConfig> configs = new ArrayList<PageTypeConfig>();
         for (Iterator i = aRoot.elementIterator(ELEM_TYPE); i.hasNext();) {
@@ -105,12 +121,22 @@ public class ConfigurationParser {
         return configs;
     }
 
+    /**
+     * Parses a URL-based configuration. 
+     * @param aUrlElem Configuration element. 
+     * @return Configuration. 
+     */
     private UrlConfig parseUrlConfig(Element aUrlElem) {
         String pattern = aUrlElem.elementText(ELEM_PATTERN);
         PageRequest request = parseRequestConfig(aUrlElem);
         return new UrlConfig(pattern, request);
     }
 
+    /**
+     * Parses a page type based configuration. 
+     * @param aTypeElem Configuration element. 
+     * @return Configuration. 
+     */
     private PageTypeConfig parsePageTypeConfig(Element aTypeElem) {
         String pattern = aTypeElem.elementText(ELEM_PATTERN);
         PageRequest request = parseRequestConfig(aTypeElem);
@@ -118,14 +144,15 @@ public class ConfigurationParser {
     }
 
     /**
-     * @param aUrlElem
-     * @return
+     * Parses a request configuration describing how to execute requests. 
+     * @param aElem Configuration element. 
+     * @return Page request. 
      */
-    private PageRequest parseRequestConfig(Element aUrlElem) {
-        String method = aUrlElem.elementText(ELEM_METHOD);
-        String xslt = aUrlElem.elementText(ELEM_XSLT);
+    private PageRequest parseRequestConfig(Element aElem) {
+        String method = aElem.elementText(ELEM_METHOD);
+        String xslt = aElem.elementText(ELEM_XSLT);
         List<NameValuePair> params = new ArrayList<NameValuePair>();
-        for (Iterator i = aUrlElem.elementIterator(ELEM_PARAM); i.hasNext();) {
+        for (Iterator i = aElem.elementIterator(ELEM_PARAM); i.hasNext();) {
             Element paramElem = (Element) i.next();
             NameValuePair param = parseParameter(paramElem);
             params.add(param);
@@ -147,6 +174,11 @@ public class ConfigurationParser {
         return request;
     }
 
+    /**
+     * Parses a parameter definition. 
+     * @param aParam Parameter. 
+     * @return Name value pair describing a parameter. 
+     */
     private NameValuePair parseParameter(Element aParam) {
         String name = aParam.attributeValue(AT_NAME);
         String value = aParam.attributeValue(AT_VALUE);