org.apache.abdera.model.Element

Here are the examples of the java api class org.apache.abdera.model.Element taken from open source projects.

1. SecurityBase#domToFom()

Project: abdera
File: SecurityBase.java
protected Element domToFom(org.w3c.dom.Element element, SecurityOptions options) {
    Element el = null;
    if (element != null) {
        try {
            Serializer ser = new XMLSerializer();
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            ser.setOutputByteStream(out);
            ser.asDOMSerializer().serialize(element);
            ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
            el = options.getParser().parse(in).getRoot();
        } catch (Exception e) {
        }
    }
    return el;
}

2. FOMExtensibleElement#getExtension()

Project: abdera
File: FOMExtensibleElement.java
/**
   * Trick using Generics to find an extension element without 
   * having to pass in it's QName
   */
@SuppressWarnings("unchecked")
public <T extends Element> T getExtension(Class<T> _class) {
    T t = null;
    List<Element> extensions = getExtensions();
    for (Element ext : extensions) {
        if (_class.isAssignableFrom(ext.getClass())) {
            t = (T) ext;
            break;
        }
    }
    return t;
}

3. InteractionActivityRunnable#createBasicInteractionMessage()

Project: incubator-taverna-common-activities
File: InteractionActivityRunnable.java
private Entry createBasicInteractionMessage(final String id, final String runId) {
    final Entry interactionNotificationMessage = ABDERA.newEntry();
    interactionNotificationMessage.setId(id);
    final Date timestamp = new Date();
    interactionNotificationMessage.setPublished(timestamp);
    interactionNotificationMessage.setUpdated(timestamp);
    interactionNotificationMessage.addAuthor("Taverna");
    interactionNotificationMessage.setTitle("Interaction from Taverna for " + this.requestor.generateId());
    final Element runIdElement = interactionNotificationMessage.addExtension(AtomUtils.getRunIdQName());
    runIdElement.setText(StringEscapeUtils.escapeJavaScript(runId));
    final Element pathIdElement = interactionNotificationMessage.addExtension(AtomUtils.getPathIdQName());
    pathIdElement.setText(StringEscapeUtils.escapeJavaScript(this.requestor.getPath()));
    final Element countElement = interactionNotificationMessage.addExtension(AtomUtils.getCountQName());
    countElement.setText(StringEscapeUtils.escapeJavaScript(this.requestor.getInvocationCount().toString()));
    if (this.requestor.getInteractionType().equals(InteractionType.Notification)) {
        interactionNotificationMessage.addExtension(AtomUtils.getProgressQName());
    }
    final Element idElement = interactionNotificationMessage.addExtension(AtomUtils.getIdQName());
    idElement.setText(id);
    return interactionNotificationMessage;
}

4. ResponseFeedListener#getRunId()

Project: incubator-taverna-common-activities
File: ResponseFeedListener.java
private static String getRunId(final Entry entry) {
    final Element runIdElement = entry.getFirstChild(AtomUtils.getRunIdQName());
    if (runIdElement == null) {
        return null;
    }
    return runIdElement.getText();
}

5. ResponseFeedListener#getReplyTo()

Project: incubator-taverna-common-activities
File: ResponseFeedListener.java
private static String getReplyTo(final Entry entry) {
    final Element replyTo = entry.getFirstChild(AtomUtils.getInReplyToQName());
    if (replyTo == null) {
        return null;
    }
    return replyTo.getText();
}

6. FOMExtensibleElement#getSimpleExtension()

Project: abdera
File: FOMExtensibleElement.java
public String getSimpleExtension(QName qname) {
    Element el = getExtension(qname);
    return el.getText();
}

7. FOMExtensibleElement#addSimpleExtension()

Project: abdera
File: FOMExtensibleElement.java
public Element addSimpleExtension(QName qname, String value) {
    FOMFactory fomfactory = (FOMFactory) factory;
    Element el = fomfactory.newElement(qname, this);
    el.setText(value);
    return el;
}

8. EncryptionBase#isEncrypted()

Project: abdera
File: EncryptionBase.java
public boolean isEncrypted(Document doc) throws SecurityException {
    Element el = doc.getRoot();
    return el.getQName().equals(Constants.ENCRYPTEDDATA);
}

9. FOMPerson#getEmail()

Project: abdera
File: FOMPerson.java
public String getEmail() {
    Element email = getEmailElement();
    return (email != null) ? email.getText() : null;
}

10. FOMPerson#getName()

Project: abdera
File: FOMPerson.java
public String getName() {
    Element name = getNameElement();
    return (name != null) ? name.getText() : null;
}

11. FOMFactory#newExtensionElement()

Project: abdera
File: FOMFactory.java
@SuppressWarnings("unchecked")
public Element newExtensionElement(QName qname, OMContainer parent, OMXMLParserWrapper parserWrapper) {
    Element element = null;
    List<ExtensionFactory> factories = getExtensionFactories();
    for (ExtensionFactory factory : factories) {
        if (factory instanceof FOMExtensionFactory && factory.handlesNamespace(qname.getNamespaceURI())) {
            if (parserWrapper != null) {
                element = ((FOMExtensionFactory) factory).newExtensionElement(qname, (Base) parent, this, parserWrapper);
            } else {
                element = factory.newExtensionElement(qname, (Base) parent, this);
            }
        }
    }
    if (element == null) {
        if (parserWrapper == null) {
            element = new FOMElement(qname, (OMContainer) parent, this);
        } else {
            element = new FOMElement(qname, (OMContainer) parent, this, parserWrapper);
        }
    }
    return element;
}

12. FOMExtensibleElement#addExtensions()

Project: abdera
File: FOMExtensibleElement.java
public void addExtensions(List<Element> extensions) {
    for (Element e : extensions) {
        addExtension(e);
    }
}

13. FOMElement#getNextSibling()

Project: abdera
File: FOMElement.java
@SuppressWarnings("unchecked")
public <T extends Element> T getNextSibling(QName qname) {
    Element el = getNextSibling();
    while (el != null) {
        OMElement omel = (OMElement) el;
        if (omel.getQName().equals(qname))
            return (T) omel;
        el = el.getNextSibling();
    }
    return null;
}

14. FOMElement#getPreviousSibling()

Project: abdera
File: FOMElement.java
@SuppressWarnings("unchecked")
public <T extends Element> T getPreviousSibling(QName qname) {
    Element el = getPreviousSibling();
    while (el != null) {
        OMElement omel = (OMElement) el;
        if (omel.getQName().equals(qname))
            return (T) omel;
        el = el.getPreviousSibling();
    }
    return null;
}