All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.lizardev.xquery.saxon.coverage.collect.LineCollector Maven / Gradle / Ivy

There is a newer version: 0.8.0
Show newest version
package com.github.lizardev.xquery.saxon.coverage.collect;

import com.github.lizardev.xquery.saxon.coverage.trace.CoverageInstruction;
import com.github.lizardev.xquery.saxon.coverage.trace.InstructionId;

import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;

public class LineCollector {

    private final int lineNumber;
    private Map instructionCollectors = new LinkedHashMap<>();

    public LineCollector(int lineNumber) {
        this.lineNumber = lineNumber;
    }

    public InstructionCollector instructionCreated(CoverageInstruction instruction) {
        return getInstructionCollector(instruction);
    }

    private InstructionCollector getInstructionCollector(CoverageInstruction instruction) {
        InstructionCollector instructionCollector = instructionCollectors.get(instruction.getInstructionId());
        if (instructionCollector == null) {
            instructionCollector = new InstructionCollector(instruction);
            instructionCollectors.put(instruction.getInstructionId(), instructionCollector);
        }
        return instructionCollector;
    }

    public Collection getInstructionCollectors() {
        return instructionCollectors.values();
    }

    public int getLineNumber() {
        return lineNumber;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy