📄 converter.java
字号:
/* * Copyright 2005 Joe Walker * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.directwebremoting.extend;/** * An interface for converting types from a string to some other type. * @author Joe Walker [joe at getahead dot ltd dot uk] */public interface Converter{ /** * If we are a compound converter that farms out part of the conversion * to other converters then you farm the conversion out via a configuration. * @param config The confiuration object */ void setConverterManager(ConverterManager config); /** * Attempt to coerce the data from a string to an Object. * If anything goes wrong with inbound conversion then we generally throw * an exception because we are converting data from the untrusted internet * so we take the assumption that anything wrong is someone hacking. * @param paramType The type to convert to * @param data The data to convert * @param inctx The map of data that we are working on * @return The convered data, or null if the conversion was not possible * @throws MarshallException If the conversion failed for some reason */ Object convertInbound(Class paramType, InboundVariable data, InboundContext inctx) throws MarshallException; /** * Return a javascript string that defines the variable named varName to * have the contents of the converted object data. * <p>In contrast to <code>convertInbound()</code> failures in converting * data on the way out should not stop processing, and we should carry on * if we can. Failures are probably down to some misconfiguration so as much * information about the error as can be safely generated to console logs is * good. In other words if you need to loop in outbound conversion then it * might be a good idea to catch issues inside the loop, log, and carry on. * @param data The data to convert * @param outctx A collection of objects already converted and the results * @return The OutboundVariable that represents the data to convert * @throws MarshallException If the conversion failed for some reason */ OutboundVariable convertOutbound(Object data, OutboundContext outctx) throws MarshallException;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -