當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonLocation.getLineNr方法代碼示例

本文整理匯總了Java中com.fasterxml.jackson.core.JsonLocation.getLineNr方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonLocation.getLineNr方法的具體用法?Java JsonLocation.getLineNr怎麽用?Java JsonLocation.getLineNr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.fasterxml.jackson.core.JsonLocation的用法示例。


在下文中一共展示了JsonLocation.getLineNr方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTokenLocation

import com.fasterxml.jackson.core.JsonLocation; //導入方法依賴的package包/類
@Override
public XContentLocation getTokenLocation() {
    JsonLocation loc = parser.getTokenLocation();
    if (loc == null) {
        return null;
    }
    return new XContentLocation(loc.getLineNr(), loc.getColumnNr());
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:9,代碼來源:JsonXContentParser.java

示例2: initializeJsonLocation

import com.fasterxml.jackson.core.JsonLocation; //導入方法依賴的package包/類
private void initializeJsonLocation(@Nullable JsonLocation jsonLoc) {
    if (jsonLoc == null) {
        return;
    }

    this.charOffset = ((int) jsonLoc.getCharOffset());
    this.colNum = jsonLoc.getColumnNr();
    this.lineNum = jsonLoc.getLineNr();
}
 
開發者ID:esacinc,項目名稱:sdcct,代碼行數:10,代碼來源:SdcctLocation.java

示例3: build

import com.fasterxml.jackson.core.JsonLocation; //導入方法依賴的package包/類
public static JsonNode build(final JsonProcessingException e,
    final boolean crlf)
{
    final JsonLocation location = e.getLocation();
    final ObjectNode ret = JsonNodeFactory.instance.objectNode();

    /*
     * Unfortunately, for some reason, Jackson botches the column number in
     * its JsonPosition -- I cannot figure out why exactly. However, it does
     * have a correct offset into the buffer.
     *
     * The problem is that if the input has CR/LF line terminators, its
     * offset will be "off" by the number of lines minus 1 with regards to
     * what JavaScript sees as positions in text areas. Make the necessary
     * adjustments so that the caret jumps at the correct position in this
     * case.
     */
    final int lineNr = location.getLineNr();
    int offset = (int) location.getCharOffset();
    if (crlf)
        offset = offset - lineNr + 1;
    ret.put(LINE, lineNr);
    ret.put(OFFSET, offset);

    // Finally, put the message
    ret.put(MESSAGE, e.getOriginalMessage());
    return ret;
}
 
開發者ID:fge,項目名稱:json-schema-validator-demo,代碼行數:29,代碼來源:ParseError.java

示例4: createLocation

import com.fasterxml.jackson.core.JsonLocation; //導入方法依賴的package包/類
private Location createLocation(JsonLocation json) {
    return new Location(json.getLineNr() - 1, json.getColumnNr() - 1);
}
 
開發者ID:RepreZen,項目名稱:KaiZen-OpenAPI-Editor,代碼行數:4,代碼來源:NodeDeserializer.java

示例5: toResponse

import com.fasterxml.jackson.core.JsonLocation; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public Response toResponse(JsonProcessingException exception) {
    Throwable throwable = exception;
    while (throwable != null) {
        if (throwable instanceof PersistenceException) {
            return exceptionMappers.get().findMapping(throwable).toResponse(throwable);
        }
        throwable = throwable.getCause();
    }

    logger.debug("Json Processing error", exception);
    String message = exception.getOriginalMessage();
    String desc = null;
    String source = null;
    if (mode.isDev()) {
        desc = IOUtils.getStackTrace(exception);
        JsonLocation location = exception.getLocation();
        if (location != null) {
            source = "line: " + location.getLineNr() +
                    ", column: " + location.getColumnNr();
        } else {
            source = exception.getStackTrace()[0].toString();
        }
    }

    ErrorMessage errorMessage = ErrorMessage.fromStatus(Response.Status.BAD_REQUEST.getStatusCode());
    errorMessage.setThrowable(exception);
    errorMessage.setCode(Hashing.murmur3_32().hashUnencodedChars(exception.getClass().getName()).toString());

    errorMessage.addError(new Result.Error(
            errorMessage.getCode(),
            message != null ? message : exception.getMessage(),
            desc,
            source
    ));

    return Response.status(errorMessage.getStatus())
            .entity(errorMessage)
            .type(ExceptionMapperUtils.getResponseType())
            .build();
}
 
開發者ID:icode,項目名稱:ameba,代碼行數:45,代碼來源:JsonProcessingExceptionMapper.java


注:本文中的com.fasterxml.jackson.core.JsonLocation.getLineNr方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。