/** * This method is used to extract the annotations associated with * the type. Annotations extracted include the <code>Root</code> * annotation and the <code>Namespace</code> annotation as well as * other annotations that are used to describe the type. * * @param type this is the type to extract the annotations from */ private void extract(Class type) { for(Annotation label : labels) { if(label instanceof Namespace) { namespace(label); } if(label instanceof NamespaceList) { scope(label); } if(label instanceof Root) { root(label); } if(label instanceof Order) { order(label); } if(label instanceof Default) { access(label); } } }
private static String getNamespaceString( Class clazz ) { Namespace namespace = (Namespace) clazz.getAnnotation(Namespace.class); if (namespace == null) { Package pkg = clazz.getPackage(); if (pkg != null) { namespace = pkg.getAnnotation(Namespace.class); if (namespace == null) { // prior to android v4.3 package annotations aren't supported namespace = getAnnotation( pkg, Namespace.class ); } } } String ns = ""; if (namespace != null) ns = namespace.reference(); return ns; }
/** * This is use to scan for <code>Namespace</code> annotations on * the contact. Once a namespace has been located then it is used * to populate the internal namespace decorator. This can then be * used to decorate any output node that requires it. * * @param contact this is the contact to scan for namespaces */ private void namespace(Contact contact) { Namespace primary = contact.getAnnotation(Namespace.class); if(primary != null) { decorator.set(primary); decorator.add(primary); } }
/** * This is use to apply for <code>NamespaceList</code> annotations * on the node. If there is no namespace list then this will return * and the node will be left unchanged. If however the namespace * list is not empty the the namespaces are added. * * @param node this is the node to apply the namespace list to */ private void scope(OutputNode node) { NamespaceMap map = node.getNamespaces(); for(Namespace next : scope) { String reference = next.reference(); String prefix = next.prefix(); map.setReference(reference, prefix); } }
public Class<? extends Annotation> annotationType() { return Namespace.class; }
/** * This is used to set the primary namespace for nodes that will * be decorated by the namespace decorator. If no namespace is set * using this method then this decorator will leave the namespace * reference unchanged and only add namespaces for scoping. * * @param namespace this is the primary namespace to be set */ public void set(Namespace namespace) { if(namespace != null) { add(namespace); } primary = namespace; }
/** * This is used to set the primary namespace for nodes that will * be decorated by the namespace decorator. If no namespace is set * using this method then this decorator will leave the namespace * reference unchanged and only add namespaces for scoping. * * @param detail the detail object that contains the namespace */ private void commit(Detail detail) { Namespace namespace = detail.getNamespace(); if(namespace != null) { decorator.set(namespace); } }
/** * This returns the <code>Namespace</code> annotation that was * declared on the type. If no annotation has been declared on the * type this will return null as not belonging to any. * * @return this returns the namespace this type belongs to, if any */ public Namespace getNamespace() { return detail.getNamespace(); }
/** * This returns the <code>Namespace</code> annotation that was * declared on the type. If no annotation has been declared on the * type this will return null as not belonging to any. * * @return this returns the namespace this type belongs to, if any */ public Namespace getNamespace() { return namespace; }
/** * This returns the <code>Namespace</code> annotation that was * declared on the type. If no annotation has been declared on the * type this will return null as not belonging to any. * * @return this returns the namespace this type belongs to, if any */ Namespace getNamespace();
/** * Constructor for the <code>NamespaceDecorator</code> object. A * namespace decorator can be used for applying namespaces to a * specified node. It can add namespaces to set the scope of the * namespace reference to the node and it can also be used to set * the primary namespace reference used for the node. */ public NamespaceDecorator() { this.scope = new ArrayList<Namespace>(); }
/** * This is used to add a namespace to the decorator so that it can * be added to decorated nodes. Namespaces that are added will be * set on the element so that child elements can reference the * namespace and will thus inherit the prefix from that elment. * * @param namespace this is the namespace to be added for scoping */ public void add(Namespace namespace) { scope.add(namespace); }