use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class AbstractBindVisitor method createRequiresElement.
protected Element createRequiresElement() {
Element requires;
requires = new Element("requires", "");
if (m_specification != null) {
requires.addAttribute(new Attribute("specification", m_specification));
}
if (m_aggregate != null) {
requires.addAttribute(new Attribute("aggregate", m_aggregate));
}
if (m_filter != null) {
requires.addAttribute(new Attribute("filter", m_filter));
}
if (m_optional != null) {
requires.addAttribute(new Attribute("optional", m_optional));
}
if (m_policy != null) {
requires.addAttribute(new Attribute("policy", m_policy));
}
if (m_id != null) {
requires.addAttribute(new Attribute("id", m_id));
}
if (m_comparator != null) {
requires.addAttribute(new Attribute("comparator", m_comparator));
}
if (m_from != null) {
requires.addAttribute(new Attribute("from", m_from));
}
if (m_proxy != null) {
requires.addAttribute(new Attribute("proxy", m_proxy));
}
return requires;
}
use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class ParameterBindVisitor method visitEnd.
/**
* End of the visit.
* Create or append the requirement info to a created or already existing "requires" element.
*
* @see org.objectweb.asm.commons.EmptyVisitor#visitEnd()
*/
public void visitEnd() {
if (m_id == null) {
m_id = Integer.toString(m_index);
}
Element requires = getRequiresElement();
// Specific for parameters
requires.addAttribute(new Attribute("constructor-parameter", Integer.toString(m_index)));
workbench.getIds().put(m_id, requires);
workbench.getElements().put(requires, null);
}
use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class ParameterGenericVisitor method visitEnd.
@Override
public void visitEnd() {
super.visitEnd();
String type = Type.getArgumentTypes(node.desc)[index].getClassName();
// TODO Is the 'index' attribute required ?
element.addAttribute(new Attribute("index", Integer.toString(index)));
element.addAttribute(new Attribute("type", type));
element.addAttribute(new Attribute("constructor-parameter", Integer.toString(index)));
}
use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class XMLMetadataParser method startElement.
/**
* Start an element.
* @param namespaceURI : element namespace.
* @param localName : local element.
* @param qName : qualified name.
* @param atts : attribute
* @throws SAXException : occurs if the element cannot be parsed correctly.
* @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
*/
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
String namespace = namespaceURI;
if (namespaceURI != null && (namespaceURI.equalsIgnoreCase("org.apache.felix.ipojo") || namespaceURI.equalsIgnoreCase("org.apache.felix.ipojo.composite"))) {
// Remove the 'org.apache.felix.ipojo' namespace
namespace = null;
}
Element elem = new Element(localName, namespace);
for (int i = 0; i < atts.getLength(); i++) {
String name = (String) atts.getLocalName(i);
String ns = (String) atts.getURI(i);
String value = (String) atts.getValue(i);
Attribute att = new Attribute(name, ns, value);
elem.addAttribute(att);
}
addElement(elem);
}
use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class MethodDescriptor method getElement.
/**
* Compute method manipulation metadata.
* @return the element containing metadata about this method.
*/
public Element getElement() {
Element method = new Element("method", "");
method.addAttribute(new Attribute("name", m_name));
// Add return
if (!m_returnType.equals("void")) {
method.addAttribute(new Attribute("return", m_returnType));
}
// Add arguments
if (m_arguments.length > 0) {
StringBuilder args = new StringBuilder("{");
StringBuilder names = new StringBuilder("{");
args.append(m_arguments[0]);
if (m_locals.containsKey(1)) {
// index +1 as the 0 is this
names.append(m_locals.get(1).name);
}
for (int i = 1; i < m_arguments.length; i++) {
args.append(",").append(m_arguments[i]);
if (m_locals.containsKey(i + 1)) {
names.append(",").append(m_locals.get(i + 1).name);
}
}
args.append("}");
names.append("}");
method.addAttribute(new Attribute("arguments", args.toString()));
method.addAttribute(new Attribute("names", names.toString()));
}
return method;
}
Aggregations