use of org.directwebremoting.extend.OutboundVariable in project ma-core-public by infiniteautomation.
the class ArrayOutboundVariable method getInlineDefinition.
/* (non-Javadoc)
* @see org.directwebremoting.dwrp.AbstractOutboundVariable#getInlineDefinition()
*/
protected String getInlineDefinition() {
StringBuffer buffer = new StringBuffer();
buffer.append("[");
boolean first = true;
for (int i = 0; i < ovs.size(); i++) {
OutboundVariable ov = (OutboundVariable) ovs.get(i);
if (!first) {
buffer.append(',');
}
buffer.append(ov.getAssignCode());
first = false;
}
buffer.append("]");
return buffer.toString();
}
use of org.directwebremoting.extend.OutboundVariable in project ma-core-public by infiniteautomation.
the class ArrayOutboundVariable method getNotInlineDefinition.
/* (non-Javadoc)
* @see org.directwebremoting.dwrp.AbstractOutboundVariable#getNotInlineDefinition()
*/
protected NotInlineDefinition getNotInlineDefinition() {
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < ovs.size(); i++) {
OutboundVariable nested = (OutboundVariable) ovs.get(i);
String varName = getVariableName();
if (nested != null) {
buffer.append(varName);
buffer.append('[');
buffer.append(i);
buffer.append("]=");
buffer.append(nested.getAssignCode());
buffer.append(';');
}
}
buffer.append("\r\n");
return new NotInlineDefinition("var " + getVariableName() + "=[];", buffer.toString());
}
use of org.directwebremoting.extend.OutboundVariable in project ma-core-public by infiniteautomation.
the class XOMConverter method convertOutbound.
/* (non-Javadoc)
* @see org.directwebremoting.Converter#convertOutbound(java.lang.Object, org.directwebremoting.OutboundContext)
*/
public OutboundVariable convertOutbound(Object data, OutboundContext outctx) throws MarshallException {
try {
// Using XSLT to convert to a stream. Setup the source
if (!(data instanceof Node)) {
throw new MarshallException(data.getClass());
}
Node node = (Node) data;
String script = EnginePrivate.xmlStringToJavascriptDom(node.toXML());
OutboundVariable ov = new SimpleOutboundVariable(script, outctx, false);
outctx.put(data, ov);
return ov;
} catch (MarshallException ex) {
throw ex;
} catch (Exception ex) {
throw new MarshallException(data.getClass(), ex);
}
}
use of org.directwebremoting.extend.OutboundVariable in project ma-core-public by infiniteautomation.
the class DefaultConverterManager method convertOutbound.
/* (non-Javadoc)
* @see org.directwebremoting.ConverterManager#convertOutbound(java.lang.Object, org.directwebremoting.OutboundContext)
*/
public OutboundVariable convertOutbound(Object object, OutboundContext outctx) throws MarshallException {
if (object == null) {
return new SimpleOutboundVariable("null", outctx, true);
}
// Check to see if we have done this one already
OutboundVariable ov = outctx.get(object);
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(object);
if (converter == null) {
log.error(Messages.getString("DefaultConverterManager.MissingConverter", object.getClass().getName()));
return new SimpleOutboundVariable("null", outctx, true);
}
return converter.convertOutbound(object, outctx);
}
use of org.directwebremoting.extend.OutboundVariable in project ma-core-public by infiniteautomation.
the class BlabberConverterManager method convertOutbound.
/*
* (non-Javadoc)
*
* @see org.directwebremoting.ConverterManager#convertOutbound(java.lang.Object,
* org.directwebremoting.OutboundContext)
*/
public OutboundVariable convertOutbound(Object object, OutboundContext outctx) throws MarshallException {
if (object == null) {
return new SimpleOutboundVariable("null", outctx, true);
}
// Check to see if we have done this one already
OutboundVariable ov = outctx.get(object);
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(object);
if (converter == null) {
log.error(Messages.getString("DefaultConverterManager.MissingConverter", object.getClass().getName()));
return new SimpleOutboundVariable("null", outctx, true);
}
return converter.convertOutbound(object, outctx);
}
Aggregations