当前位置: 首页>>代码示例>>Java>>正文


Java CollectionConverter类代码示例

本文整理汇总了Java中com.thoughtworks.xstream.converters.collections.CollectionConverter的典型用法代码示例。如果您正苦于以下问题:Java CollectionConverter类的具体用法?Java CollectionConverter怎么用?Java CollectionConverter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CollectionConverter类属于com.thoughtworks.xstream.converters.collections包,在下文中一共展示了CollectionConverter类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testObject

import com.thoughtworks.xstream.converters.collections.CollectionConverter; //导入依赖的package包/类
private void testObject(final HierarchicalStreamDriver driver) {
    final XStream xstream = new XStream(driver);
    xstream.allowTypesByWildcard(AbstractAcceptanceTest.class.getPackage().getName() + ".*objects.**");
    xstream.allowTypesByWildcard(this.getClass().getName() + "$*");
    xstream.registerConverter(new CollectionConverter(xstream.getMapper()) {

        @Override
        public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
            final ExtendedHierarchicalStreamReader exReader = (ExtendedHierarchicalStreamReader)reader;
            if (exReader.peekNextChild() == null) {
                return new ArrayList<Object>();
            }
            return super.unmarshal(reader, context);
        }

    });

    final SampleLists in = new SampleLists();
    in.good.add("one");
    in.good.add("two");
    in.good.add("three");
    in.bad.add(Boolean.TRUE);
    in.bad.add(Boolean.FALSE);
    final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    xstream.toXML(in, buffer);
    final Object out = xstream.fromXML(new ByteArrayInputStream(buffer.toByteArray()));

    Assert.assertEquals(in, out);
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:30,代码来源:DriverEndToEndTestSuite.java

示例2: makeXStream

import com.thoughtworks.xstream.converters.collections.CollectionConverter; //导入依赖的package包/类
@Nonnull
public static XStream makeXStream() {
  XStream xstream = new XStream();
  if (ConfigProvider.class.getClassLoader() != null) {
    xstream.setClassLoader(ConfigProvider.class.getClassLoader());
  }

  xstream.registerLocalConverter(Stash.class, "contents", new NamedMapConverter(xstream.getMapper(), "component", "name", String.class, "ppm", Double.class,
      true, true, xstream.getConverterLookup()));
  xstream.addImplicitCollection(Material.class, "components");
  xstream.useAttributeFor(Material.class, "name");
  xstream.useAttributeFor(Material.class, "prio");
  xstream.useAttributeFor(Material.class, "volume");
  xstream.useAttributeFor(Material.class, "density");
  xstream.useAttributeFor(Component.class, "name");
  xstream.useAttributeFor(Component.class, "factor");
  xstream.useAttributeFor(Component.class, "count");
  xstream.useAttributeFor(Component.class, "granularity");
  xstream.useAttributeFor(MinecraftItem.class, "modID");
  xstream.useAttributeFor(MinecraftItem.class, "itemName");
  xstream.useAttributeFor(MinecraftItem.class, "itemMeta");
  xstream.useAttributeFor(OreDictionaryItem.class, "oreDictionary");
  xstream.alias("water", Water.class);
  xstream.alias("material", Material.class);
  xstream.alias("component", Component.class);
  xstream.alias("OreDictionaryItem", OreDictionaryItem.class);
  xstream.alias("MinecraftItem", MinecraftItem.class);

  ClassAliasingMapper mapper = new ClassAliasingMapper(xstream.getMapper());
  mapper.addClassAlias("amount", Double.class);
  xstream.registerLocalConverter(Component.class, "granularities", new CollectionConverter(mapper));
  return xstream;
}
 
开发者ID:HenryLoenwind,项目名称:EnderIOAddons,代码行数:34,代码来源:ConfigProvider.java

示例3: PortfolioRepositoryHandler

import com.thoughtworks.xstream.converters.collections.CollectionConverter; //导入依赖的package包/类
/**
* 
*/
  protected PortfolioRepositoryHandler() {
      supportedTypes = new ArrayList<String>(1);
      supportedTypes.add(EPTemplateMapResource.TYPE_NAME);

      myStream.alias("defaultMap", EPDefaultMap.class);
      myStream.alias("structureMap", EPStructuredMap.class);
      myStream.alias("templateMap", EPStructuredMapTemplate.class);
      myStream.alias("structure", EPStructureElement.class);
      myStream.alias("page", EPPage.class);
      myStream.alias("structureToArtefact", EPStructureToArtefactLink.class);
      myStream.alias("structureToStructure", EPStructureToStructureLink.class);
      myStream.alias("collectionRestriction", CollectRestriction.class);

      myStream.alias("org.olat.resource.OLATResourceImpl", OLATResourceImpl.class);
      myStream.alias("OLATResource", OLATResourceImpl.class);

      myStream.alias("org.olat.basesecurity.SecurityGroupImpl", SecurityGroupImpl.class);
      myStream.alias("SecurityGroupImpl", SecurityGroupImpl.class);

      myStream.alias("org.olat.basesecurity.SecurityGroup", SecurityGroup.class);
      myStream.alias("SecurityGroup", SecurityGroup.class);

      myStream.alias("org.olat.core.id.Persistable", Persistable.class);
      myStream.alias("Persistable", Persistable.class);

      myStream.alias("org.hibernate.proxy.HibernateProxy", HibernateProxy.class);
      myStream.alias("HibernateProxy", HibernateProxy.class);

      myStream.omitField(EPStructuredMapTemplate.class, "ownerGroup");
      myStream.addDefaultImplementation(PersistentList.class, List.class);
      myStream.addDefaultImplementation(ArrayList.class, List.class);
      myStream.registerConverter(new CollectionConverter(myStream.getMapper()) {
          @Override
          public boolean canConvert(final Class type) {
              return PersistentList.class == type;
          }
      });
  }
 
开发者ID:huihoo,项目名称:olat,代码行数:42,代码来源:PortfolioRepositoryHandler.java

示例4: setupConverters

import com.thoughtworks.xstream.converters.collections.CollectionConverter; //导入依赖的package包/类
protected void setupConverters() {
    registerConverter(new ReflectionConverter(mapper, reflectionProvider), PRIORITY_VERY_LOW);

    registerConverter(new SerializableConverter(mapper, reflectionProvider, classLoaderReference), PRIORITY_LOW);
    registerConverter(new ExternalizableConverter(mapper, classLoaderReference), PRIORITY_LOW);

    registerConverter(new NullConverter(), PRIORITY_VERY_HIGH);
    registerConverter(new IntConverter(), PRIORITY_NORMAL);
    registerConverter(new FloatConverter(), PRIORITY_NORMAL);
    registerConverter(new DoubleConverter(), PRIORITY_NORMAL);
    registerConverter(new LongConverter(), PRIORITY_NORMAL);
    registerConverter(new ShortConverter(), PRIORITY_NORMAL);
    registerConverter((Converter)new CharConverter(), PRIORITY_NORMAL);
    registerConverter(new BooleanConverter(), PRIORITY_NORMAL);
    registerConverter(new ByteConverter(), PRIORITY_NORMAL);

    registerConverter(new StringConverter(), PRIORITY_NORMAL);
    registerConverter(new StringBufferConverter(), PRIORITY_NORMAL);
    registerConverter(new StringBuilderConverter(), PRIORITY_NORMAL);
    registerConverter(new ThrowableConverter(converterLookup), PRIORITY_NORMAL);
    registerConverter(new StackTraceElementConverter(), PRIORITY_NORMAL);
    registerConverter(new DateConverter(), PRIORITY_NORMAL);
    registerConverter(new GregorianCalendarConverter(), PRIORITY_NORMAL);
    registerConverter(new RegexPatternConverter(), PRIORITY_NORMAL);
    registerConverter(new CurrencyConverter(), PRIORITY_NORMAL);
    registerConverter(new CharsetConverter(), PRIORITY_NORMAL);
    registerConverter(new LocaleConverter(), PRIORITY_NORMAL);
    registerConverter(new BitSetConverter(), PRIORITY_NORMAL);
    registerConverter(new UUIDConverter(), PRIORITY_NORMAL);
    registerConverter(new URIConverter(), PRIORITY_NORMAL);
    registerConverter(new URLConverter(), PRIORITY_NORMAL);
    registerConverter(new BigIntegerConverter(), PRIORITY_NORMAL);
    registerConverter(new BigDecimalConverter(), PRIORITY_NORMAL);

    registerConverter(new ArrayConverter(mapper), PRIORITY_NORMAL);
    registerConverter(new CharArrayConverter(), PRIORITY_NORMAL);
    registerConverter(new CollectionConverter(mapper), PRIORITY_NORMAL);
    registerConverter(new MapConverter(mapper), PRIORITY_NORMAL);
    registerConverter(new TreeMapConverter(mapper), PRIORITY_NORMAL);
    registerConverter(new TreeSetConverter(mapper), PRIORITY_NORMAL);
    registerConverter(new SingletonCollectionConverter(mapper), PRIORITY_NORMAL);
    registerConverter(new SingletonMapConverter(mapper), PRIORITY_NORMAL);
    registerConverter(new PropertiesConverter(), PRIORITY_NORMAL);
    registerConverter((Converter)new EncodedByteArrayConverter(), PRIORITY_NORMAL);
    registerConverter(new EnumConverter(), PRIORITY_NORMAL);
    registerConverter(new EnumSetConverter(mapper), PRIORITY_NORMAL);
    registerConverter(new EnumMapConverter(mapper), PRIORITY_NORMAL);

    registerConverter(new FileConverter(), PRIORITY_NORMAL);
    if (JVM.isSQLAvailable()) {
        registerConverter(new SqlTimestampConverter(), PRIORITY_NORMAL);
        registerConverter(new SqlTimeConverter(), PRIORITY_NORMAL);
        registerConverter(new SqlDateConverter(), PRIORITY_NORMAL);
    }
    registerConverter(new DynamicProxyConverter(mapper, classLoaderReference), PRIORITY_NORMAL);
    registerConverter(new JavaClassConverter(classLoaderReference), PRIORITY_NORMAL);
    registerConverter(new JavaMethodConverter(classLoaderReference), PRIORITY_NORMAL);
    registerConverter(new JavaFieldConverter(classLoaderReference), PRIORITY_NORMAL);
    if (JVM.isAWTAvailable()) {
        registerConverter(new FontConverter(mapper), PRIORITY_NORMAL);
        registerConverter(new ColorConverter(), PRIORITY_NORMAL);
        registerConverter(new TextAttributeConverter(), PRIORITY_NORMAL);
    }
    if (JVM.isSwingAvailable()) {
        registerConverter(new LookAndFeelConverter(mapper, reflectionProvider), PRIORITY_NORMAL);
    }

    if (JVM.loadClassForName("javax.security.auth.Subject") != null) {
        registerConverterDynamically("com.thoughtworks.xstream.converters.extended.SubjectConverter",
            PRIORITY_NORMAL, new Class[]{Mapper.class}, new Object[]{mapper});
    }
    if (JVM.loadClassForName("javax.xml.datatype.Duration") != null) {
        registerConverterDynamically("com.thoughtworks.xstream.converters.extended.DurationConverter",
            PRIORITY_NORMAL, null, null);
    }

    registerConverter(new SelfStreamingInstanceChecker(converterLookup, this), PRIORITY_NORMAL);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:79,代码来源:XStream.java

示例5: registerStringAlias

import com.thoughtworks.xstream.converters.collections.CollectionConverter; //导入依赖的package包/类
private static void registerStringAlias(XStream xstream, Class clazz, String tag) {
    ClassAliasingMapper mapper = new ClassAliasingMapper(xstream.getMapper());
    mapper.addClassAlias(tag, String.class);
    xstream.registerLocalConverter(clazz, tag + "s", new CollectionConverter(mapper));
}
 
开发者ID:fabric8io,项目名称:fabric8-build,代码行数:6,代码来源:AssemblyPrinter.java


注:本文中的com.thoughtworks.xstream.converters.collections.CollectionConverter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。