* @return BobberArchetype
*/
private BobberArchetype parseBobberArchetype(String tagName, XmlPullParser parser, boolean strict)
throws IOException, XmlPullParserException
{
BobberArchetype bobberArchetype = new BobberArchetype();
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( "id" ) )
{
if ( parsed.contains( "id" ) )
{
throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null );
}
parsed.add( "id" );
bobberArchetype.setId( getTrimmedValue( parser.nextText()) );
}
else if ( parser.getName().equals( "allowPartial" ) )
{
if ( parsed.contains( "allowPartial" ) )
{
throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null );
}
parsed.add( "allowPartial" );
bobberArchetype.setAllowPartial( getBooleanValue( getTrimmedValue( parser.nextText()), "allowPartial", parser, "false" ) );
}
else if ( parser.getName().equals( "variables" ) )
{
if ( parsed.contains( "variables" ) )
{
throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null );
}
parsed.add( "variables" );
java.util.List variables = new java.util.ArrayList();
bobberArchetype.setVariables( variables );
while ( parser.nextTag() == XmlPullParser.START_TAG )
{
if ( parser.getName().equals( "variable" ) )
{
variables.add( parseVariable( "variable", parser, strict ) );
}
else if ( strict )
{
throw new XmlPullParserException( "Unrecognised association: '" + parser.getName() + "'", parser, null );
}
else
{
// swallow up to end tag since this is not valid
while ( parser.next() != XmlPullParser.END_TAG ) {}
}
}
}
else if ( parser.getName().equals( "templates" ) )
{
if ( parsed.contains( "templates" ) )
{
throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null );
}
parsed.add( "templates" );
java.util.List templates = new java.util.ArrayList();
bobberArchetype.setTemplates( templates );
while ( parser.nextTag() == XmlPullParser.START_TAG )
{
if ( parser.getName().equals( "template" ) )
{
templates.add( parseTemplate( "template", parser, strict ) );