The ArrayFactory is used to create object array types that are compatible with the field type. This simply requires the type of the array in order to instantiate that array. However, this also performs a check on the field type to ensure that the array component types are compatible.
Inheritance: Factory
Exemplo n.º 1
0
 /// <summary>
 /// Constructor for the <c>CompositeArray</c> object. This is
 /// given the array type for the contact that is to be converted. An
 /// array of the specified type is used to hold the deserialized
 /// elements and will be the same length as the number of elements.
 /// </summary>
 /// <param name="context">
 /// this is the context object used for serialization
 /// </param>
 /// <param name="type">
 /// this is the field type for the array being used
 /// </param>
 /// <param name="entry">
 /// this is the entry type for the array elements
 /// </param>
 /// <param name="parent">
 /// this is the name to wrap the array element with
 /// </param>
 public CompositeArray(Context context, Type type, Type entry, String parent)
 {
     this.factory = new ArrayFactory(context, type);
     this.root    = new Traverser(context);
     this.parent  = parent;
     this.entry   = entry;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor for the <c>PrimitiveArray</c> object. This is
 /// given the array type for the contact that is to be converted. An
 /// array of the specified type is used to hold the deserialized
 /// elements and will be the same length as the number of elements.
 /// </summary>
 /// <param name="context">
 /// this is the context object used for serialization
 /// </param>
 /// <param name="type">
 /// this is the actual field type from the schema
 /// </param>
 /// <param name="entry">
 /// the entry type to be stored within the array
 /// </param>
 /// <param name="parent">
 /// this is the name to wrap the array element with
 /// </param>
 public PrimitiveArray(Context context, Type type, Type entry, String parent)
 {
     this.factory = new ArrayFactory(context, type);
     this.root    = new Primitive(context, entry);
     this.parent  = parent;
     this.entry   = entry;
 }
Exemplo n.º 3
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    array   = new ClassType(type);
            Factory factory = new ArrayFactory(context, array);

            if (!label.empty())
            {
                return(factory.getInstance());
            }
            return(null);
        }
Exemplo n.º 4
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 array = new ClassType(type);
    Factory factory = new ArrayFactory(context, array);
    if(!label.empty()) {
       return factory.getInstance();
    }
    return null;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Constructor for the <c>CompositeArray</c> object. This is
 /// given the array type for the contact that is to be converted. An
 /// array of the specified type is used to hold the deserialized
 /// elements and will be the same length as the number of elements.
 /// </summary>
 /// <param name="context">
 /// this is the context object used for serialization
 /// </param>
 /// <param name="type">
 /// this is the field type for the array being used
 /// </param>
 /// <param name="entry">
 /// this is the entry type for the array elements
 /// </param>
 /// <param name="parent">
 /// this is the name to wrap the array element with
 /// </param>
 public CompositeArray(Context context, Type type, Type entry, String parent) {
    this.factory = new ArrayFactory(context, type);
    this.root = new Traverser(context);
    this.parent = parent;
    this.entry = entry;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Constructor for the <c>PrimitiveArray</c> object. This is
 /// given the array type for the contact that is to be converted. An
 /// array of the specified type is used to hold the deserialized
 /// elements and will be the same length as the number of elements.
 /// </summary>
 /// <param name="context">
 /// this is the context object used for serialization
 /// </param>
 /// <param name="type">
 /// this is the actual field type from the schema
 /// </param>
 /// <param name="entry">
 /// the entry type to be stored within the array
 /// </param>
 /// <param name="parent">
 /// this is the name to wrap the array element with
 /// </param>
 public PrimitiveArray(Context context, Type type, Type entry, String parent) {
    this.factory = new ArrayFactory(context, type);
    this.root = new Primitive(context, entry);
    this.parent = parent;
    this.entry = entry;
 }