The CollectionFactory is used to create collection instances that are compatible with the field type. This performs resolution of the collection class by firstly consulting the specified Strategy implementation. If the strategy cannot resolve the collection class then this will select a type from the Java Collections framework, if a compatible one exists.
Inheritance: Factory
Exemplo n.º 1
0
 /// <summary>
 /// This is used to provide a configured empty value used when the
 /// annotated value is null. This ensures that XML can be created
 /// with required details regardless of whether values are null or
 /// not. It also provides a means for sensible default values.
 /// </summary>
 /// <param name="context">
 /// this is the context object for the serialization
 /// </param>
 /// <returns>
 /// this returns the string to use for default values
 /// </returns>
 public Object GetEmpty(Context context) {
    Type list = new ClassType(type);
    Factory factory = new CollectionFactory(context, list);
    if(!label.empty()) {
       return factory.getInstance();
    }
    return null;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor for the <c>PrimitiveList</c> object. This is
 /// given the list type and entry type to be used. The list type is
 /// the <c>Collection</c> implementation that deserialized
 /// entry objects are inserted into.
 /// </summary>
 /// <param name="context">
 /// this is the context object used for serialization
 /// </param>
 /// <param name="type">
 /// this is the collection type for the list used
 /// </param>
 /// <param name="entry">
 /// the primitive type to be stored within the list
 /// </param>
 /// <param name="parent">
 /// this is the name to wrap the list element with
 /// </param>
 public PrimitiveList(Context context, Type type, Type entry, String parent) {
    this.factory = new CollectionFactory(context, type);
    this.root = new Primitive(context, entry);
    this.parent = parent;
    this.entry = entry;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Constructor for the <c>CompositeInlineList</c> object.
 /// This is given the list type and entry type to be used. The list
 /// type is the <c>Collection</c> implementation that is used
 /// to collect the deserialized entry objects from the XML source.
 /// </summary>
 /// <param name="context">
 /// this is the context object used for serialization
 /// </param>
 /// <param name="type">
 /// this is the collection type for the list used
 /// </param>
 /// <param name="entry">
 /// the entry type to be stored within the list
 /// </param>
 /// <param name="name">
 /// this is the name of the entries used for this list
 /// </param>
 public CompositeInlineList(Context context, Type type, Type entry, String name) {
    this.factory = new CollectionFactory(context, type);
    this.root = new Traverser(context);
    this.entry = entry;
    this.name = name;
 }