* @param parser
*/
private Metadata parseMetadata(String tagName, XmlPullParser parser, boolean strict, String encoding)
throws IOException, XmlPullParserException
{
Metadata metadata = new Metadata();
metadata.setModelEncoding( encoding );
java.util.Set parsed = new java.util.HashSet();
int eventType = parser.getEventType();
boolean foundRoot = false;
while ( eventType != XmlPullParser.END_DOCUMENT )
{
if ( eventType == XmlPullParser.START_TAG )
{
if ( parser.getName().equals( tagName ) )
{
foundRoot = true;
}
else if ( parser.getName().equals( "groupId" ) )
{
if ( parsed.contains( "groupId" ) )
{
throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
}
parsed.add( "groupId" );
metadata.setGroupId( getTrimmedValue( parser.nextText()) );
}
else if ( parser.getName().equals( "artifactId" ) )
{
if ( parsed.contains( "artifactId" ) )
{
throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
}
parsed.add( "artifactId" );
metadata.setArtifactId( getTrimmedValue( parser.nextText()) );
}
else if ( parser.getName().equals( "version" ) )
{
if ( parsed.contains( "version" ) )
{
throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
}
parsed.add( "version" );
metadata.setVersion( getTrimmedValue( parser.nextText()) );
}
else if ( parser.getName().equals( "versioning" ) )
{
if ( parsed.contains( "versioning" ) )
{
throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
}
parsed.add( "versioning" );
metadata.setVersioning( parseVersioning( "versioning", parser, strict, encoding ) );
}
else if ( parser.getName().equals( "plugins" ) )
{
if ( parsed.contains( "plugins" ) )
{
throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
}
parsed.add( "plugins" );
java.util.List plugins = new java.util.ArrayList();
metadata.setPlugins( plugins );
while ( parser.nextTag() == XmlPullParser.START_TAG )
{
if ( parser.getName().equals( "plugin" ) )
{
plugins.add( parsePlugin( "plugin", parser, strict, encoding ) );