package hudson.plugins.analysis.util;

import java.io.Serializable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * Master-Slave transfer object for blame information.
 *
 * @author Ullrich Hafner
 */
public class BlameRequest implements Iterable<Integer>, Serializable {
    private String fileName;
    private final Set<Integer> lines = new HashSet<Integer>();
    private final Map<Integer, String> commitByLine = new HashMap<Integer, String>();
    private final Map<Integer, String> nameByLine = new HashMap<Integer, String>();
    private final Map<Integer, String> emailByLine = new HashMap<Integer, String>();

    public BlameRequest(final String fileName, final int lineNumber) {
        String OS = System.getProperty("os.name");
        if (OS.startsWith("Windows")) {
            this.fileName = fileName.replaceAll("\\\\", "/");
        } 
        else {
            this.fileName = fileName;            
        }        
        addLineNumber(lineNumber);
    }

    public final void addLineNumber(final int lineNumber) {
        lines.add(lineNumber);
    }

    public String getFileName() {
        return fileName;
    }

    @Override
    public String toString() {
        return fileName + " - " + lines;
    }

    @Override
    public Iterator<Integer> iterator() {
        return lines.iterator();
    }

    public void setCommit(final int line, final String id) {
        commitByLine.put(line, id);
    }

    public String getCommit(final int line) {
        return commitByLine.get(line);
    }

    public void setName(final int line, final String name) {
        nameByLine.put(line, name);
    }

    public String getName(final int line) {
        return nameByLine.get(line);
    }

    public void setEmail(final int line, final String emailAddress) {
        emailByLine.put(line, emailAddress);
    }

    public String getEmail(final int line) {
        return emailByLine.get(line);
    }
}

@@ -779,246 +779,33 @@
     
-String OS = System.getProperty(%22os.name%22);%0A        if (OS.startsWith(%22Windows%22)) %7B%0A            this.fileName = fileName.replaceAll(%22%5C%5C%5C%5C%22, %22/%22);%0A        %7D %0A        else %7B%0A            this.fileName = fileName;            %0A        %7D        
+this.fileName = fileName;
 %0A   

Revert "Fixed Request Path for Windows OS"