use of org.directwebremoting.extend.Converter in project ma-core-public by infiniteautomation.
the class DefaultConverterManager method convertInbound.
/* (non-Javadoc)
* @see org.directwebremoting.ConverterManager#convertInbound(java.lang.Class, org.directwebremoting.InboundVariable, org.directwebremoting.InboundContext, org.directwebremoting.TypeHintContext)
*/
public Object convertInbound(Class paramType, InboundVariable iv, InboundContext inctx, TypeHintContext incc) throws MarshallException {
Object converted = inctx.getConverted(iv, paramType);
if (converted == null) {
// Was the inbound variable marshalled as an Object in the client
// (could mean that this is an instance of one of our generated
// JavaScript classes)
Converter converter = getNamedConverter(paramType, iv.getType());
// didn't find anything above
if (converter == null) {
converter = getConverter(paramType);
}
if (converter == null) {
throw new MarshallException(paramType, Messages.getString("DefaultConverterManager.MissingConverter", paramType));
}
// from passing null to things they are not allowed to convert
if (iv.isNull()) {
return null;
}
inctx.pushContext(incc);
converted = converter.convertInbound(paramType, iv, inctx);
inctx.popContext();
}
return converted;
}
use of org.directwebremoting.extend.Converter 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.Converter in project ma-core-public by infiniteautomation.
the class DefaultConverterManager method addConverter.
/* (non-Javadoc)
* @see org.directwebremoting.ConverterManager#addConverter(java.lang.String, java.lang.String, java.util.Map)
*/
public void addConverter(String match, String type, Map params) throws IllegalArgumentException, InstantiationException, IllegalAccessException {
Class clazz = (Class) converterTypes.get(type);
if (clazz == null) {
log.info("Probably not an issue: " + match + " is not available so the " + type + " converter will not load. This is only a problem if you wanted to use it.");
return;
}
Converter converter = (Converter) clazz.newInstance();
converter.setConverterManager(this);
LocalUtil.setParams(converter, params, ignore);
// add the converter for the specified match
addConverter(match, converter);
}
use of org.directwebremoting.extend.Converter 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);
}
use of org.directwebremoting.extend.Converter in project ma-core-public by infiniteautomation.
the class BlabberConverterManager method addConverter.
/*
* (non-Javadoc)
*
* @see org.directwebremoting.ConverterManager#addConverter(java.lang.String, java.lang.String, java.util.Map)
*/
public void addConverter(String match, String type, @SuppressWarnings("rawtypes") Map params) throws IllegalArgumentException, InstantiationException, IllegalAccessException {
Class<Converter> clazz = converterTypes.get(type);
if (clazz == null) {
log.info("Probably not an issue: " + match + " is not available so the " + type + " converter will not load. This is only an problem if you wanted to use it.");
return;
}
// TODO fix this by modifying the ma-priv code, but until we have a good copy this is my plan!
// String js = match.substring(match.lastIndexOf(".")+1);
// params.put("javascript", js);
Converter converter = clazz.newInstance();
converter.setConverterManager(this);
LocalUtil.setParams(converter, params, ignore);
// add the converter for the specified match
addConverter(match, converter);
}
Aggregations