InputStream is = portletContext.getResourceAsStream("/WEB-INF/portlet.xml");
if (is != null)
{
try
{
XmlPullParser parser = new XmlPullParser();
parser.parse(is);
while (true)
{
XmlTag elem;
String name;
int level;
do
{
elem = (XmlTag)parser.nextTag();
}
while (elem != null && (!(elem.getName().equals("portlet") && elem.isOpen())));
if (elem == null)
{
break;
}
String description = null;
String filterPath = null;
String filterQuery = null;
String displayName = null;
HashMap initParameters = new HashMap();
level = 0;
do
{
elem = (XmlTag)parser.nextTag();
name = elem.getName();
level = elem.isOpen() ? (level + 1) : (level - 1);
if (level == 1)
{
if (name.equals("description") || name.equals("display-name"))
{
parser.setPositionMarker();
}
else if (name.equals("init-param"))
{
String initParamName = null;
String initParamValue = null;
do
{
elem = (XmlTag)parser.nextTag();
name = elem.getName();
level = elem.isOpen() ? (level + 1) : (level - 1);
if (level == 2)
{
if (name.equals("name") || name.equals("value"))
{
parser.setPositionMarker();
}
}
else if (level == 1)
{
if (name.equals("name"))
{
initParamName = parser.getInputFromPositionMarker(
elem.getPos()).toString();
}
else if (name.equals("value"))
{
initParamValue = parser.getInputFromPositionMarker(
elem.getPos()).toString();
}
}
}
while (level > 0);
if (initParamName != null && initParamValue != null)
{
initParameters.put(initParamName, initParamValue);
}
}
}
else if (level == 0)
{
if (name.equals("description"))
{
description = parser.getInputFromPositionMarker(elem.getPos())
.toString();
}
else if (name.equals("display-name"))
{
displayName = parser.getInputFromPositionMarker(elem.getPos())
.toString();
}
}
}
while (level > -1);