本文整理汇总了Java中org.directwebremoting.ConversionException类的典型用法代码示例。如果您正苦于以下问题:Java ConversionException类的具体用法?Java ConversionException怎么用?Java ConversionException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConversionException类属于org.directwebremoting包,在下文中一共展示了ConversionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertOutbound
import org.directwebremoting.ConversionException; //导入依赖的package包/类
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
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 converter found for '" + data.getClass().getName() + "'";
log.error(message);
return new ErrorOutboundVariable(message);
}
return converter.convertOutbound(data, converted);
}
示例2: createChild
import org.directwebremoting.ConversionException; //导入依赖的package包/类
public Property createChild(int newParameterNumber) throws ConversionException
{
Method method = descriptor.getReadMethod();
if (method == null)
{
throw new ConversionException(descriptor.getPropertyType(), "Property \"" + descriptor.getDisplayName() + "\" of type " + descriptor.getPropertyType().getName() + " has no read method (getter).");
}
// Type[] types = method.getGenericParameterTypes();
// if (types.length == 0)
// {
// return new NestedProperty(this, method, null, 0, newParameterNumber);
// }
// return new NestedProperty(this, method, types[0], 0, newParameterNumber);
return new NestedProperty(
this, method, method.getGenericReturnType(), 0, newParameterNumber);
}
示例3: dereference
import org.directwebremoting.ConversionException; //导入依赖的package包/类
/**
* Attempt to de-reference an inbound variable.
* We try de-referencing as soon as possible (why? there is a good reason
* for it, it fixes some bug, but I can't remember what right now) However
* the referenced variable may not exist yet, so the de-referencing may
* fail, requiring us to have another go later.
* @throws ConversionException If cross-references don't add up
*/
public void dereference() throws ConversionException
{
int depth = 0;
while (ProtocolConstants.TYPE_REFERENCE.equals(type))
{
InboundVariable cd = context.getInboundVariable(formField.getString());
if (cd == null)
{
throw new ConversionException(getClass(), "Found reference to variable named '" + formField.getString() + "', but no variable of that name could be found.");
}
type = cd.type;
formField = cd.getFormField();
key = cd.key;
depth++;
if (depth > 20)
{
throw new ConversionException(getClass(), "Max depth exceeded when dereferencing " + formField.getString());
}
}
dereferenced = true;
}
示例4: convertOutbound
import org.directwebremoting.ConversionException; //导入依赖的package包/类
public OutboundVariable convertOutbound(Object data, OutboundContext outctx) throws ConversionException
{
long millis;
if (data instanceof Calendar)
{
Calendar cal = (Calendar) data;
millis = cal.getTime().getTime();
}
else if (data instanceof Date)
{
Date date = (Date) data;
millis = date.getTime();
}
else
{
throw new ConversionException(data.getClass());
}
return new NonNestedOutboundVariable("new Date(" + millis + ")");
}
示例5: convertInbound
import org.directwebremoting.ConversionException; //导入依赖的package包/类
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException
{
if (data.isNull())
{
return null;
}
String urlString = data.urlDecode();
try
{
return new URL(urlString);
}
catch (MalformedURLException ex)
{
log.warn("Failed to create URL from string '" + urlString + "'. Returning null");
return null;
}
}
示例6: convertInbound
import org.directwebremoting.ConversionException; //导入依赖的package包/类
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException
{
if (data.isNull())
{
return null;
}
String uriString = data.urlDecode();
try
{
return new URI(uriString);
}
catch (URISyntaxException ex)
{
log.warn("Failed to create URL from string '" + uriString + "'. Returning null");
return null;
}
}
示例7: convertInbound
import org.directwebremoting.ConversionException; //导入依赖的package包/类
/**
* Parses a currency ISO code.
*/
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException
{
if (data.isNull())
{
return null;
}
try
{
Currency currency = Currency.getInstance(data.getValue());
if (currency == null)
{
throw new IllegalArgumentException(data.getValue() + " is not a valid java.util.Currency value");
}
return currency;
}
catch (Exception ex)
{
throw new ConversionException(Currency.class, ex);
}
}
示例8: getPropertyMapFromClass
import org.directwebremoting.ConversionException; //导入依赖的package包/类
@Override
public Map<String, Property> getPropertyMapFromClass(Class<?> type, boolean readRequired, boolean writeRequired) throws ConversionException
{
Map<String, Property> descriptors = super.getPropertyMapFromClass(type, readRequired, writeRequired);
descriptors.put("javaClassName", new PlainProperty("javaClassName", type.getName()));
// Make sure Throwable's standard properties are added
// (fix for Bean Introspector peculiarities)
try
{
fixMissingThrowableProperty(descriptors, "message", "getMessage");
fixMissingThrowableProperty(descriptors, "cause", "getCause");
}
catch (IntrospectionException ex)
{
throw new ConversionException(type, ex);
}
return descriptors;
}
示例9: convertInbound
import org.directwebremoting.ConversionException; //导入依赖的package包/类
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException
{
if (data.isNull())
{
return null;
}
if (data.getFormField().isFile())
{
// Data from file uploads is not URL encoded
return data.getValue();
}
else
{
return data.urlDecode();
}
}
示例10: getData
import org.directwebremoting.ConversionException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T getData(Class<T> asType)
{
if (source == Source.SERVER)
{
try
{
return (T) data;
}
catch (ClassCastException ex)
{
throw new ConversionException(asType, ex);
}
}
else
{
return converterManager.convertInbound(asType, rawData);
}
}
示例11: assertInboundConversionFailure
import org.directwebremoting.ConversionException; //导入依赖的package包/类
public static void assertInboundConversionFailure(String input, Class<?> convertTo)
{
ConverterManager converterManager = TestEnvironment.getConverterManager();
InboundContext ctx = new InboundContext();
String explanation = "Convert \"" + input + "\" to " + convertTo.getSimpleName();
try
{
InboundVariable iv = new InboundVariable(ctx, null, "type", input);
iv.dereference();
converterManager.convertInbound(convertTo, iv, null);
Assert.fail();
}
catch (Exception ex)
{
Assert.assertEquals(explanation, ex.getClass(), ConversionException.class);
}
}
示例12: addScriptHandleExceptions
import org.directwebremoting.ConversionException; //导入依赖的package包/类
/**
* Marshall a Script without worrying about MarshallExceptions
*/
public void addScriptHandleExceptions(ScriptConduit conduit, ScriptBuffer script) throws IOException
{
try
{
conduit.sendScript(ScriptBufferUtil.createOutput(script, converterManager, jsonOutput));
}
catch (ConversionException ex)
{
log.warn("Error marshalling exception. Is the exception converter configured?", ex);
}
}
示例13: convertInbound
import org.directwebremoting.ConversionException; //导入依赖的package包/类
public Object convertInbound(Class<?> typeInfo, InboundVariable data) throws ConversionException
{
try
{
return getConverter().convertInbound(typeInfo, data);
}
catch (ClassCastException e)
{
throw new ConversionException(type, e);
}
}
示例14: convertOutbound
import org.directwebremoting.ConversionException; //导入依赖的package包/类
public OutboundVariable convertOutbound(Object data, OutboundContext outctx) throws ConversionException
{
try
{
return getConverter().convertOutbound(type.cast(data), outctx);
}
catch (ClassCastException e)
{
throw new ConversionException(type, e);
}
}
示例15: convertInbound
import org.directwebremoting.ConversionException; //导入依赖的package包/类
public <T> T convertInbound(Class<T> paramType, RawData rawData) throws ConversionException
{
RealRawData realRawData = (RealRawData) rawData;
InboundVariable inboundVariable = realRawData.getInboundVariable();
TypeHintContext typeHintContext = new TypeHintContext(this, null, 0);
return convertInbound(paramType, inboundVariable, typeHintContext);
}