Example usage for org.apache.maven.model.io ModelParseException getLineNumber

List of usage examples for org.apache.maven.model.io ModelParseException getLineNumber

Introduction

In this page you can find the example usage for org.apache.maven.model.io ModelParseException getLineNumber.

Prototype

public int getLineNumber() 

Source Link

Document

Gets the one-based index of the line containing the error.

Usage

From source file:org.fedoraproject.maven.model.building.FossModelProblemCollector.java

License:Open Source License

@Override
public void add(final ModelProblem.Severity severity, final String message, final InputLocation location,
        final Exception cause) {

    int line = -1;
    int column = -1;
    String source = null;/*w  ww. j  av a2s  .c om*/
    String modelId = null;

    if (location != null) {
        line = location.getLineNumber();
        column = location.getColumnNumber();
        if (location.getSource() != null) {
            modelId = location.getSource().getModelId();
            source = location.getSource().getLocation();
        }
    }

    if (modelId == null) {
        modelId = getModelId();
        source = getSource();
    }

    if (line <= 0 && column <= 0 && cause instanceof ModelParseException) {
        ModelParseException e = (ModelParseException) cause;
        line = e.getLineNumber();
        column = e.getColumnNumber();
    }

    ModelProblem problem = new DefaultModelProblem(message, severity, source, line, column, modelId, cause);

    add(problem);
}