本文整理了Java中org.nuxeo.common.xmap.XMap.setValueFactory()
方法的一些代码示例,展示了XMap.setValueFactory()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMap.setValueFactory()
方法的具体详情如下:
包路径:org.nuxeo.common.xmap.XMap
类名称:XMap
方法名:setValueFactory
[英]Sets a custom value factory for the given class.
Value factories are used to decode values from XML strings.
[中]为给定类设置自定义值工厂。
值工厂用于解码XML字符串中的值。
代码示例来源:origin: org.nuxeo.runtime/nuxeo-connect-standalone
public static XMap createXmap() {
@SuppressWarnings("hiding")
XMap xmap = new XMap();
xmap.setValueFactory(PackageType.class, new XValueFactory() {
@Override
public String serialize(Context arg0, Object arg1) {
xmap.setValueFactory(Version.class, new XValueFactory() {
@Override
public String serialize(Context arg0, Object arg1) {
xmap.setValueFactory(PackageDependency.class, new XValueFactory() {
代码示例来源:origin: org.nuxeo.common/nuxeo-common
public XAnnotatedMember(XMap xmap, XAccessor setter, XNode anno) {
this.xmap = xmap;
accessor = setter;
path = new Path(anno.value());
trim = anno.trim();
type = setter.getType();
valueFactory = xmap.getValueFactory(type);
if (valueFactory == null && type.isEnum()) {
valueFactory = new XValueFactory() {
@Override
public String serialize(Context arg0, Object arg1) {
return ((Enum<?>) arg1).name();
}
@SuppressWarnings("unchecked")
@Override
public Object deserialize(Context arg0, String arg1) {
return Enum.valueOf(type, arg1);
}
};
xmap.setValueFactory(type, valueFactory);
}
xao = xmap.register(type);
}
内容来源于网络,如有侵权,请联系作者删除!