* @param parser
*/
private Expression parseExpression(String tagName, XmlPullParser parser, boolean strict, String encoding)
throws IOException, XmlPullParserException
{
Expression expression = new Expression();
expression.setModelEncoding( encoding );
java.util.Set parsed = new java.util.HashSet();
while ( parser.nextTag() == XmlPullParser.START_TAG )
{
if ( parser.getName().equals( "syntax" ) )
{
if ( parsed.contains( "syntax" ) )
{
throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
}
parsed.add( "syntax" );
expression.setSyntax( getTrimmedValue( parser.nextText()) );
}
else if ( parser.getName().equals( "description" ) )
{
if ( parsed.contains( "description" ) )
{
throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
}
parsed.add( "description" );
expression.setDescription( getTrimmedValue( parser.nextText()) );
}
else if ( parser.getName().equals( "configuration" ) )
{
if ( parsed.contains( "configuration" ) )
{
throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
}
parsed.add( "configuration" );
expression.setConfiguration( getTrimmedValue( parser.nextText()) );
}
else if ( parser.getName().equals( "cliOptions" ) )
{
if ( parsed.contains( "cliOptions" ) )
{
throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
}
parsed.add( "cliOptions" );
while ( parser.nextTag() == XmlPullParser.START_TAG )
{
if ( parser.getName().equals( "cliOption" ) )
{
String key = null;
String value = null;
//explode mode.
while ( parser.nextTag() == XmlPullParser.START_TAG )
{
if ( parser.getName().equals( "key" ) )
{
key = parser.nextText();
}
else if ( parser.getName().equals( "value" ) )
{
value = parser.nextText()
.trim()
;
}
else
{
parser.nextText();
}
}
expression.addCliOption( key, value );
}
parser.next();
}
}
else if ( parser.getName().equals( "apiMethods" ) )
{
if ( parsed.contains( "apiMethods" ) )
{
throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
}
parsed.add( "apiMethods" );
while ( parser.nextTag() == XmlPullParser.START_TAG )
{
if ( parser.getName().equals( "apiMethod" ) )
{
String key = null;
String value = null;
//explode mode.
while ( parser.nextTag() == XmlPullParser.START_TAG )
{
if ( parser.getName().equals( "key" ) )
{
key = parser.nextText();
}
else if ( parser.getName().equals( "value" ) )
{
value = parser.nextText()
.trim()
;
}
else
{
parser.nextText();
}
}
expression.addApiMethod( key, value );
}
parser.next();
}
}
else if ( parser.getName().equals( "deprecation" ) )
{
if ( parsed.contains( "deprecation" ) )
{
throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
}
parsed.add( "deprecation" );
expression.setDeprecation( getTrimmedValue( parser.nextText()) );
}
else if ( parser.getName().equals( "ban" ) )
{
if ( parsed.contains( "ban" ) )
{
throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
}
parsed.add( "ban" );
expression.setBan( getTrimmedValue( parser.nextText()) );
}
else if ( parser.getName().equals( "editable" ) )
{
if ( parsed.contains( "editable" ) )
{
throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
}
parsed.add( "editable" );
expression.setEditable( getBooleanValue( getTrimmedValue( parser.nextText()), "editable", parser ) );
}
else
{
if ( strict )
{