/** * Constructor for the <code>MethodPartFactory</code> object. This * is used to create method parts based on the method signature * and the XML annotation is uses. The created part can be used to * either set or get values depending on its type. * * @param detail this contains details for the annotated class * @param support this contains various support functions */ public MethodPartFactory(Detail detail, Support support) { this.factory = new AnnotationFactory(detail, support); }
/** * This is used to create an annotation for the provided type. * Annotations created are used to match the type provided. So * a <code>List</code> will have an <code>ElementList</code> * annotation for example. Matching the annotation to the * type ensures the best serialization for that type. * * @param type the type to create the annotation for * @param dependents these are the dependents for the type * * @return this returns the synthetic annotation to be used */ public Annotation getInstance(Class type, Class[] dependents) throws Exception { ClassLoader loader = getClassLoader(); if(Map.class.isAssignableFrom(type)) { if(isPrimitiveKey(dependents) && isAttribute()) { return getInstance(loader, ElementMap.class, true); } return getInstance(loader, ElementMap.class); } if(Collection.class.isAssignableFrom(type)) { return getInstance(loader, ElementList.class); } return getInstance(type); }
/** * This is used to create an annotation for the provided type. * Annotations created are used to match the type provided. So * an array of objects will have an <code>ElementArray</code> * annotation for example. Matching the annotation to the * type ensures the best serialization for that type. * * @param type the type to create the annotation for * * @return this returns the synthetic annotation to be used */ private Annotation getInstance(Class type) throws Exception { ClassLoader loader = getClassLoader(); Class entry = type.getComponentType(); if(type.isArray()) { if(isPrimitive(entry)) { return getInstance(loader, Element.class); } return getInstance(loader, ElementArray.class); } if(isPrimitive(type) && isAttribute()) { return getInstance(loader, Attribute.class); } return getInstance(loader, Element.class); }
/** * This will create a synthetic annotation using the provided * interface. All attributes for the provided annotation will * have their default values. * * @param loader this is the class loader to load the annotation * @param label this is the annotation interface to be used * * @return this returns the synthetic annotation to be used */ private Annotation getInstance(ClassLoader loader, Class label) throws Exception { return getInstance(loader, label, false); }
/** * This is used to determine if a map contains a primitive key. * A primitive key is a key for a <code>Map</code> that is of * a primitive type and thus can be used as an attribute. Here * we accept all primitive types and also enumerations. * * @param dependents these are the dependents of the map * * @return this returns true if the key is a primitive type */ private boolean isPrimitiveKey(Class[] dependents) { if(dependents != null && dependents.length > 0) { Class parent = dependents[0].getSuperclass(); Class type = dependents[0]; if(parent != null) { if(parent.isEnum()) { return true; } if(type.isEnum()) { return true; } } return isPrimitive(type); } return false; }
/** * This will create a synthetic annotation using the provided * interface. All attributes for the provided annotation will * have their default values. * * @param loader this is the class loader to load the annotation * @param label this is the annotation interface to be used * * @return this returns the synthetic annotation to be used */ private Annotation getInstance(ClassLoader loader, Class label) throws Exception { return getInstance(loader, label, false); }
/** * This is used to determine if a map contains a primitive key. * A primitive key is a key for a <code>Map</code> that is of * a primitive type and thus can be used as an attribute. Here * we accept all primitive types and also enumerations. * * @param dependents these are the dependents of the map * * @return this returns true if the key is a primitive type */ private boolean isPrimitiveKey(Class[] dependents) { if(dependents != null && dependents.length > 0) { Class parent = dependents[0].getSuperclass(); Class type = dependents[0]; if(parent != null) { if(parent.isEnum()) { return true; } if(type.isEnum()) { return true; } } return isPrimitive(type); } return false; }
/** * This is used to create an annotation for the provided type. * Annotations created are used to match the type provided. So * a <code>List</code> will have an <code>ElementList</code> * annotation for example. Matching the annotation to the * type ensures the best serialization for that type. * * @param type the type to create the annotation for * @param dependents these are the dependents for the type * * @return this returns the synthetic annotation to be used */ public Annotation getInstance(Class type, Class[] dependents) throws Exception { ClassLoader loader = getClassLoader(); if(Map.class.isAssignableFrom(type)) { if(isPrimitiveKey(dependents) && isAttribute()) { return getInstance(loader, ElementMap.class, true); } return getInstance(loader, ElementMap.class); } if(Collection.class.isAssignableFrom(type)) { return getInstance(loader, ElementList.class); } return getInstance(type); }
/** * This is used to create an annotation for the provided type. * Annotations created are used to match the type provided. So * an array of objects will have an <code>ElementArray</code> * annotation for example. Matching the annotation to the * type ensures the best serialization for that type. * * @param type the type to create the annotation for * * @return this returns the synthetic annotation to be used */ private Annotation getInstance(Class type) throws Exception { ClassLoader loader = getClassLoader(); Class entry = type.getComponentType(); if(type.isArray()) { if(isPrimitive(entry)) { return getInstance(loader, Element.class); } return getInstance(loader, ElementArray.class); } if(isPrimitive(type) && isAttribute()) { return getInstance(loader, Attribute.class); } return getInstance(loader, Element.class); }
/** * This will create a synthetic annotation using the provided * interface. All attributes for the provided annotation will * have their default values. * * @param loader this is the class loader to load the annotation * @param label this is the annotation interface to be used * * @return this returns the synthetic annotation to be used */ private Annotation getInstance(ClassLoader loader, Class label) throws Exception { return getInstance(loader, label, false); }
/** * Constructor for the <code>MethodPartFactory</code> object. This * is used to create method parts based on the method signature * and the XML annotation is uses. The created part can be used to * either set or get values depending on its type. * * @param detail this contains details for the annotated class * @param support this contains various support functions */ public MethodPartFactory(Detail detail, Support support) { this.factory = new AnnotationFactory(detail, support); }
/** * This is used to determine if a map contains a primitive key. * A primitive key is a key for a <code>Map</code> that is of * a primitive type and thus can be used as an attribute. Here * we accept all primitive types and also enumerations. * * @param dependents these are the dependents of the map * * @return this returns true if the key is a primitive type */ private boolean isPrimitiveKey(Class[] dependents) { if(dependents != null && dependents.length > 0) { Class parent = dependents[0].getSuperclass(); Class type = dependents[0]; if(parent != null) { if(parent.isEnum()) { return true; } if(type.isEnum()) { return true; } } return isPrimitive(type); } return false; }
/** * This is used to create an annotation for the provided type. * Annotations created are used to match the type provided. So * a <code>List</code> will have an <code>ElementList</code> * annotation for example. Matching the annotation to the * type ensures the best serialization for that type. * * @param type the type to create the annotation for * @param dependents these are the dependents for the type * * @return this returns the synthetic annotation to be used */ public Annotation getInstance(Class type, Class[] dependents) throws Exception { ClassLoader loader = getClassLoader(); if(Map.class.isAssignableFrom(type)) { if(isPrimitiveKey(dependents) && isAttribute()) { return getInstance(loader, ElementMap.class, true); } return getInstance(loader, ElementMap.class); } if(Collection.class.isAssignableFrom(type)) { return getInstance(loader, ElementList.class); } return getInstance(type); }
/** * This is used to create an annotation for the provided type. * Annotations created are used to match the type provided. So * an array of objects will have an <code>ElementArray</code> * annotation for example. Matching the annotation to the * type ensures the best serialization for that type. * * @param type the type to create the annotation for * * @return this returns the synthetic annotation to be used */ private Annotation getInstance(Class type) throws Exception { ClassLoader loader = getClassLoader(); Class entry = type.getComponentType(); if(type.isArray()) { if(isPrimitive(entry)) { return getInstance(loader, Element.class); } return getInstance(loader, ElementArray.class); } if(isPrimitive(type) && isAttribute()) { return getInstance(loader, Attribute.class); } return getInstance(loader, Element.class); }
/** * This method is used to process the field an annotation given. * This will check to determine if the field is accessible, if it * is not accessible then it is made accessible so that private * member fields can be used during the serialization process. * * @param field this is the field to be added as a contact * @param type this is the type to acquire the annotation * @param list this is the list of annotations on the field */ private void process(Field field, Class type, Annotation[] list) throws Exception { Class[] dependents = Reflector.getDependents(field); Annotation label = factory.getInstance(type, dependents); if(label != null) { process(field, label, list); } }
/** * Constructor for the <code>MethodPartFactory</code> object. This * is used to create method parts based on the method signature * and the XML annotation is uses. The created part can be used to * either set or get values depending on its type. * * @param detail this contains details for the annotated class * @param support this contains various support functions */ public MethodPartFactory(Detail detail, Support support) { this.factory = new AnnotationFactory(detail, support); }
/** * This method is used to process the field an annotation given. * This will check to determine if the field is accessible, if it * is not accessible then it is made accessible so that private * member fields can be used during the serialization process. * * @param field this is the field to be added as a contact * @param type this is the type to acquire the annotation * @param list this is the list of annotations on the field */ private void process(Field field, Class type, Annotation[] list) throws Exception { Class[] dependents = Reflector.getDependents(field); Annotation label = factory.getInstance(type, dependents); if(label != null) { process(field, label, list); } }
/** * Constructor for the <code>FieldScanner</code> object. This is * used to perform a scan on the specified class in order to find * all fields that are labeled with an XML annotation. * * @param detail this contains the details for the class scanned * @param support this contains various support functions */ public FieldScanner(Detail detail, Support support) throws Exception { this.factory = new AnnotationFactory(detail, support); this.done = new ContactMap(); this.support = support; this.scan(detail); }
/** * This method is used to process the field an annotation given. * This will check to determine if the field is accessible, if it * is not accessible then it is made accessible so that private * member fields can be used during the serialization process. * * @param field this is the field to be added as a contact * @param type this is the type to acquire the annotation * @param list this is the list of annotations on the field */ private void process(Field field, Class type, Annotation[] list) throws Exception { Class[] dependents = Reflector.getDependents(field); Annotation label = factory.getInstance(type, dependents); if(label != null) { process(field, label, list); } }
/** * Constructor for the <code>FieldScanner</code> object. This is * used to perform a scan on the specified class in order to find * all fields that are labeled with an XML annotation. * * @param detail this contains the details for the class scanned * @param support this contains various support functions */ public FieldScanner(Detail detail, Support support) throws Exception { this.factory = new AnnotationFactory(detail, support); this.done = new ContactMap(); this.support = support; this.scan(detail); }