* @return Metadata
*/
private Metadata parseMetadata( String tagName, XmlPullParser parser, boolean strict )
throws IOException, XmlPullParserException
{
Metadata metadata = new Metadata();
java.util.Set parsed = new java.util.HashSet();
int eventType = parser.getEventType();
boolean foundRoot = false;
metadata.setModelEncoding( parser.getInputEncoding() );
while ( eventType != XmlPullParser.END_DOCUMENT )
{
if ( eventType == XmlPullParser.START_TAG )
{
if ( parser.getName().equals( tagName ) )
{
foundRoot = true;
}
else if ( strict && ! foundRoot )
{
throw new XmlPullParserException( "Expected root element '" + tagName + "' but found '" + parser.getName() + "'", parser, null );
}
else if ( checkFieldWithDuplicate( parser, "groupId", null, parsed ) )
{
metadata.setGroupId( getTrimmedValue( parser.nextText() ) );
}
else if ( checkFieldWithDuplicate( parser, "artifactId", null, parsed ) )
{
metadata.setArtifactId( getTrimmedValue( parser.nextText() ) );
}
else if ( checkFieldWithDuplicate( parser, "version", null, parsed ) )
{
metadata.setVersion( getTrimmedValue( parser.nextText() ) );
}
else if ( checkFieldWithDuplicate( parser, "versioning", null, parsed ) )
{
metadata.setVersioning( parseVersioning( "versioning", parser, strict ) );
}
else if ( checkFieldWithDuplicate( parser, "plugins", null, parsed ) )
{
java.util.List plugins = new java.util.ArrayList/*<Plugin>*/();
metadata.setPlugins( plugins );
while ( parser.nextTag() == XmlPullParser.START_TAG )
{
if ( parser.getName().equals( "plugin" ) )
{
plugins.add( parsePlugin( "plugin", parser, strict ) );