/** * Is there something (like JSON mode) that forces us to inline or maybe we * are referred to by multiple other things */ protected boolean isInline() { return context.isJsonMode() || !referenced; }
/** * Are we in JSON mode, and therefore must quote property names? */ public boolean isJsonMode() { return context.isJsonMode(); }
/** * Constructor for when we have a Javascript type to populate */ public ObjectOutboundVariable(OutboundContext context, Class<?> type, String scriptClassName) { super(context); if (context.isJsonMode()) { if (scriptClassName != null) { throw new JsonModeMarshallException(type, "Can't used named Javascript objects in JSON mode"); } } this.scriptClassName = scriptClassName; this.isNamed = scriptClassName != null && scriptClassName.length() > 0; }
public OutboundVariable convertOutbound(Object data, OutboundContext converted) throws ConversionException { if (data == null) { return new NonNestedOutboundVariable("null"); } // Check to see if we have done this one already if (!converted.isJsonMode()) { OutboundVariable ov = converted.get(data); if (ov != null) { // So the object as been converted already, we just need to refer to it. return ov.getReferenceVariable(); } } // So we will have to do the conversion Converter converter = getConverter(data); if (converter == null) { String message = "No outbound converter found for '" + data.getClass().getName() + "'"; log.error(message); return new ErrorOutboundVariable(message); } return converter.convertOutbound(data, converted); }