Example usage for org.dom4j Element addElement

List of usage examples for org.dom4j Element addElement

Introduction

In this page you can find the example usage for org.dom4j Element addElement.

Prototype

Element addElement(String name);

Source Link

Document

Adds a new Element node with the given name to this branch and returns a reference to the new node.

Usage

From source file:com.jswiff.xml.TagXMLWriter.java

License:Open Source License

private static void writeScriptLimits(Element parentElement, ScriptLimits tag) {
    Element element = parentElement.addElement("scriptlimits");
    element.addAttribute("maxrecursiondepth", Integer.toString(tag.getMaxRecursionDepth()));
    element.addAttribute("scripttimeout", Integer.toString(tag.getScriptTimeoutSeconds()));
}

From source file:com.jswiff.xml.TagXMLWriter.java

License:Open Source License

private static void writeSetTabIndex(Element parentElement, SetTabIndex tag) {
    Element element = parentElement.addElement("settabindex");
    element.addAttribute("depth", Integer.toString(tag.getDepth()));
    element.addAttribute("tabindex", Integer.toString(tag.getTabIndex()));
}

From source file:com.jswiff.xml.TagXMLWriter.java

License:Open Source License

private static void writeShowFrame(Element parentElement, ShowFrame tag) {
    parentElement.addElement("showframe");
}

From source file:com.jswiff.xml.TagXMLWriter.java

License:Open Source License

private static void writeSoundStreamBlock(Element parentElement, SoundStreamBlock tag) {
    Element element = parentElement.addElement("soundstreamblock");
    element.addElement("streamsounddata").addText(Base64.encode(tag.getStreamSoundData()));
}

From source file:com.jswiff.xml.TagXMLWriter.java

License:Open Source License

private static void writeSoundStreamHead(Element parentElement, SoundStreamHead tag) {
    Element element = parentElement.addElement("soundstreamhead");
    element.addAttribute("streamformat", getSoundFormatString(tag.getStreamFormat()));
    element.addAttribute("streamrate", getSoundRateString(tag.getStreamRate()));
    if (tag.isStreamStereo()) {
        element.addAttribute("streamstereo", "true");
    }/*from w  w w  .j  ava  2s.c o  m*/
    element.addAttribute("streamsamplecount", Integer.toString(tag.getStreamSampleCount()));
    element.addAttribute("playbackrate", getSoundRateString(tag.getPlaybackRate()));
    if (tag.isPlaybackStereo()) {
        element.addAttribute("playbackstereo", "true");
    }
    if (tag.getStreamFormat() == SoundStreamHead.FORMAT_MP3) {
        element.addAttribute("latencyseek", Short.toString(tag.getLatencySeek()));
    }
}

From source file:com.jswiff.xml.TagXMLWriter.java

License:Open Source License

private static void writeSoundStreamHead2(Element parentElement, SoundStreamHead2 tag) {
    Element element = parentElement.addElement("soundstreamhead2");
    element.addAttribute("streamformat", getSoundFormatString(tag.getStreamFormat()));
    element.addAttribute("streamrate", getSoundRateString(tag.getStreamRate()));
    if (tag.isStream16BitSample()) {
        element.addAttribute("streamsample16bit", "true");
    }// www.  jav  a  2s .  c o  m
    if (tag.isStreamStereo()) {
        element.addAttribute("streamstereo", "true");
    }
    element.addAttribute("streamsamplecount", Integer.toString(tag.getStreamSampleCount()));
    element.addAttribute("playbackrate", getSoundRateString(tag.getPlaybackRate()));
    if (tag.isPlayback16BitSample()) {
        element.addAttribute("playbacksample16bit", "true");
    }
    if (tag.isPlaybackStereo()) {
        element.addAttribute("playbackstereo", "true");
    }
    if (tag.getStreamFormat() == SoundStreamHead.FORMAT_MP3) {
        element.addAttribute("latencyseek", Short.toString(tag.getLatencySeek()));
    }
}

From source file:com.jswiff.xml.TagXMLWriter.java

License:Open Source License

private static void writeStartSound(Element parentElement, StartSound tag) {
    Element element = parentElement.addElement("startsound");
    element.addAttribute("soundid", Integer.toString(tag.getSoundId()));
    RecordXMLWriter.writeSoundInfo(element, tag.getSoundInfo());
}

From source file:com.jswiff.xml.TagXMLWriter.java

License:Open Source License

private static void writeUnknownTag(Element parentElement, UnknownTag tag) {
    Element element = parentElement.addElement("unknowntag");
    element.addAttribute("code", Integer.toString(tag.getCode()));
    element.addText(Base64.encode(tag.getData()));
}

From source file:com.jswiff.xml.TagXMLWriter.java

License:Open Source License

private static void writeVideoFrame(Element parentElement, VideoFrame tag) {
    Element element = parentElement.addElement("videoframe");
    element.addAttribute("streamid", Integer.toString(tag.getStreamId()));
    element.addAttribute("framenum", Integer.toString(tag.getFrameNum()));
    element.addElement("videodata").addText(Base64.encode(tag.getVideoData()));
}

From source file:com.jswiff.xml.XMLWriter.java

License:Open Source License

private void writeHeader() {
    Element headerElement = rootElement.addElement("header");
    headerElement.addAttribute("swfversion", Integer.toString(swfDocument.getVersion()));
    if (swfDocument.isCompressed()) {
        headerElement.addAttribute("compressed", "true");
    }/*from  ww  w . j a  v  a  2s.co m*/
    Element frames = headerElement.addElement("frames");
    frames.addAttribute("count", Integer.toString(swfDocument.getFrameCount()));
    frames.addAttribute("rate", Integer.toString(swfDocument.getFrameRate()));
    Rect size = swfDocument.getFrameSize();
    RecordXMLWriter.writeRect(frames, "size", size);
    Color bgColor = swfDocument.getBackgroundColor();
    if (bgColor != null) {
        RecordXMLWriter.writeColor(headerElement, "bgcolor", bgColor);
    }
    if (swfDocument.getVersion() >= 8) {
        switch (swfDocument.getAccessMode()) {
        case SWFDocument.ACCESS_MODE_LOCAL:
            headerElement.addAttribute("access", "local");
            break;
        case SWFDocument.ACCESS_MODE_NETWORK:
            headerElement.addAttribute("access", "network");
            break;
        }
        String metadata = swfDocument.getMetadata();
        if (metadata != null) {
            headerElement.addElement("metadata").addText(Base64.encodeString(metadata));
        }
    }
}