Java Code Examples for org.dom4j.tree.DefaultElement#getName()

The following examples show how to use org.dom4j.tree.DefaultElement#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CPResource.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * this constructor is needed when building up the datamodel (parsing XML-manifest)
 * 
 * @param me
 */
public CPResource(final DefaultElement me) {
    super(me.getName());
    files = new Vector<CPFile>();
    dependencies = new Vector<CPDependency>();

    // setAttributes(me.attributes());
    setContent(me.content());

    this.identifier = me.attributeValue(CPCore.IDENTIFIER);
    this.type = me.attributeValue(CPCore.TYPE);
    this.href = me.attributeValue(CPCore.HREF);
    this.xmlbase = me.attributeValue(CPCore.BASE, "");

}
 
Example 2
Source File: CPCore.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * adds an element to the cp. Adds it after the item with identifier "id"
 * 
 * @param newElement
 * @param id
 * @return
 */
public boolean addElementAfter(final DefaultElement newElement, final String id) {
    final DefaultElement beforeElement = rootNode.getElementByIdentifier(id);

    if (beforeElement == null) {
        return false;
    }

    if (beforeElement instanceof CPItem) {
        // beforeElement is a <item>
        // ==> newElement has to be an <item>
        final CPItem beforeItem = (CPItem) beforeElement;
        final DefaultElement parent = beforeItem.getParentElement();
        if (!(newElement instanceof CPItem)) {
            throw new OLATRuntimeException(CPOrganizations.class, "only <item> element allowed", new Exception());
        }
        if (parent instanceof CPItem) {
            final CPItem p = (CPItem) parent;
            p.addItemAt((CPItem) newElement, beforeItem.getPosition() + 1);
        } else if (parent instanceof CPOrganization) {
            final CPOrganization o = (CPOrganization) parent;
            o.addItemAt((CPItem) newElement, beforeItem.getPosition() + 1);
        } else {
            throw new OLATRuntimeException(CPOrganizations.class, "you cannot add an <item> element to a " + parent.getName() + " element", new Exception());
        }

    }

    return true;
}
 
Example 3
Source File: CPDependency.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * this constructor is neeeded when building up the cp (parsing XML manifest file)
 * 
 * @param me
 */
public CPDependency(final DefaultElement me) {
    super(me.getName());
    identifierRef = me.attributeValue(CPCore.IDENTIFIERREF);
    if (identifierRef.equals(null)) {
        throw new OLATRuntimeException(CPOrganizations.class, "Invalid IMS-Manifest ( <dependency> element without identifierref )", new Exception());
    }
}
 
Example 4
Source File: CPManifest.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * this constructor is used when building up the cp (parsing XML)
 * 
 * @param me
 */
public CPManifest(final CPCore cp, final DefaultElement me) {
    super(me.getName());
    errors = new Vector<String>();
    this.identifier = me.attributeValue(CPCore.IDENTIFIER);
    this.schemaLocation = me.attributeValue(CPCore.SCHEMALOCATION);
    this.setNamespace(me.getNamespace());
    this.cp = cp;
    // FIXME: namespaces ! xmlns
    setContent(me.content());
}
 
Example 5
Source File: CPOrganizations.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * this constructor is used when building up the CP (parsing XML)
 * 
 * @param me
 */
public CPOrganizations(final DefaultElement me) {
    super(me.getName());
    orgas = new Vector<CPOrganization>();
    errors = new Vector<String>();
    // setAttributes(me.attributes());
    setContent(me.content());
}
 
Example 6
Source File: CPResources.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * this constructor i used when building up the cp (parsing XML manifest)
 * 
 * @param me
 */
public CPResources(final DefaultElement me) {
    super(me.getName());
    resources = new Vector<CPResource>();
    errors = new Vector<String>();

    setAttributes(me.attributes());
    setContent(me.content());
}
 
Example 7
Source File: CPFile.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor, used when building up the cp (parsing XML-manifest)
 * 
 * @param me
 * @param xmlBase
 *            xmlBase-attribute of the parental resource-element
 * @param packageFolder
 *            TODO
 */
public CPFile(final DefaultElement me, final String xmlBase, final VFSContainer rootDir) {
    super(me.getName());
    setContent(me.content());
    this.href = me.attributeValue(CPCore.HREF);
    if (xmlBase.equals("")) {
        file = (VFSLeaf) rootDir.resolve(href);
    } else {
        file = (VFSLeaf) rootDir.resolve(xmlBase + "/" + href);
    }
}
 
Example 8
Source File: CPItem.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * constructor is needed while building the datamodel-tree (parsing XML)
 * 
 * @param me
 */
public CPItem(final DefaultElement me, final DefaultElement parent) {
    super(me.getName());
    items = new Vector<CPItem>();
    errors = new Vector<String>();

    // setAttributes(me.attributes());
    setContent(me.content());
    this.parent = parent;
    this.identifier = me.attributeValue(CPCore.IDENTIFIER);
    this.identifierRef = me.attributeValue(CPCore.IDENTIFIERREF, "");

    final String val = me.attributeValue(CPCore.ISVISIBLE, "true");
    this.visible = (val != null && val.equals("true"));
}
 
Example 9
Source File: CPOrganization.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * this constructor is used when the cp is built (parsing XML manifest file)
 * 
 * @param me
 */
CPOrganization(final DefaultElement me) {
    super(me.getName());
    items = new Vector<CPItem>();
    errors = new Vector<String>();
    setAttributes(me.attributes());
    setContent(me.content());

    this.identifier = me.attributeValue(CPCore.IDENTIFIER);
    this.structure = me.attributeValue(CPCore.STRUCTURE, "hierarchical");
    // this.title = me.

}
 
Example 10
Source File: CPResource.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * this constructor is needed when building up the datamodel (parsing XML-manifest)
 * 
 * @param me
 */
public CPResource(final DefaultElement me) {
    super(me.getName());
    files = new Vector<CPFile>();
    dependencies = new Vector<CPDependency>();

    // setAttributes(me.attributes());
    setContent(me.content());

    this.identifier = me.attributeValue(CPCore.IDENTIFIER);
    this.type = me.attributeValue(CPCore.TYPE);
    this.href = me.attributeValue(CPCore.HREF);
    this.xmlbase = me.attributeValue(CPCore.BASE, "");

}
 
Example 11
Source File: CPCore.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * adds an element to the cp. Adds it after the item with identifier "id"
 * 
 * @param newElement
 * @param id
 * @return
 */
public boolean addElementAfter(final DefaultElement newElement, final String id) {
    final DefaultElement beforeElement = rootNode.getElementByIdentifier(id);

    if (beforeElement == null) {
        return false;
    }

    if (beforeElement instanceof CPItem) {
        // beforeElement is a <item>
        // ==> newElement has to be an <item>
        final CPItem beforeItem = (CPItem) beforeElement;
        final DefaultElement parent = beforeItem.getParentElement();
        if (!(newElement instanceof CPItem)) {
            throw new OLATRuntimeException(CPOrganizations.class, "only <item> element allowed", new Exception());
        }
        if (parent instanceof CPItem) {
            final CPItem p = (CPItem) parent;
            p.addItemAt((CPItem) newElement, beforeItem.getPosition() + 1);
        } else if (parent instanceof CPOrganization) {
            final CPOrganization o = (CPOrganization) parent;
            o.addItemAt((CPItem) newElement, beforeItem.getPosition() + 1);
        } else {
            throw new OLATRuntimeException(CPOrganizations.class, "you cannot add an <item> element to a " + parent.getName() + " element", new Exception());
        }

    }

    return true;
}
 
Example 12
Source File: CPDependency.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * this constructor is neeeded when building up the cp (parsing XML manifest file)
 * 
 * @param me
 */
public CPDependency(final DefaultElement me) {
    super(me.getName());
    identifierRef = me.attributeValue(CPCore.IDENTIFIERREF);
    if (identifierRef.equals(null)) {
        throw new OLATRuntimeException(CPOrganizations.class, "Invalid IMS-Manifest ( <dependency> element without identifierref )", new Exception());
    }
}
 
Example 13
Source File: CPManifest.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * this constructor is used when building up the cp (parsing XML)
 * 
 * @param me
 */
public CPManifest(final CPCore cp, final DefaultElement me) {
    super(me.getName());
    errors = new Vector<String>();
    this.identifier = me.attributeValue(CPCore.IDENTIFIER);
    this.schemaLocation = me.attributeValue(CPCore.SCHEMALOCATION);
    this.setNamespace(me.getNamespace());
    this.cp = cp;
    // FIXME: namespaces ! xmlns
    setContent(me.content());
}
 
Example 14
Source File: CPOrganizations.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * this constructor is used when building up the CP (parsing XML)
 * 
 * @param me
 */
public CPOrganizations(final DefaultElement me) {
    super(me.getName());
    orgas = new Vector<CPOrganization>();
    errors = new Vector<String>();
    // setAttributes(me.attributes());
    setContent(me.content());
}
 
Example 15
Source File: CPResources.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * this constructor i used when building up the cp (parsing XML manifest)
 * 
 * @param me
 */
public CPResources(final DefaultElement me) {
    super(me.getName());
    resources = new Vector<CPResource>();
    errors = new Vector<String>();

    setAttributes(me.attributes());
    setContent(me.content());
}
 
Example 16
Source File: CPFile.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor, used when building up the cp (parsing XML-manifest)
 * 
 * @param me
 * @param xmlBase
 *            xmlBase-attribute of the parental resource-element
 * @param packageFolder
 *            TODO
 */
public CPFile(final DefaultElement me, final String xmlBase, final VFSContainer rootDir) {
    super(me.getName());
    setContent(me.content());
    this.href = me.attributeValue(CPCore.HREF);
    if (xmlBase.equals("")) {
        file = (VFSLeaf) rootDir.resolve(href);
    } else {
        file = (VFSLeaf) rootDir.resolve(xmlBase + "/" + href);
    }
}
 
Example 17
Source File: CPItem.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * constructor is needed while building the datamodel-tree (parsing XML)
 * 
 * @param me
 */
public CPItem(final DefaultElement me, final DefaultElement parent) {
    super(me.getName());
    items = new Vector<CPItem>();
    errors = new Vector<String>();

    // setAttributes(me.attributes());
    setContent(me.content());
    this.parent = parent;
    this.identifier = me.attributeValue(CPCore.IDENTIFIER);
    this.identifierRef = me.attributeValue(CPCore.IDENTIFIERREF, "");

    final String val = me.attributeValue(CPCore.ISVISIBLE, "true");
    this.visible = (val != null && val.equals("true"));
}
 
Example 18
Source File: CPOrganization.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * this constructor is used when the cp is built (parsing XML manifest file)
 * 
 * @param me
 */
CPOrganization(final DefaultElement me) {
    super(me.getName());
    items = new Vector<CPItem>();
    errors = new Vector<String>();
    setAttributes(me.attributes());
    setContent(me.content());

    this.identifier = me.attributeValue(CPCore.IDENTIFIER);
    this.structure = me.attributeValue(CPCore.STRUCTURE, "hierarchical");
    // this.title = me.

}
 
Example 19
Source File: CPMetadata.java    From olat with Apache License 2.0 4 votes vote down vote up
public CPMetadata(final DefaultElement me) {
    super(me.getName());
    setContent(me.content());
    // TODO: parse xml to LOM-Object!
}
 
Example 20
Source File: CPMetadata.java    From olat with Apache License 2.0 4 votes vote down vote up
public CPMetadata(final DefaultElement me) {
    super(me.getName());
    setContent(me.content());
    // TODO: parse xml to LOM-Object!
}