本文整理匯總了Java中com.fasterxml.jackson.core.JsonLocation.NA屬性的典型用法代碼示例。如果您正苦於以下問題:Java JsonLocation.NA屬性的具體用法?Java JsonLocation.NA怎麽用?Java JsonLocation.NA使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.fasterxml.jackson.core.JsonLocation
的用法示例。
在下文中一共展示了JsonLocation.NA屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: deserialize
@Override
public User deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
JsonNode rootNode = jp.readValueAsTree();
User user = MAPPER.readValue(rootNode.traverse(), User.class);
if (user.getSchemas() == null) {
throw new JsonMappingException(jp, "Required field 'schemas' is missing");
}
if (user.getSchemas().size() == 1) {
return user;
}
User.Builder builder = new User.Builder(user);
for (String urn : user.getSchemas()) {
if (urn.equals(schema)) {
continue;
}
JsonNode extensionNode = rootNode.get(urn);
if (extensionNode == null) {
throw new JsonParseException(jp, "Registered extension not present: " + urn, JsonLocation.NA);
}
builder.addExtension(deserializeExtension(jp, extensionNode, urn));
}
return builder.build();
}
示例2: _reportInvalidBase64
protected final void _reportInvalidBase64(Base64Variant paramBase64Variant, char paramChar, int paramInt, String paramString)
{
String str;
if (paramChar <= ' ')
str = "Illegal white space character (code 0x" + Integer.toHexString(paramChar) + ") as character #" + (paramInt + 1) + " of 4-char base64 unit: can only used between units";
else if (paramBase64Variant.usesPaddingChar(paramChar))
str = "Unexpected padding character ('" + paramBase64Variant.getPaddingChar() + "') as character #" + (paramInt + 1) + " of 4-char base64 unit: padding only legal as 3rd or 4th character";
else if ((!Character.isDefined(paramChar)) || (Character.isISOControl(paramChar)))
str = "Illegal character (code 0x" + Integer.toHexString(paramChar) + ") in base64 content";
else
str = "Illegal character '" + paramChar + "' (code 0x" + Integer.toHexString(paramChar) + ") in base64 content";
if (paramString != null)
str = str + ": " + paramString;
throw new JsonParseException(str, JsonLocation.NA);
}
示例3: doSerializeV3
@Override
public void doSerializeV3(final JSONProperty property, final JsonGenerator jgen, final SerializerProvider provider)
throws IOException, JsonProcessingException {
jgen.writeStartObject();
if (property.getMetadata() != null) {
jgen.writeStringField(ODataConstants.JSON_METADATA, property.getMetadata().toASCIIString());
}
final Element content = property.getContent();
if (XMLUtils.hasOnlyTextChildNodes(content)) {
jgen.writeStringField(ODataConstants.JSON_VALUE, content.getTextContent());
} else {
try {
final DocumentBuilder builder = ODataConstants.DOC_BUILDER_FACTORY.newDocumentBuilder();
final Document document = builder.newDocument();
final Element wrapper = document.createElement(ODataConstants.ELEM_PROPERTY);
if (XMLUtils.hasElementsChildNode(content)) {
wrapper.appendChild(document.renameNode(
document.importNode(content, true), null, ODataConstants.JSON_VALUE));
DOMTreeUtils.writeSubtree(client, jgen, wrapper);
} else if (EdmSimpleType.isGeospatial(content.getAttribute(ODataConstants.ATTR_M_TYPE))) {
wrapper.appendChild(document.renameNode(
document.importNode(content, true), null, ODataConstants.JSON_VALUE));
DOMTreeUtilsV3.writeSubtree(client, jgen, wrapper, true);
} else {
DOMTreeUtils.writeSubtree(client, jgen, content);
}
} catch (Exception e) {
throw new JsonParseException("Cannot serialize property", JsonLocation.NA, e);
}
}
jgen.writeEndObject();
}
示例4: doSerializeV4
@Override
public void doSerializeV4(final JSONProperty property, final JsonGenerator jgen, final SerializerProvider provider)
throws IOException, JsonProcessingException {
jgen.writeStartObject();
final Element content = property.getContent();
if (XMLUtils.hasOnlyTextChildNodes(content)) {
jgen.writeStringField(ODataConstants.JSON_VALUE, content.getTextContent());
} else {
try {
final DocumentBuilder builder = ODataConstants.DOC_BUILDER_FACTORY.newDocumentBuilder();
final Document document = builder.newDocument();
final Element wrapper = document.createElement(ODataConstants.ELEM_PROPERTY);
if (XMLUtils.hasElementsChildNode(content)) {
wrapper.appendChild(document.renameNode(
document.importNode(content, true), null, ODataConstants.JSON_VALUE));
DOMTreeUtils.writeSubtree(client, jgen, wrapper);
} else if (EdmSimpleType.isGeospatial(content.getAttribute(ODataConstants.ATTR_M_TYPE))) {
wrapper.appendChild(document.renameNode(
document.importNode(content, true), null, ODataConstants.JSON_VALUE));
DOMTreeUtilsV4.writeSubtree(client, jgen, wrapper, true);
} else {
DOMTreeUtils.writeSubtree(client, jgen, content);
}
} catch (Exception e) {
throw new JsonParseException("Cannot serialize property", JsonLocation.NA, e);
}
}
jgen.writeEndObject();
}
示例5: deserialize
@Override
public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
try {
return sdf.parse(jsonParser.getText());
} catch (ParseException ex) {
try {
long numericDate = Long.parseLong(jsonParser.getText());
return new Date(numericDate);
} catch (NumberFormatException ex2) {
throw new JsonParseException ("El formato de la fecha '" + jsonParser.getText() + "' no es correcto",JsonLocation.NA);
}
}
}
示例6: JacksonStreamReaderImpl
/**
* Constructs a {@link JacksonStreamReaderImpl} with the provided {@link JsonParser}.
*
* @param jp
* JsonParser from which to get tokens
* @throws IOException
* Null JsonParser or error getting token
*/
public JacksonStreamReaderImpl(final JsonParser jp) throws IOException {
if (jp == null) {
throw new JacksonStreamReaderException("JsonParser cannot be null", JsonLocation.NA);
}
this.jp = jp;
if (jp.getCurrentToken() == null) {
jp.nextToken();
}
}
示例7: shouldTranslateJsonParseException
@Test
public void shouldTranslateJsonParseException() {
String originalMessage = "originalMessage";
JsonParseException jsonParseException = new JsonParseException(originalMessage, JsonLocation.NA);
Exception translatedException =
JsonProcessingExceptionTranslator.translateJsonProcessingException(jsonParseException);
assertThat(translatedException, instanceOf(DNSAPIClientJsonMappingException.class));
assertEquals(DNSAPIClientJsonMappingException.DNSAPIClientJsonMappingExceptionCode.unexpectedMappingError,
((DNSAPIClientJsonMappingException) translatedException).getExceptionCode());
assertArrayEquals(new Object[] {"unknown", originalMessage + "\n at [Source: N/A; line: -1, column: -1]"},
((DNSAPIClientJsonMappingException) translatedException).getObjects());
}
示例8: getTokenLocation
@Override
public JsonLocation getTokenLocation() {
ConfigValue current = currentConfig();
if (current == null) {
return JsonLocation.NA;
}
ConfigOrigin nodeOrigin = current.origin();
return new JsonLocation(current, -1, nodeOrigin.lineNumber(), -1);
}
示例9: serialize
/**
* {@inheritDoc }
*/
@Override
public void serialize(final JSONProperty property, final JsonGenerator jgen, final SerializerProvider provider)
throws IOException, JsonProcessingException {
jgen.writeStartObject();
if (property.getMetadata() != null) {
jgen.writeStringField(ODataConstants.JSON_METADATA, property.getMetadata().toASCIIString());
}
final Element content = property.getContent();
if (XMLUtils.hasOnlyTextChildNodes(content)) {
jgen.writeStringField(ODataConstants.JSON_VALUE, content.getTextContent());
} else {
try {
final DocumentBuilder builder = ODataConstants.DOC_BUILDER_FACTORY.newDocumentBuilder();
final Document document = builder.newDocument();
final Element wrapper = document.createElement(ODataConstants.ELEM_PROPERTY);
if (XMLUtils.hasElementsChildNode(content)) {
wrapper.appendChild(document.renameNode(
document.importNode(content, true), null, ODataConstants.JSON_VALUE));
DOMTreeUtils.writeSubtree(jgen, wrapper);
} else if (EdmSimpleType.isGeospatial(content.getAttribute(ODataConstants.ATTR_M_TYPE))) {
wrapper.appendChild(document.renameNode(
document.importNode(content, true), null, ODataConstants.JSON_VALUE));
DOMTreeUtils.writeSubtree(jgen, wrapper, true);
} else {
DOMTreeUtils.writeSubtree(jgen, content);
}
} catch (Exception e) {
throw new JsonParseException("Cannot serialize property", JsonLocation.NA, e);
}
}
jgen.writeEndObject();
}
示例10: content
public Builder content(JsonNode n){
content = new JSONOptions(n, JsonLocation.NA);
return this;
}
示例11: _reportUndetectableSource
protected void _reportUndetectableSource(Object paramObject)
{
throw new JsonParseException("Can not use source of type " + paramObject.getClass().getName() + " with format auto-detection: must be byte- not char-based", JsonLocation.NA);
}
示例12: _reportUnkownFormat
protected void _reportUnkownFormat(DataFormatReaders paramDataFormatReaders, DataFormatReaders.Match paramMatch)
{
throw new JsonParseException("Can not detect format from input, does not look like any of detectable formats " + paramDataFormatReaders.toString(), JsonLocation.NA);
}
示例13: getCurrentLocation
public final JsonLocation getCurrentLocation()
{
if (this._location == null)
return JsonLocation.NA;
return this._location;
}
示例14: getCurrentLocation
public JsonLocation getCurrentLocation()
{
return JsonLocation.NA;
}
示例15: getTokenLocation
public JsonLocation getTokenLocation()
{
return JsonLocation.NA;
}