/** * Adds a default implicit collection which is used for any unmapped XML tag. * * @param ownerType class owning the implicit collection * @param fieldName name of the field in the ownerType. This field must be a concrete * collection type or matching the default implementation type of the collection * type. */ public void addImplicitCollection(Class ownerType, String fieldName) { addImplicitCollection(ownerType, fieldName, null, null); }
/** * Adds an implicit array. * * @param ownerType class owning the implicit array * @param fieldName name of the array field * @since 1.4 */ public void addImplicitArray(Class ownerType, String fieldName) { addImplicitCollection(ownerType, fieldName); }
/** * Adds an implicit array which is used for all items of the given element name defined by * itemName. * * @param ownerType class owning the implicit array * @param fieldName name of the array field in the ownerType * @param itemName alias name of the items * @throws InitializationException if no {@link ImplicitCollectionMapper} is available * @since 1.4 */ public void addImplicitArray(Class ownerType, String fieldName, String itemName) { addImplicitCollection(ownerType, fieldName, itemName, null); }
/** * Adds implicit collection which is used for all items of the given itemType. * * @param ownerType class owning the implicit collection * @param fieldName name of the field in the ownerType. This field must be a concrete * collection type or matching the default implementation type of the collection * type. * @param itemType type of the items to be part of this collection * @throws InitializationException if no {@link ImplicitCollectionMapper} is available */ public void addImplicitCollection(Class ownerType, String fieldName, Class itemType) { addImplicitCollection(ownerType, fieldName, null, itemType); }
/** * Adds an implicit array which is used for all items of the given itemType when the array * type matches. * * @param ownerType class owning the implicit array * @param fieldName name of the array field in the ownerType * @param itemType type of the items to be part of this array * @throws InitializationException if no {@link ImplicitCollectionMapper} is available or the * array type does not match the itemType * @since 1.4 */ public void addImplicitArray(Class ownerType, String fieldName, Class itemType) { addImplicitCollection(ownerType, fieldName, itemType); }
String[] collectionFields = StringUtils.commaDelimitedListToStringArray(fields); for (String collectionField : collectionFields) { xstream.addImplicitCollection(key, collectionField);
XStream xstream = new XStream(); xstream.alias("person", Person.class); xstream.alias("persons", PersonList.class); xstream.addImplicitCollection(PersonList.class, "list"); PersonList list = new PersonList(); list.add(new Person("ABC",12,"address")); list.add(new Person("XYZ",20,"address2")); String xml = xstream.toXML(list);
XStream xstream = new XStream(); xstream.alias("comments", Comments.class); xstream.alias("comment", Comment.class); xstream.addImplicitCollection(Comments.class, "comments"); Comments comments = (Comments)xstream.fromXML(xml);
/** * Adds an implicit array. * * @param ownerType class owning the implicit array * @param fieldName name of the array field * @since 1.4 */ public void addImplicitArray(final Class<?> ownerType, final String fieldName) { addImplicitCollection(ownerType, fieldName); }
/** * Adds a default implicit collection which is used for any unmapped XML tag. * * @param ownerType class owning the implicit collection * @param fieldName name of the field in the ownerType. This field must be a concrete collection type or matching * the default implementation type of the collection type. */ public void addImplicitCollection(final Class<?> ownerType, final String fieldName) { addImplicitCollection(ownerType, fieldName, null, null); }
/** * Adds implicit collection which is used for all items of the given itemType. * * @param ownerType class owning the implicit collection * @param fieldName name of the field in the ownerType. This field must be a concrete collection type or matching * the default implementation type of the collection type. * @param itemType type of the items to be part of this collection * @throws InitializationException if no {@link ImplicitCollectionMapper} is available */ public void addImplicitCollection(final Class<?> ownerType, final String fieldName, final Class<?> itemType) { addImplicitCollection(ownerType, fieldName, null, itemType); }
/** * Adds an implicit array which is used for all items of the given element name defined by itemName. * * @param ownerType class owning the implicit array * @param fieldName name of the array field in the ownerType * @param itemName alias name of the items * @throws InitializationException if no {@link ImplicitCollectionMapper} is available * @since 1.4 */ public void addImplicitArray(final Class<?> ownerType, final String fieldName, final String itemName) { addImplicitCollection(ownerType, fieldName, itemName, null); }
/** * Adds a default implicit collection which is used for any unmapped XML tag. * * @param ownerType class owning the implicit collection * @param fieldName name of the field in the ownerType. This field must be a concrete * collection type or matching the default implementation type of the collection * type. */ public void addImplicitCollection(Class ownerType, String fieldName) { addImplicitCollection(ownerType, fieldName, null, null); }
/** * Adds a default implicit collection which is used for any unmapped XML tag. * * @param ownerType class owning the implicit collection * @param fieldName name of the field in the ownerType. This field must be a concrete * collection type or matching the default implementation type of the collection * type. */ public void addImplicitCollection(Class ownerType, String fieldName) { addImplicitCollection(ownerType, fieldName, null, null); }
/** * Adds an implicit array. * * @param ownerType class owning the implicit array * @param fieldName name of the array field * @since 1.4 */ public void addImplicitArray(Class ownerType, String fieldName) { addImplicitCollection(ownerType, fieldName); }
/** * Creates a new persister */ public XStreamPersister() { this.xStream = new XStream(); xStream.alias( "configurations", Configurations.class ); xStream.addImplicitCollection( Configurations.class, "configurations" ); }
/** * 设置Xstream别名 * */ public static void setAlias(XStream xstream) { for (Map.Entry< String, Class< ? > > et : ALIAS_MAPPING.entrySet()) { xstream.alias(et.getKey(), et.getValue()); } xstream.addImplicitCollection(Schema.class, "cols", "attribute", Column.class); }
/** * Adds an implicit Collection for the given type. * * @see XStream#addImplicitCollection(Class, String) */ public void addImplicitCollection(String name, Class type) { getXStream().addImplicitCollection(type, name); }
XStream xstream = new XStream(); xstream.alias("employee", Employee.class); xstream.alias("employees", EmployeeList.class); xstream.addImplicitCollection(EmployeeList.class, "list"); EmployeeList list = new EmployeeList(); list.add(new Employee(1,"Vimal Jaiswal",50000)); list.add(new Employee(2,"Kamal",40000)); String xml = xstream.toXML(list);
private static XStream configureXStream() { XStream xStream = new XStream(new DomDriver()); xStream.alias("Sections", TestData.class); xStream.omitField(TestData.class, "loadedSections"); xStream.addImplicitCollection(TestData.class, "sectionsLoadedFromFile", "Section", Section.class); xStream = Section.configurePageLayoutXStream(xStream); return xStream; } }