bundles/org.eclipse.packagedrone.repo.aspect.common/src/org/eclipse/packagedrone/repo/aspect/common/p2/InstallableUnit.java
public void writeXmlForUnit ( final XMLStreamWriter xsw ) throws XMLStreamException
    {
        xsw.writeStartElement ( "unit" );
        xsw.writeAttribute ( "id", this.id );
        xsw.writeAttribute ( "version", "" + this.version );
        xsw.writeAttribute ( "singleton", Boolean.toString ( this.singleton ) );

        {
            xsw.writeEmptyElement ( "update" );
            xsw.writeAttribute ( "id", this.id );
            xsw.writeAttribute ( "range", "[0.0.0," + this.version + ")" );
            xsw.writeAttribute ( "severity", "0" );
        }

        {
            xsw.writeStartElement ( "properties" );
            xsw.writeAttribute ( "size", Integer.toString ( this.properties.size () ) );

            for ( final Map.Entry<String, String> entry : this.properties.entrySet () )
            {
                xsw.writeStartElement ( "property" );
                xsw.writeAttribute ( "name", entry.getKey () );
                if ( entry.getValue () != null )
                {
                    xsw.writeAttribute ( "value", entry.getValue () );
                }
                xsw.writeEndElement ();
            }

            xsw.writeEndElement (); // properties
        }

        {
            xsw.writeStartElement ( "provides" );
            xsw.writeAttribute ( "size", Integer.toString ( this.provides.size () ) );

            for ( final Entry<String> entry : this.provides )
            {
                xsw.writeStartElement ( "provided" );
                xsw.writeAttribute ( "namespace", entry.getNamespace () );
                xsw.writeAttribute ( "name", entry.getKey () );
                xsw.writeAttribute ( "version", entry.getValue () );
                xsw.writeEndElement ();
            }

            xsw.writeEndElement (); // provides
        }

        {
            xsw.writeStartElement ( "requires" );
            xsw.writeAttribute ( "size", Integer.toString ( this.requires.size () ) );

            for ( final Entry<Requirement> entry : this.requires )
            {
                xsw.writeStartElement ( "required" );

                xsw.writeAttribute ( "namespace", entry.getNamespace () );
                xsw.writeAttribute ( "name", entry.getKey () );
                xsw.writeAttribute ( "range", makeString ( entry.getValue ().getRange () ) );

                if ( entry.getValue ().isOptional () )
                {
                    xsw.writeAttribute ( "optional", "true" );

                }
                if ( entry.getValue ().getGreedy () != null )
                {
                    xsw.writeAttribute ( "greedy", "" + entry.getValue ().getGreedy () );
                }

                final String filterString = entry.getValue ().getFilter ();
                if ( filterString != null && !filterString.isEmpty () )
                {
                    xsw.writeStartElement ( "filter" );
                    xsw.writeCharacters ( entry.getValue ().getFilter () );
                    xsw.writeEndElement (); // filter
                }

                xsw.writeEndElement (); // required
            }

            xsw.writeEndElement (); // requires
        }

        {
            if ( this.filter != null && !this.filter.isEmpty () )
            {
                xsw.writeStartElement ( "filter" );
                xsw.writeCharacters ( this.filter );
                xsw.writeEndElement (); // filter
            }
        }

        if ( !this.artifacts.isEmpty () )
        {
            xsw.writeStartElement ( "artifacts" );
            xsw.writeAttribute ( "size", Integer.toString ( this.artifacts.size () ) );

            for ( final Artifact artifact : this.artifacts )
            {
                xsw.writeEmptyElement ( "artifact" );
                xsw.writeAttribute ( "classifier", artifact.getClassifer () );
                xsw.writeAttribute ( "id", artifact.getId () );
                xsw.writeAttribute ( "version", "" + artifact.getVersion () );
            }

            xsw.writeEndElement (); // artifacts
        }

        {
            if ( this.touchpoints.isEmpty () )
            {
                xsw.writeEmptyElement ( "touchpoint" );
                xsw.writeAttribute ( "id", "null" );
                xsw.writeAttribute ( "version", "0.0.0" );
            }
            else
            {
                for ( final Touchpoint tp : this.touchpoints )
                {
                    xsw.writeEmptyElement ( "touchpoint" );
                    xsw.writeAttribute ( "id", tp.getId () );
                    xsw.writeAttribute ( "version", tp.getVersion () );

                    if ( !tp.getInstructions ().isEmpty () )
                    {
                        xsw.writeStartElement ( "touchpointData" );
                        xsw.writeAttribute ( "size", "1" );

                        xsw.writeStartElement ( "instructions" );
                        xsw.writeAttribute ( "size", Integer.toString ( tp.getInstructions ().size () ) );

                        for ( final Map.Entry<String, String> entry : tp.getInstructions ().entrySet () )
                        {
                            xsw.writeStartElement ( "instruction" );
                            xsw.writeAttribute ( "key", entry.getKey () );
                            xsw.writeCharacters ( entry.getValue () );
                            xsw.writeEndElement (); // instruction
                        }

                        xsw.writeEndElement (); // instructions
                        xsw.writeEndElement (); // touchpointData
                    }
                }
            }
        }

        {
            xsw.writeStartElement ( "licenses" );
            xsw.writeAttribute ( "size", Integer.toString ( this.licenses.size () ) );

            for ( final License licenseEntry : this.licenses )
            {
                xsw.writeStartElement ( "license" );

                if ( licenseEntry.getUri () != null )
                {
                    xsw.writeAttribute ( "url", licenseEntry.getUri () );
                    xsw.writeAttribute ( "uri", licenseEntry.getUri () );
                }

                if ( licenseEntry.getText () != null )
                {
                    xsw.writeCData ( licenseEntry.getText () );
                }

                xsw.writeEndElement (); // license
            }

            xsw.writeEndElement (); // licenses
        }

        if ( this.copyright != null || this.copyrightUrl != null )
        {
            xsw.writeStartElement ( "copyright" );

            if ( this.copyrightUrl != null )
            {
                xsw.writeAttribute ( "url", this.copyrightUrl );
                xsw.writeAttribute ( "uri", this.copyrightUrl );
            }
            if ( this.copyright != null )
            {
                xsw.writeCData ( this.copyright );
            }
            xsw.writeEndElement ();
        }

        xsw.writeEndElement (); // unit
    }
public void writeXmlForUnit ( final XMLStreamWriter xsw ) throws XMLStreamException
    {
        xsw.writeStartElement ( "unit" );
        xsw.writeAttribute ( "id", this.id );
        xsw.writeAttribute ( "version", "" + this.version );
        xsw.writeAttribute ( "singleton", Boolean.toString ( this.singleton ) );

        {
            xsw.writeEmptyElement ( "update" );
            xsw.writeAttribute ( "id", this.id );
            xsw.writeAttribute ( "range", "[0.0.0," + this.version + ")" );
            xsw.writeAttribute ( "severity", "0" );
        }

        {
            xsw.writeStartElement ( "properties" );
            xsw.writeAttribute ( "size", Integer.toString ( this.properties.size () ) );

            for ( final Map.Entry<String, String> entry : this.properties.entrySet () )
            {
                xsw.writeStartElement ( "property" );
                xsw.writeAttribute ( "name", entry.getKey () );
                if ( entry.getValue () != null )
                {
                    xsw.writeAttribute ( "value", entry.getValue () );
                }
                xsw.writeEndElement ();
            }

            xsw.writeEndElement (); // properties
        }

        {
            xsw.writeStartElement ( "provides" );
            xsw.writeAttribute ( "size", Integer.toString ( this.provides.size () ) );

            for ( final Entry<String> entry : this.provides )
            {
                xsw.writeStartElement ( "provided" );
                xsw.writeAttribute ( "namespace", entry.getNamespace () );
                xsw.writeAttribute ( "name", entry.getKey () );
                xsw.writeAttribute ( "version", entry.getValue () );
                xsw.writeEndElement ();
            }

            xsw.writeEndElement (); // provides
        }

        {
            xsw.writeStartElement ( "requires" );
            xsw.writeAttribute ( "size", Integer.toString ( this.requires.size () ) );

            for ( final Entry<Requirement> entry : this.requires )
            {
                xsw.writeStartElement ( "required" );

                xsw.writeAttribute ( "namespace", entry.getNamespace () );
                xsw.writeAttribute ( "name", entry.getKey () );
                xsw.writeAttribute ( "range", makeString ( entry.getValue ().getRange () ) );

                if ( entry.getValue ().isOptional () )
                {
                    xsw.writeAttribute ( "optional", "true" );

                }
                if ( entry.getValue ().getGreedy () != null )
                {
                    xsw.writeAttribute ( "greedy", "" + entry.getValue ().getGreedy () );
                }

                final String filterString = entry.getValue ().getFilter ();
                if ( filterString != null && !filterString.isEmpty () )
                {
                    xsw.writeStartElement ( "filter" );
                    xsw.writeCharacters ( entry.getValue ().getFilter () );
                    xsw.writeEndElement (); // filter
                }

                xsw.writeEndElement (); // required
            }

            xsw.writeEndElement (); // requires
        }

        {
            if ( this.filter != null && !this.filter.isEmpty () )
            {
                xsw.writeStartElement ( "filter" );
                xsw.writeCharacters ( this.filter );
                xsw.writeEndElement (); // filter
            }
        }

        if ( !this.artifacts.isEmpty () )
        {
            xsw.writeStartElement ( "artifacts" );
            xsw.writeAttribute ( "size", Integer.toString ( this.artifacts.size () ) );

            for ( final Artifact artifact : this.artifacts )
            {
                xsw.writeEmptyElement ( "artifact" );
                xsw.writeAttribute ( "classifier", artifact.getClassifer () );
                xsw.writeAttribute ( "id", artifact.getId () );
                xsw.writeAttribute ( "version", "" + artifact.getVersion () );
            }

            xsw.writeEndElement (); // artifacts
        }

        {
            if ( this.touchpoints.isEmpty () )
            {
                xsw.writeEmptyElement ( "touchpoint" );
                xsw.writeAttribute ( "id", "null" );
                xsw.writeAttribute ( "version", "0.0.0" );
            }
            else
            {
                for ( final Touchpoint tp : this.touchpoints )
                {
                    xsw.writeEmptyElement ( "touchpoint" );
                    xsw.writeAttribute ( "id", tp.getId () );
                    xsw.writeAttribute ( "version", tp.getVersion () );

                    if ( !tp.getInstructions ().isEmpty () )
                    {
                        xsw.writeStartElement ( "touchpointData" );
                        xsw.writeAttribute ( "size", "1" );

                        xsw.writeStartElement ( "instructions" );
                        xsw.writeAttribute ( "size", Integer.toString ( tp.getInstructions ().size () ) );

                        for ( final Map.Entry<String, String> entry : tp.getInstructions ().entrySet () )
                        {
                            xsw.writeStartElement ( "instruction" );
                            xsw.writeAttribute ( "key", entry.getKey () );
                            xsw.writeCharacters ( entry.getValue () );
                            xsw.writeEndElement (); // instruction
                        }

                        xsw.writeEndElement (); // instructions
                        xsw.writeEndElement (); // touchpointData
                    }
                }
            }
        }

        {
            xsw.writeStartElement ( "licenses" );
            xsw.writeAttribute ( "size", Integer.toString ( this.licenses.size () ) );

            for ( final License licenseEntry : this.licenses )
            {
                xsw.writeStartElement ( "license" );

                if ( licenseEntry.getUri () != null )
                {
                    xsw.writeAttribute ( "url", licenseEntry.getUri () );
                    xsw.writeAttribute ( "uri", licenseEntry.getUri () );
                }

                if ( licenseEntry.getText () != null )
                {
                    xsw.writeCData ( licenseEntry.getText () );
                }

                xsw.writeEndElement (); // license
            }

            xsw.writeEndElement (); // licenses
        }

        if ( this.copyright != null || this.copyrightUrl != null )
        {
            xsw.writeStartElement ( "copyright" );

            if ( this.copyrightUrl != null )
            {
                xsw.writeAttribute ( "url", this.copyrightUrl );
                xsw.writeAttribute ( "uri", this.copyrightUrl );
            }
            if ( this.copyright != null )
            {
                xsw.writeCData ( this.copyright );
            }
            xsw.writeEndElement ();
        }

        xsw.writeEndElement (); // unit
    }
Write the unit as XML fragment

@param xsw
the XMLStreamWriter to write to
@throws XMLStreamException
if the underlying throws it