FileDocCategorySizeDatePackage
SmilXmlSerializer.javaAPI DocAndroid 1.5 API2635Wed May 06 22:42:46 BST 2009com.android.mms.dom.smil.parser

SmilXmlSerializer

public class SmilXmlSerializer extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidserialize(org.w3c.dom.smil.SMILDocument smilDoc, java.io.OutputStream out)

        try {
            Writer writer = new BufferedWriter(new OutputStreamWriter(out, "UTF-8"), 2048);

            writeElement(writer, smilDoc.getDocumentElement());
            writer.flush();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    
private static voidwriteElement(java.io.Writer writer, org.w3c.dom.Element element)

        writer.write('<");
        writer.write(element.getTagName());

        if (element.hasAttributes()) {
            NamedNodeMap attributes = element.getAttributes();
            for (int i = 0; i < attributes.getLength(); i++) {
                Attr attribute = (Attr)attributes.item(i);
                writer.write(" " + attribute.getName());
                writer.write("=\"" + attribute.getValue() + "\"");
            }
        }

        // FIXME: Might throw ClassCastException
        SMILElement childElement = (SMILElement) element.getFirstChild();

        if (childElement != null) {
            writer.write('>");

            do {
                writeElement(writer, childElement);
                childElement = (SMILElement) childElement.getNextSibling();
            } while (childElement != null);

            writer.write("</");
            writer.write(element.getTagName());
            writer.write('>");
        } else {
            writer.write("/>");
        }