Search in sources :

Example 6 with OutboundVariable

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();
}
Also used : OutboundVariable(org.directwebremoting.extend.OutboundVariable)

Example 7 with OutboundVariable

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());
}
Also used : OutboundVariable(org.directwebremoting.extend.OutboundVariable)

Example 8 with OutboundVariable

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);
    }
}
Also used : OutboundVariable(org.directwebremoting.extend.OutboundVariable) SimpleOutboundVariable(org.directwebremoting.dwrp.SimpleOutboundVariable) MarshallException(org.directwebremoting.extend.MarshallException) Node(nu.xom.Node) SimpleOutboundVariable(org.directwebremoting.dwrp.SimpleOutboundVariable) MarshallException(org.directwebremoting.extend.MarshallException)

Example 9 with OutboundVariable

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);
}
Also used : OutboundVariable(org.directwebremoting.extend.OutboundVariable) NamedConverter(org.directwebremoting.extend.NamedConverter) Converter(org.directwebremoting.extend.Converter)

Example 10 with OutboundVariable

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);
}
Also used : OutboundVariable(org.directwebremoting.extend.OutboundVariable) SimpleOutboundVariable(org.directwebremoting.dwrp.SimpleOutboundVariable) NamedConverter(org.directwebremoting.extend.NamedConverter) Converter(org.directwebremoting.extend.Converter) SimpleOutboundVariable(org.directwebremoting.dwrp.SimpleOutboundVariable)

Aggregations

OutboundVariable (org.directwebremoting.extend.OutboundVariable)21 MarshallException (org.directwebremoting.extend.MarshallException)12 Iterator (java.util.Iterator)10 Map (java.util.Map)7 ObjectOutboundVariable (org.directwebremoting.dwrp.ObjectOutboundVariable)6 SimpleOutboundVariable (org.directwebremoting.dwrp.SimpleOutboundVariable)6 TreeMap (java.util.TreeMap)5 Property (org.directwebremoting.extend.Property)5 StringWriter (java.io.StringWriter)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 ArrayOutboundVariable (org.directwebremoting.dwrp.ArrayOutboundVariable)2 ErrorOutboundVariable (org.directwebremoting.dwrp.ErrorOutboundVariable)2 Converter (org.directwebremoting.extend.Converter)2 NamedConverter (org.directwebremoting.extend.NamedConverter)2 Collection (java.util.Collection)1 Entry (java.util.Map.Entry)1 Unit (javax.measure.unit.Unit)1 Source (javax.xml.transform.Source)1