/** * Returns either backtick-quoted `named.getName()` (if `named` not null), * or "[null]" if `named` is null. * * @since 2.9 */ public static String nameOf(Named named) { if (named == null) { return "[null]"; } return backticked(named.getName()); }
@Override public void writeRawValue(String text) throws IOException { _appendValue(JsonToken.VALUE_EMBEDDED_OBJECT, new RawValue(text)); }
/** * Format a date into 'yyyy-MM-ddThh:mm:ss[.sss]Z' (GMT timezone) * * @param date the date to format * @param millis true to include millis precision otherwise false * @return the date formatted as 'yyyy-MM-ddThh:mm:ss[.sss]Z' */ public static String format(Date date, boolean millis) { return format(date, millis, TIMEZONE_Z); }
/** * Helper method used to skip processing for types that we know * cannot be (i.e. are never consider to be) beans: * things like primitives, Arrays, Enums, and proxy types. *<p> * Note that usually we shouldn't really be getting these sort of * types anyway; but better safe than sorry. */ protected boolean isPotentialBeanType(Class<?> type) { return (ClassUtil.canBeABeanType(type) == null) && !ClassUtil.isProxyType(type); }
public JsonToken peekNextToken() throws IOException { // closed? nothing more to peek, either if (_closed) return null; Segment seg = _segment; int ptr = _segmentPtr+1; if (ptr >= Segment.TOKENS_PER_SEGMENT) { ptr = 0; seg = (seg == null) ? null : seg.next(); } return (seg == null) ? null : seg.type(ptr); }
@Override public <A extends Annotation> A getContextAnnotation(Class<A> acls) { return (_contextAnnotations == null) ? null : _contextAnnotations .get(acls); }
@Override public PropertyName findRootName(JavaType rootType) { if (_rootName != null) { return _rootName; } return _rootNames.findRootName(rootType, this); }
@Override public void writeUTF8String(byte[] text, int offset, int length) throws IOException { // could add support for buffering if we really want it... _reportUnsupportedOperation(); }
@Override protected void _handleEOF() throws JsonParseException { _throwInternal(); } }
public ShortBuilder getShortBuilder() { if (_shortBuilder == null) { _shortBuilder = new ShortBuilder(); } return _shortBuilder; } public IntBuilder getIntBuilder()
public LongBuilder getLongBuilder() { if (_longBuilder == null) { _longBuilder = new LongBuilder(); } return _longBuilder; }
@Override public void serializeWithType(JsonGenerator gen, SerializerProvider provider, TypeSerializer typeSer) throws IOException { // No type for JSONP wrapping: value serializer will handle typing for value: serialize(gen, provider); }
protected boolean _isExplicitClassOrOb(Object maybeCls, Class<?> implicit) { if ((maybeCls == null) || (maybeCls == implicit)) { return false; } if (maybeCls instanceof Class<?>) { return !ClassUtil.isBogusClass((Class<?>) maybeCls); } return true; }
/** * @return Iterator that can be used to traverse all key/value pairs for * object nodes; empty iterator (no contents) for other types */ public Iterator<Map.Entry<String, JsonNode>> fields() { return ClassUtil.emptyIterator(); }
/** * @since 2.9 */ protected void _ensureOverride(String method) { ClassUtil.verifyMustOverride(MapSerializer.class, this, method); }
@Override public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { TimeZone tz = _timezone; if (tz == null) { tz = DEFAULT_TIMEZONE; } _format(tz, _locale, date, toAppendTo); return toAppendTo; }
@Override public PropertyName findRootName(Class<?> rawRootType) { if (_rootName != null) { return _rootName; } return _rootNames.findRootName(rawRootType, this); }