本文整理了Java中org.apache.felix.ipojo.metadata.Element
类的一些代码示例,展示了Element
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element
类的具体详情如下:
包路径:org.apache.felix.ipojo.metadata.Element
类名称:Element
[英]An element represents an XML Element. It contains a name, a namepace, Attribute objects and sub-elements. This class is used to parse iPOJO metadata.
[中]元素表示XML元素。它包含名称、名称空间、属性对象和子元素。此类用于解析iPOJO元数据。
代码示例来源:origin: apache/felix
/**
* Find all the values of the specified attribute in the given element.
* @param metadata Element to be traversed
* @param attributeName Search attribute name
* @return Set of attribute values (no duplicate).
*/
public static Set<String> findAttributes(Element metadata, String attributeName) {
Set<String> referred = new HashSet<String>();
// Search in the given element
if (metadata.containsAttribute(attributeName)) {
referred.add(metadata.getAttribute(attributeName));
}
// Search in children
for (Element elem : metadata.getElements()) {
Set<String> found = findAttributes(elem, attributeName);
referred.addAll(found);
}
// Return all found values
return referred;
}
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.api
/**
* Adds an array property.
* @param name the property name
* @param values the property value
* @return the current instantiated sub-service
*/
public InstantiatedService addProperty(String name, String[] values) {
Element elem = new Element("property", "");
elem.addAttribute(new Attribute("name", name));
elem.addAttribute(new Attribute("type", "array"));
m_conf.add(elem);
for (int i = 0; i < values.length; i++) {
Object obj = values[i];
Element e = new Element("property", "");
elem.addElement(e);
e.addAttribute(new Attribute("value", obj.toString()));
}
return this;
}
代码示例来源:origin: apache/felix
/**
* To String method.
* @return the String form of this element.
* @see java.lang.Object#toString()
*/
public String toString() {
return toString(0);
}
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo
private String initExtension() {
if (m_componentMetadata.getNameSpace() == null) {
return m_componentMetadata.getName();
}
return m_componentMetadata.getNameSpace() + ":" + m_componentMetadata.getName();
}
代码示例来源:origin: apache/felix
private void collectStructuralFields(List<String> fieldsInStructure, Element structure) {
Element[] fields = structure.getElements("field");
if (fields != null) {
for (Element field : fields) {
fieldsInStructure.add(field.getAttribute("name"));
}
}
}
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo
/**
* Gets the array of component type metadata.
* @return the component metadata (composite & component).
* An empty array is returned if no component type declaration.
* @throws ParseException if a parsing error occurs
*/
public Element[] getComponentsMetadata() throws ParseException {
Element[] elems = m_elements[0].getElements();
List list = new ArrayList();
for (int i = 0; i < elems.length; i++) {
if (!"instance".equals(elems[i].getName())) {
list.add(elems[i]);
}
}
return (Element[]) list.toArray(new Element[list.size()]);
}
代码示例来源:origin: apache/felix
/**
* Compute required handlers.
* @return the list of required handler.
*/
public List<RequiredHandler> getRequiredHandlerList() {
List<RequiredHandler> list = new ArrayList<RequiredHandler>();
Element[] elems = m_componentMetadata.getElements();
for (Element current : elems) {
RequiredHandler req = new RequiredHandler(current.getName(), current.getNameSpace());
if (!list.contains(req)) {
list.add(req);
}
}
// Add architecture if architecture != 'false'
String arch = m_componentMetadata.getAttribute("architecture");
if (arch == null || arch.equalsIgnoreCase("true")) {
RequiredHandler req = new RequiredHandler("architecture", null);
if (! list.contains(req)) { list.add(req); }
}
return list;
}
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo
/**
* Creates a field metadata.
* This constructor is used when creating the {@link PojoMetadata}
* object.
* @param metadata the field manipulation element from Manipulation
* Metadata.
*/
FieldMetadata(Element metadata) {
m_name = metadata.getAttribute("name");
m_type = metadata.getAttribute("type");
}
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.api
/**
* Adds a string property.
* @param name the property name
* @param value the property value
* @return the current instantiated sub-service
*/
public InstantiatedService addProperty(String name, String value) {
Element elem = new Element("property", "");
m_conf.add(elem);
elem.addAttribute(new Attribute("name", name));
elem.addAttribute(new Attribute("value", value));
return this;
}
代码示例来源:origin: apache/felix
if (publisher.containsAttribute(NAME_ATTRIBUTE)) {
m_name = publisher.getAttribute(NAME_ATTRIBUTE);
} else {
throw new ConfigurationException(
if (publisher.containsAttribute(FIELD_ATTRIBUTE)) {
m_field = publisher.getAttribute(FIELD_ATTRIBUTE);
} else {
throw new ConfigurationException(
if (publisher.containsAttribute(TOPICS_ATTRIBUTE)) {
setTopics(publisher.getAttribute(TOPICS_ATTRIBUTE));
} else {
m_topics = null;
if (publisher.containsAttribute(SYNCHRONOUS_ATTRIBUTE)) {
m_synchronous = "true".equalsIgnoreCase(publisher
.getAttribute(SYNCHRONOUS_ATTRIBUTE));
} else {
m_synchronous = DEFAULT_SYNCHRONOUS_VALUE;
if (publisher.containsAttribute(DATA_KEY_ATTRIBUTE)) {
m_dataKey = publisher.getAttribute(DATA_KEY_ATTRIBUTE);
} else if (publisher.containsAttribute("data_key")) {
m_dataKey = publisher.getAttribute("data_key");
} else if (publisher.containsAttribute("dataKey")) {
m_dataKey = publisher.getAttribute("dataKey");
代码示例来源:origin: apache/felix
/**
* Get parsed metadata.
* The document must be parsed before calling this method.
* @return : all the metadata.
* @throws ParseException : occurs if an error occurs during the parsing.
*/
public Element[] getMetadata() throws ParseException {
return m_elements[0].getElements();
}
代码示例来源:origin: apache/felix
if (componentMetadata != null && componentMetadata.containsAttribute("name") && instanceMetadata != null) {
instanceMetadata.addAttribute(new Attribute("component", componentMetadata.getAttribute("name")));
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo
private void computeServiceReferenceDescription(ServiceReference ref, Element use) {
use.addAttribute(new Attribute(Constants.SERVICE_ID, ref.getProperty(Constants.SERVICE_ID).toString()));
String instance = (String) ref.getProperty(Factory.INSTANCE_NAME_PROPERTY);
if (instance != null) {
use.addAttribute(new Attribute(Factory.INSTANCE_NAME_PROPERTY, instance));
}
}
代码示例来源:origin: org.wisdom-framework/wisdom-ipojo-module
/**
* @return the Component element.
*/
public static Element getComponentElement() {
return new Element(COMPONENT, "");
}
}
代码示例来源:origin: apache/felix
/**
* Gets the instance description.
* Overridden to add created objects.
* @return the instance description
*/
public Element getDescription() {
Element elem = super.getDescription();
elem.addElement(getInternalServices());
InstanceDescription[] descs = getContainedInstances();
if (descs.length > 0) {
Element inst = new Element("ContainedInstances", "");
for (int i = 0; i < descs.length; i++) {
inst.addElement(descs[i].getDescription());
}
elem.addElement(inst);
}
return elem;
}
代码示例来源:origin: apache/felix
/**
* End of the annotation.
* Create a "controller" element
* @see org.objectweb.asm.AnnotationVisitor#visitEnd()
*/
public void visitEnd() {
provides.addElement(controller);
}
}
代码示例来源:origin: apache/felix
private void renderElement(Element element, StringBuilder builder) {
// If the element is already here, do not re-add the element.
if(!isFiltered(element)) {
// Print the beginning of the element
startElement(element, builder);
// Render all attributes
for (Attribute attribute : element.getAttributes()) {
renderAttribute(attribute, builder);
}
// Render child elements
for (Element child : element.getElements()) {
renderElement(child, builder);
}
// Print the end of the element
endElement(builder);
}
}
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo
if (metadata.containsAttribute("nullable") || dependency.getDefaultImplementation() != null || dependency
.getException() != null) {
if (metadata.containsAttribute("nullable") && dependency.getDefaultImplementation() != null) {
throw new ConfigurationException(message + "`nullable` and `default-implementation` cannot be " +
"combined");
if (metadata.containsAttribute("nullable") && dependency.getException() != null) {
throw new ConfigurationException(message + "`nullable` and `exception` cannot be combined");
代码示例来源:origin: apache/felix
private boolean isInstance(Element element) {
return "instance".equals(element.getName());
}
}
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.composite
/**
* Compute required handlers.
* @return the list of required handler.
*/
public List<RequiredHandler> getRequiredHandlerList() {
List<RequiredHandler> list = new ArrayList<RequiredHandler>();
Element[] elems = m_componentMetadata.getElements();
for (Element current : elems) {
RequiredHandler req = new RequiredHandler(current.getName(), current.getNameSpace());
if (!list.contains(req)) {
list.add(req);
}
}
// Add architecture if architecture != 'false'
String arch = m_componentMetadata.getAttribute("architecture");
if (arch == null || arch.equalsIgnoreCase("true")) {
RequiredHandler req = new RequiredHandler("architecture", null);
if (! list.contains(req)) { list.add(req); }
}
return list;
}
内容来源于网络,如有侵权,请联系作者删除!