/*
 * File   :
 * Date   : 
 * Version: 
 *
 * This library is part of OpenCms -
 * the Open Source Content Mananagement System
 *
 * Copyright (C) 2002 - 2003 Alkacon Software (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package org.opencms.validation;

import java.util.Date;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;

/**
 * Stores the result of a pointer link validation. <p>
 * 
 * @author Jan Baudisch (j.baudisch@alkacon.com)
 * 
 * @version $Revision: 1.1 $
 */
public class CmsPointerLinkValidationResult {

    /**  The broken links that were found.<p> */
    private Map m_brokenLinks;

    /**  The date of the validation.<p> */
    private Date m_validationDate;
    
    /**
     * Constructs a new pointer link validation result.<p>
     * 
     * @param brokenLinks a list of the broken links
     */
    public CmsPointerLinkValidationResult(Map brokenLinks) {

        m_brokenLinks = brokenLinks;
        m_validationDate = new Date();
    }
    
    /**
     * Returns a Html representation of this pointer link validation result.<p>
     * 
     * @param locale the Locale to display the result in
     * 
     * @return a Html representation of this external link validation result
     */
    public String toHtml(Locale locale) {
        StringBuffer result = new StringBuffer(1024);
        Iterator brokenLinks = m_brokenLinks.entrySet().iterator();
        result.append(Messages.get().key(locale, Messages.GUI_LINK_VALIDATION_RESULTS_INTRO_1, 
            new Object[] {m_validationDate})).append("<ul>");
        while (brokenLinks.hasNext()) {
            Entry link = (Map.Entry)brokenLinks.next();
            String linkPath = (String)link.getKey();
            String linkUrl = (String)link.getValue();
            String msg = Messages.get().key(locale, Messages.GUI_LINK_POINTING_TO_2, 
                new Object[] {linkPath, linkUrl});
            result.append("<li>").append(msg).append("</li>"); 
        }
        return result.append("</ul>").toString(); 
    }
}
@@ -1454,17 +1454,17 @@
 sion: 1.
-1
+2
  $%0A */%0Ap
@@ -2242,24 +2242,68 @@
 e locale) %7B%0A
+        if (m_brokenLinks.size() %3E 0) %7B%0A    
         Stri
@@ -2352,16 +2352,20 @@
         
+   
+ 
 Iterator
@@ -2416,32 +2416,36 @@
 ator();%0A        
+    
 result.append(Me
@@ -2442,16 +2442,33 @@
 .append(
+%0A                
 Messages
@@ -2531,18 +2531,25 @@
 INTRO_1,
- 
 %0A
+        
         
@@ -2610,16 +2610,20 @@
         
+    
 while (b
@@ -2658,16 +2658,20 @@
         
+  
+  
 Entry li
@@ -2710,32 +2710,36 @@
 ();%0A            
+    
 String linkPath 
@@ -2767,32 +2767,36 @@
 ();%0A            
+   
+ 
 String linkUrl =
@@ -2817,24 +2817,28 @@
 getValue();%0A
+    
             
@@ -2909,18 +2909,20 @@
 NG_TO_2,
- 
 %0A
+   
         
@@ -2921,32 +2921,33 @@
                 
+ 
 new Object%5B%5D %7Bli
@@ -2965,16 +2965,20 @@
 kUrl%7D);%0A
+    
         
@@ -3031,18 +3031,21 @@
 %3C/li%3E%22);
- 
 %0A
+    
         
@@ -3042,24 +3042,28 @@
           %7D%0A
+    
         retu
@@ -3099,16 +3099,193 @@
 tring();
+%0A        %7D else %7B%0A            return Messages.get().key(locale, Messages.GUI_LINK_VALIDATION_RESULTS_ALL_VALID_1, %0A                new Object%5B%5D %7Bm_validationDate%7D);%0A        %7D   
  %0A    %7D%0A

Print different message if no broken links were found.