aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/yql/Location.java
blob: 4af35f791f1829ca12d36681edea2ebd7ed0b078 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.yql;

/**
 * A pointer to a location in a YQL source program.
 */
final class Location {

    private final String programName;
    private final int lineNumber;
    private final int characterOffset;

    public Location(String programName, int lineNumber, int characterOffset) {
        this.programName = programName;
        this.lineNumber = lineNumber;
        this.characterOffset = characterOffset;
    }


    public int getLineNumber() {
        return lineNumber;
    }

    public int getCharacterOffset() {
        return characterOffset;
    }

    @Override
    public String toString() {
        if (programName != null) {
            return programName + ":L" + lineNumber + ":" + characterOffset;
        } else {
            return "L" + lineNumber + ":" + characterOffset;
        }
    }

}