Java Code Examples for org.dom4j.Element#getQualifiedName()

The following examples show how to use org.dom4j.Element#getQualifiedName() . 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: ColorClusterType.java    From ofdrw with Apache License 2.0 6 votes vote down vote up
/**
 * 解析元素并获取对应的 颜色族子类实例
 *
 * @param element 实例
 * @return 子类实例,基本颜色、底纹和渐变
 * @throws IllegalArgumentException 未知的元素类型不是 ColorClusterType子类
 */
static ColorClusterType getInstance(Element element) {
    String qName = element.getQualifiedName();
    ColorClusterType res = null;
    switch (qName) {
        case "ofd:Pattern":
            res = new CT_Pattern(element);
            break;
        case "ofd:AxialShd":
            res = new CT_AxialShd(element);
            break;
        case "ofd:RadialShd":
            res = new CT_RadialShd(element);
            break;
        case "ofd:GouraudShd":
            res = new CT_GouraudShd(element);
            break;
        case "ofd:LaGouraudShd":
            res = new CT_LaGouraudShd(element);
            break;
        default:
            throw new IllegalArgumentException("未知的元素类型不是 颜色子类:" + qName);
    }
    return res;
}
 
Example 2
Source File: ClipAble.java    From ofdrw with Apache License 2.0 6 votes vote down vote up
/**
 * 获取可裁剪对象实例
 *
 * @param e 元素对象
 * @return 可裁剪对象
 */
static ClipAble getInstance(Element e) {
    if (e == null) {
        return null;
    }
    String qName = e.getQualifiedName();
    ClipAble res = null;
    switch (qName) {
        case "Path":
            res = new CT_Path(e);
            break;
        case "Text":
            res = new CT_Text(e);
            break;
        default:
            throw new IllegalArgumentException("不支持裁剪对象类型:" + qName);
    }
    return res;
}
 
Example 3
Source File: OFDResource.java    From ofdrw with Apache License 2.0 6 votes vote down vote up
/**
 * 解析元素并获取对应资源类型子类实例
 *
 * @param element 实例
 * @return 子类实例
 * @throws IllegalArgumentException 未知的元素类型不是 OFDResource子类
 */
static OFDResource getInstance(Element element) {
    String qName = element.getQualifiedName();
    OFDResource res = null;
    switch (qName) {
        case "ofd:ColorSpaces":
            res = new ColorSpaces(element);
            break;
        case "ofd:DrawParams":
            res = new DrawParams(element);
            break;
        case "ofd:Fonts":
            res = new Fonts(element);
            break;
        case "ofd:MultiMedias":
            res = new MultiMedias(element);
            break;
        case "ofd:CompositeGraphicUnits":
            res = new CompositeGraphicUnits(element);
            break;
        default:
            throw new IllegalArgumentException("不是 Res的子类,未知元素类型:" + qName);
    }
    return res;
}
 
Example 4
Source File: OFDAction.java    From ofdrw with Apache License 2.0 6 votes vote down vote up
/**
 * 获取动作类型实例
 *
 * @param element 元素
 * @return 实例
 * @throws IllegalArgumentException 未知的动作类型
 */
static OFDAction getInstance(Element element) {
    String qName = element.getQualifiedName();
    switch (qName) {
        case "ofd:Goto":
            return new Goto(element);
        case "ofd:URI":
            return new URI(element);
        case "ofd:GotoA":
            return new GotoA(element);
        case "ofd:Sound":
            return new Sound(element);
        case "Movies":
            return new Movie(element);
        default:
            throw new IllegalArgumentException("未知的动作类型:" + qName);
    }
}
 
Example 5
Source File: PageBlockType.java    From ofdrw with Apache License 2.0 5 votes vote down vote up
/**
 * 解析元素并获取对应的PageBlock子类实例
 *
 * @param element 实例
 * @return 子类实例
 * @throws IllegalArgumentException 未知的元素类型不是 PageBlock子类
 */
static PageBlockType getInstance(Element element) {
    String qName = element.getQualifiedName();
    PageBlockType res = null;
    switch (qName) {
        case "ofd:TextObject":
            res = new TextObject(element);
            break;
        case "ofd:PathObject":
            res = new PathObject(element);
            break;
        case "ofd:ImageObject":
            res = new ImageObject(element);
            break;
        case "ofd:CompositeObject":
            res = new CompositeObject(element);
            break;
        case "ofd:PageBlock":
            res = new CT_PageBlock(element);
            break;
        case "ofd:Layer":
            res = new CT_Layer(element);
            break;
        default:
            throw new IllegalArgumentException("不是 PageBlock 子类,未知元素类型:" + qName);
    }
    return res;
}
 
Example 6
Source File: OFDGotoTarget.java    From ofdrw with Apache License 2.0 5 votes vote down vote up
/**
 * 获取Goto目的地描述实例
 * @param element 元素
 * @return 实例
 * @throws IllegalArgumentException 未知Goto的目标类型
 */
static OFDGotoTarget getInstance(Element element) {
    String qName = element.getQualifiedName();
    switch (qName) {
        case "ofd:Dest":
            return new CT_Dest(element);
        case "ofd:Bookmark":
            return new Bookmark(element);
        default:
            throw new IllegalArgumentException("未知Goto的目标类型:" + qName);
    }
}
 
Example 7
Source File: LowercaseTableNames.java    From unitime with Apache License 2.0 4 votes vote down vote up
protected void writeElement(Element element) throws IOException {
    int size = element.nodeCount();
    String qualifiedName = element.getQualifiedName();

    writePrintln();
    indent();

    writer.write("<");
    writer.write(qualifiedName);

    boolean textOnly = true;

    for (int i = 0; i < size; i++) {
        Node node = element.node(i);
        if (node instanceof Element) {
            textOnly = false;
        } else if (node instanceof Comment) {
            textOnly = false;
        }
    }

    writeAttributes(element);

    lastOutputNodeType = Node.ELEMENT_NODE;

    if (size <= 0) {
        writeEmptyElementClose(qualifiedName);
    } else {
        writer.write(">");

        if (textOnly) {
            // we have at least one text node so lets assume
            // that its non-empty
            writeElementContent(element);
        } else {
        	if (element.attributeCount() > 3)
        		writePrintln();
            // we know it's not null or empty from above
            ++indentLevel;

            writeElementContent(element);

            --indentLevel;

            writePrintln();
            indent();
        }

        writer.write("</");
        writer.write(qualifiedName);
        writer.write(">");
    }
   	if (element.attributeCount() > 2 && indentLevel > 0)
   		writePrintln();

    lastOutputNodeType = Node.ELEMENT_NODE;
}
 
Example 8
Source File: ItemWithResponseStr.java    From olat with Apache License 2.0 4 votes vote down vote up
/**
 * Constructor for ItemWithResponseLid.
 * 
 * @param el_item
 */
public ItemWithResponseStr(final Element el_item) {
    // CELFI#107
    this.itemTitle = el_item.attributeValue("title");
    this.itemIdent = el_item.attributeValue("ident");

    final Element decvar = (Element) el_item.selectSingleNode(".//outcomes/decvar");

    if (decvar != null) {
        this.itemMinValue = decvar.attributeValue("minvalue");
        this.itemMaxValue = decvar.attributeValue("maxvalue");
        this.itemCutValue = decvar.attributeValue("cutvalue");
    }

    final List el_presentationElements = el_item.selectNodes(".//presentation//mattext | .//presentation//response_str");

    int i = 1;
    boolean lastWasMattext = false;
    for (final Iterator itPresentations = el_presentationElements.iterator(); itPresentations.hasNext();) {
        final Element el_presentation = (Element) itPresentations.next();
        final String el_qname = el_presentation.getQualifiedName();
        if (el_qname.equalsIgnoreCase("mattext")) {
            this.quetionText += el_presentation.getTextTrim();
            lastWasMattext = true;
        } else {

            responseStrIdents.add(el_presentation.attributeValue("ident"));
            final Element render_fib = el_presentation.element("render_fib");
            if (render_fib != null) {
                isEssay = (render_fib.attributeValue("rows") == null) ? false : true;
                responseColumnHeaders.add((isEssay ? "A" : "B") + i); // A -> Area, B -> Blank

                final Element responseValue = (Element) el_item.selectSingleNode(".//varequal[@respident='" + el_presentation.attributeValue("ident") + "']");
                if (responseValue != null) {
                    responseLabelMaterials.add(responseValue.getTextTrim());
                    if (lastWasMattext) {
                        this.quetionText += " [" + responseValue.getTextTrim() + "] ";
                        lastWasMattext = false;
                    }
                } else {
                    responseLabelMaterials.add("");
                }

            } else {
                responseColumnHeaders.add("unknownType");

                responseLabelMaterials.add("");
            }
            i++;
        }
    }
    // CELFI#107 END
}
 
Example 9
Source File: ItemWithResponseStr.java    From olat with Apache License 2.0 4 votes vote down vote up
/**
 * Constructor for ItemWithResponseLid.
 * 
 * @param el_item
 */
public ItemWithResponseStr(final Element el_item) {
    // CELFI#107
    this.itemTitle = el_item.attributeValue("title");
    this.itemIdent = el_item.attributeValue("ident");

    final Element decvar = (Element) el_item.selectSingleNode(".//outcomes/decvar");

    if (decvar != null) {
        this.itemMinValue = decvar.attributeValue("minvalue");
        this.itemMaxValue = decvar.attributeValue("maxvalue");
        this.itemCutValue = decvar.attributeValue("cutvalue");
    }

    final List el_presentationElements = el_item.selectNodes(".//presentation//mattext | .//presentation//response_str");

    int i = 1;
    boolean lastWasMattext = false;
    for (final Iterator itPresentations = el_presentationElements.iterator(); itPresentations.hasNext();) {
        final Element el_presentation = (Element) itPresentations.next();
        final String el_qname = el_presentation.getQualifiedName();
        if (el_qname.equalsIgnoreCase("mattext")) {
            this.quetionText += el_presentation.getTextTrim();
            lastWasMattext = true;
        } else {

            responseStrIdents.add(el_presentation.attributeValue("ident"));
            final Element render_fib = el_presentation.element("render_fib");
            if (render_fib != null) {
                isEssay = (render_fib.attributeValue("rows") == null) ? false : true;
                responseColumnHeaders.add((isEssay ? "A" : "B") + i); // A -> Area, B -> Blank

                final Element responseValue = (Element) el_item.selectSingleNode(".//varequal[@respident='" + el_presentation.attributeValue("ident") + "']");
                if (responseValue != null) {
                    responseLabelMaterials.add(responseValue.getTextTrim());
                    if (lastWasMattext) {
                        this.quetionText += " [" + responseValue.getTextTrim() + "] ";
                        lastWasMattext = false;
                    }
                } else {
                    responseLabelMaterials.add("");
                }

            } else {
                responseColumnHeaders.add("unknownType");

                responseLabelMaterials.add("");
            }
            i++;
        }
    }
    // CELFI#107 END
}