Java 类org.elasticsearch.common.xcontent.XContentLocation 实例源码

项目:Elasticsearch    文件:QueryParsingException.java   
public QueryParsingException(QueryParseContext parseContext, String msg, Throwable cause, Object... args) {
    super(msg, cause, args);
    setIndex(parseContext.index());
    int lineNumber = UNKNOWN_POSITION;
    int columnNumber = UNKNOWN_POSITION;
    XContentParser parser = parseContext.parser();
    if (parser != null) {
        XContentLocation location = parser.getTokenLocation();
        if (location != null) {
            lineNumber = location.lineNumber;
            columnNumber = location.columnNumber;
        }
    }
    this.columnNumber = columnNumber;
    this.lineNumber = lineNumber;
}
项目:elasticsearch_my    文件:PercolatorFieldMapper.java   
private static QueryBuilder parseQueryBuilder(QueryParseContext context, XContentLocation location) {
    try {
        return context.parseInnerQueryBuilder();
    } catch (IOException e) {
        throw new ParsingException(location, "Failed to parse", e);
    }
}
项目:elasticsearch_my    文件:LessThanAssertion.java   
public static LessThanAssertion parse(XContentParser parser) throws IOException {
    XContentLocation location = parser.getTokenLocation();
    Tuple<String,Object> stringObjectTuple = ParserUtils.parseTuple(parser);
    if (false == stringObjectTuple.v2() instanceof Comparable) {
        throw new IllegalArgumentException("lt section can only be used with objects that support natural ordering, found "
                + stringObjectTuple.v2().getClass().getSimpleName());
    }
    return new LessThanAssertion(location, stringObjectTuple.v1(), stringObjectTuple.v2());
}
项目:elasticsearch_my    文件:GreaterThanAssertion.java   
public static GreaterThanAssertion parse(XContentParser parser) throws IOException {
    XContentLocation location = parser.getTokenLocation();
    Tuple<String,Object> stringObjectTuple = ParserUtils.parseTuple(parser);
    if (! (stringObjectTuple.v2() instanceof Comparable) ) {
        throw new IllegalArgumentException("gt section can only be used with objects that support natural ordering, found "
                + stringObjectTuple.v2().getClass().getSimpleName());
    }
    return new GreaterThanAssertion(location, stringObjectTuple.v1(), stringObjectTuple.v2());
}
项目:elasticsearch_my    文件:LessThanOrEqualToAssertion.java   
public static LessThanOrEqualToAssertion parse(XContentParser parser) throws IOException {
    XContentLocation location = parser.getTokenLocation();
    Tuple<String,Object> stringObjectTuple = ParserUtils.parseTuple(parser);
    if (false == stringObjectTuple.v2() instanceof Comparable) {
        throw new IllegalArgumentException("lte section can only be used with objects that support natural ordering, found "
                + stringObjectTuple.v2().getClass().getSimpleName());
    }
    return new LessThanOrEqualToAssertion(location, stringObjectTuple.v1(), stringObjectTuple.v2());
}
项目:elasticsearch_my    文件:ExecutableSection.java   
static ExecutableSection parse(XContentParser parser) throws IOException {
    ParserUtils.advanceToFieldName(parser);
    String section = parser.currentName();
    XContentLocation location = parser.getTokenLocation();
    try {
        ExecutableSection executableSection = parser.namedObject(ExecutableSection.class, section, null);
        parser.nextToken();
        return executableSection;
    } catch (Exception e) {
        throw new IOException("Error parsing section starting at [" + location + "]", e);
    }
}
项目:elasticsearch_my    文件:GreaterThanEqualToAssertion.java   
public static GreaterThanEqualToAssertion parse(XContentParser parser) throws IOException {
    XContentLocation location = parser.getTokenLocation();
    Tuple<String,Object> stringObjectTuple = ParserUtils.parseTuple(parser);
    if (! (stringObjectTuple.v2() instanceof Comparable) ) {
        throw new IllegalArgumentException("gte section can only be used with objects that support natural ordering, found "
                + stringObjectTuple.v2().getClass().getSimpleName());
    }
    return new GreaterThanEqualToAssertion(location, stringObjectTuple.v1(), stringObjectTuple.v2());
}
项目:elasticsearch_my    文件:ClientYamlTestSectionTests.java   
public void testAddingDoWithoutWarningWithoutSkip() {
    int lineNumber = between(1, 10000);
    ClientYamlTestSection section = new ClientYamlTestSection(new XContentLocation(0, 0), "test");
    section.setSkipSection(SkipSection.EMPTY);
    DoSection doSection = new DoSection(new XContentLocation(lineNumber, 0));
    section.addExecutableSection(doSection);
}
项目:elasticsearch_my    文件:ClientYamlTestSectionTests.java   
public void testAddingDoWithWarningWithSkip() {
    int lineNumber = between(1, 10000);
    ClientYamlTestSection section = new ClientYamlTestSection(new XContentLocation(0, 0), "test");
    section.setSkipSection(new SkipSection(null, singletonList("warnings"), null));
    DoSection doSection = new DoSection(new XContentLocation(lineNumber, 0));
    doSection.setExpectedWarningHeaders(singletonList("foo"));
    section.addExecutableSection(doSection);
}
项目:elasticsearch_my    文件:ClientYamlTestSectionTests.java   
public void testAddingDoWithWarningWithSkipButNotWarnings() {
    int lineNumber = between(1, 10000);
    ClientYamlTestSection section = new ClientYamlTestSection(new XContentLocation(0, 0), "test");
    section.setSkipSection(new SkipSection(null, singletonList("yaml"), null));
    DoSection doSection = new DoSection(new XContentLocation(lineNumber, 0));
    doSection.setExpectedWarningHeaders(singletonList("foo"));
    Exception e = expectThrows(IllegalArgumentException.class, () -> section.addExecutableSection(doSection));
    assertEquals("Attempted to add a [do] with a [warnings] section without a corresponding [skip] so runners that do not support the"
            + " [warnings] section can skip the test at line [" + lineNumber + "]", e.getMessage());
}
项目:elasticsearch_my    文件:SearchParseException.java   
public SearchParseException(SearchContext context, String msg, @Nullable XContentLocation location, Throwable cause) {
    super(context, msg, cause);
    int lineNumber = UNKNOWN_POSITION;
    int columnNumber = UNKNOWN_POSITION;
    if (location != null) {
        if (location != null) {
            lineNumber = location.lineNumber;
            columnNumber = location.columnNumber;
        }
    }
    this.columnNumber = columnNumber;
    this.lineNumber = lineNumber;
}
项目:elasticsearch_my    文件:AbstractQueryBuilder.java   
protected static void throwParsingExceptionOnMultipleFields(String queryName, XContentLocation contentLocation,
                                                            String processedFieldName, String currentFieldName) {
    if (processedFieldName != null) {
        throw new ParsingException(contentLocation, "[" + queryName + "] query doesn't support multiple fields, found ["
                + processedFieldName + "] and [" + currentFieldName + "]");
    }
}
项目:elasticsearch_my    文件:QueryParseContext.java   
/**
 * Parses a query excluding the query element that wraps it
 */
public QueryBuilder parseInnerQueryBuilder() throws IOException {
    if (parser.currentToken() != XContentParser.Token.START_OBJECT) {
        if (parser.nextToken() != XContentParser.Token.START_OBJECT) {
            throw new ParsingException(parser.getTokenLocation(), "[_na] query malformed, must start with start_object");
        }
    }
    if (parser.nextToken() == XContentParser.Token.END_OBJECT) {
        // we encountered '{}' for a query clause, it used to be supported, deprecated in 5.0 and removed in 6.0
        throw new IllegalArgumentException("query malformed, empty clause found at [" + parser.getTokenLocation() +"]");
    }
    if (parser.currentToken() != XContentParser.Token.FIELD_NAME) {
        throw new ParsingException(parser.getTokenLocation(), "[_na] query malformed, no field after start_object");
    }
    String queryName = parser.currentName();
    // move to the next START_OBJECT
    if (parser.nextToken() != XContentParser.Token.START_OBJECT) {
        throw new ParsingException(parser.getTokenLocation(), "[" + queryName + "] query malformed, no start_object after query name");
    }
    QueryBuilder result;
    try {
        result = parser.namedObject(QueryBuilder.class, queryName, this);
    } catch (UnknownNamedObjectException e) {
        // Preserve the error message from 5.0 until we have a compellingly better message so we don't break BWC.
        // This intentionally doesn't include the causing exception because that'd change the "root_cause" of any unknown query errors
        throw new ParsingException(new XContentLocation(e.getLineNumber(), e.getColumnNumber()),
                "no [query] registered for [" + e.getName() + "]");
    }
    //end_object of the specific query (e.g. match, multi_match etc.) element
    if (parser.currentToken() != XContentParser.Token.END_OBJECT) {
        throw new ParsingException(parser.getTokenLocation(),
                "[" + queryName + "] malformed query, expected [END_OBJECT] but found [" + parser.currentToken() + "]");
    }
    //end_object of the query object
    if (parser.nextToken() != XContentParser.Token.END_OBJECT) {
        throw new ParsingException(parser.getTokenLocation(),
                "[" + queryName + "] malformed query, expected [END_OBJECT] but found [" + parser.currentToken() + "]");
    }
    return result;
}
项目:elasticsearch_my    文件:ParsingException.java   
public ParsingException(XContentLocation contentLocation, String msg, Throwable cause, Object... args) {
    super(msg, cause, args);
    int lineNumber = UNKNOWN_POSITION;
    int columnNumber = UNKNOWN_POSITION;
    if (contentLocation != null) {
        lineNumber = contentLocation.lineNumber;
        columnNumber = contentLocation.columnNumber;
    }
    this.columnNumber = columnNumber;
    this.lineNumber = lineNumber;
}
项目:elasticsearch_my    文件:JsonXContentParser.java   
@Override
public XContentLocation getTokenLocation() {
    JsonLocation loc = parser.getTokenLocation();
    if (loc == null) {
        return null;
    }
    return new XContentLocation(loc.getLineNr(), loc.getColumnNr());
}
项目:elasticsearch_my    文件:ExceptionSerializationTests.java   
public void testSearchParseException() throws IOException {
    SearchContext ctx = new TestSearchContext(null);
    SearchParseException ex = serialize(new SearchParseException(ctx, "foo", new XContentLocation(66, 666)));
    assertEquals("foo", ex.getMessage());
    assertEquals(66, ex.getLineNumber());
    assertEquals(666, ex.getColumnNumber());
    assertEquals(ctx.shardTarget(), ex.shard());
}
项目:lucene-custom-query    文件:SeqSpanQueryParser.java   
private static void throwParsingExceptionOnMultipleFields(String queryName, XContentLocation contentLocation,
                                                            String processedFieldName, String currentFieldName) {
  if (processedFieldName != null) {
    throw new ParsingException(contentLocation, "[" + queryName + "] query doesn't support multiple fields, found ["
        + processedFieldName + "] and [" + currentFieldName + "]");
  }
}
项目:Elasticsearch    文件:SearchParseException.java   
public SearchParseException(SearchContext context, String msg, @Nullable XContentLocation location, Throwable cause) {
    super(context, msg, cause);
    int lineNumber = UNKNOWN_POSITION;
    int columnNumber = UNKNOWN_POSITION;
    if (location != null) {
        if (location != null) {
            lineNumber = location.lineNumber;
            columnNumber = location.columnNumber;
        }
    }
    this.columnNumber = columnNumber;
    this.lineNumber = lineNumber;
}
项目:Elasticsearch    文件:JsonXContentParser.java   
@Override
public XContentLocation getTokenLocation() {
    JsonLocation loc = parser.getTokenLocation();
    if (loc == null) {
        return null;
    }
    return new XContentLocation(loc.getLineNr(), loc.getColumnNr());
}
项目:elasticsearch_my    文件:Assertion.java   
protected Assertion(XContentLocation location, String field, Object expectedValue) {
    this.location = location;
    this.field = field;
    this.expectedValue = expectedValue;
}
项目:elasticsearch_my    文件:Assertion.java   
@Override
public XContentLocation getLocation() {
    return location;
}
项目:elasticsearch_my    文件:LessThanAssertion.java   
public LessThanAssertion(XContentLocation location, String field, Object expectedValue) {
    super(location, field, expectedValue);
}
项目:elasticsearch_my    文件:GreaterThanAssertion.java   
public GreaterThanAssertion(XContentLocation location, String field, Object expectedValue) {
    super(location, field, expectedValue);
}
项目:elasticsearch_my    文件:SetSection.java   
public SetSection(XContentLocation location) {
    this.location = location;
}
项目:elasticsearch_my    文件:SetSection.java   
@Override
public XContentLocation getLocation() {
    return location;
}
项目:elasticsearch_my    文件:LessThanOrEqualToAssertion.java   
public LessThanOrEqualToAssertion(XContentLocation location, String field, Object expectedValue) {
    super(location, field, expectedValue);
}
项目:elasticsearch_my    文件:IsFalseAssertion.java   
public IsFalseAssertion(XContentLocation location, String field) {
    super(location, field, false);
}
项目:elasticsearch_my    文件:LengthAssertion.java   
public LengthAssertion(XContentLocation location, String field, Object expectedValue) {
    super(location, field, expectedValue);
}
项目:elasticsearch_my    文件:IsTrueAssertion.java   
public IsTrueAssertion(XContentLocation location, String field) {
    super(location, field, true);
}
项目:elasticsearch_my    文件:DoSection.java   
public DoSection(XContentLocation location) {
    this.location = location;
}
项目:elasticsearch_my    文件:DoSection.java   
@Override
public XContentLocation getLocation() {
    return location;
}
项目:elasticsearch_my    文件:ClientYamlTestSection.java   
public ClientYamlTestSection(XContentLocation location, String name) {
    this.location = location;
    this.name = name;
    this.executableSections = new ArrayList<>();
}
项目:elasticsearch_my    文件:ClientYamlTestSection.java   
public XContentLocation getLocation() {
    return location;
}
项目:elasticsearch_my    文件:MatchAssertion.java   
public static MatchAssertion parse(XContentParser parser) throws IOException {
    XContentLocation location = parser.getTokenLocation();
    Tuple<String,Object> stringObjectTuple = ParserUtils.parseTuple(parser);
    return new MatchAssertion(location, stringObjectTuple.v1(), stringObjectTuple.v2());
}
项目:elasticsearch_my    文件:MatchAssertion.java   
public MatchAssertion(XContentLocation location, String field, Object expectedValue) {
    super(location, field, expectedValue);
}
项目:elasticsearch_my    文件:GreaterThanEqualToAssertion.java   
public GreaterThanEqualToAssertion(XContentLocation location, String field, Object expectedValue) {
    super(location, field, expectedValue);
}
项目:elasticsearch_my    文件:SearchParseException.java   
public SearchParseException(SearchContext context, String msg, @Nullable XContentLocation location) {
    this(context, msg, location, null);
}
项目:elasticsearch_my    文件:FunctionScoreQueryBuilder.java   
private static void handleMisplacedFunctionsDeclaration(XContentLocation contentLocation, String errorString) {
    throw new ParsingException(contentLocation, "failed to parse [{}] query. [{}]", NAME,
            MISPLACED_FUNCTION_MESSAGE_PREFIX + errorString);
}
项目:elasticsearch_my    文件:ParsingException.java   
public ParsingException(XContentLocation contentLocation, String msg, Object... args) {
    this(contentLocation, msg, null, args);
}
项目:Elasticsearch    文件:SearchParseException.java   
public SearchParseException(SearchContext context, String msg, @Nullable XContentLocation location) {
    this(context, msg, location, null);
}