use of javax.measure.unit.Unit in project ma-core-public by infiniteautomation.
the class UnitBeanConverter method convertOutbound.
/* (non-Javadoc)
* @see org.directwebremoting.extend.Converter#convertOutbound(java.lang.Object, org.directwebremoting.extend.OutboundContext)
*/
@Override
public OutboundVariable convertOutbound(Object paramObject, OutboundContext paramOutboundContext) throws MarshallException {
// Convert from Unit to String
// Check to see if we have done this one already
OutboundVariable ov = paramOutboundContext.get(paramObject);
if (ov != null) {
// So the object as been converted already, we just need to refer to it.
return ov.getReferenceVariable();
}
if (paramObject instanceof Unit<?>) {
Unit<?> unit = (Unit<?>) paramObject;
String unitString = UnitUtil.formatLocal(unit);
if (unit == unit.ONE)
unitString = "ONE";
return new SimpleOutboundVariable("'" + unitString + "';", paramOutboundContext, false);
} else {
throw new MarshallException(paramObject.getClass());
}
}
Aggregations