}
private void writeExpression(final Expression expression)
throws IOException
{
final XmlWriter writer = getXmlWriter();
if (expression instanceof FormulaExpression)
{
final FormulaExpression fe = (FormulaExpression) expression;
final AttributeList properties = new AttributeList();
if (expression.getName() != null)
{
properties.setAttribute(ExtParserModule.NAMESPACE, "name", expression.getName());
}
properties.setAttribute(ExtParserModule.NAMESPACE, "formula", fe.getFormula());
if (expression.getDependencyLevel() > 0)
{
properties.setAttribute(ExtParserModule.NAMESPACE, "deplevel", String.valueOf(
expression.getDependencyLevel()));
}
writer.writeTag(ExtParserModule.NAMESPACE, FunctionsWriter.EXPRESSION_TAG, properties, XmlWriterSupport.CLOSE);
return;
}
if (expression instanceof FormulaFunction)
{
final FormulaFunction fe = (FormulaFunction) expression;
final AttributeList properties = new AttributeList();
if (expression.getName() != null)
{
properties.setAttribute(ExtParserModule.NAMESPACE, "name", expression.getName());
}
properties.setAttribute(ExtParserModule.NAMESPACE, "formula", fe.getFormula());
properties.setAttribute(ExtParserModule.NAMESPACE, "initial", fe.getInitial());
if (expression.getDependencyLevel() > 0)
{
properties.setAttribute(ExtParserModule.NAMESPACE, "deplevel", String.valueOf(
expression.getDependencyLevel()));
}
writer.writeTag(ExtParserModule.NAMESPACE, FunctionsWriter.EXPRESSION_TAG, properties, XmlWriterSupport.CLOSE);
return;
}
try
{
final BeanUtility bu = new BeanUtility(expression);
final String[] propertyNames = bu.getProperties();
if (propertyNames.length == 0)
{
final AttributeList properties = new AttributeList();
if (expression.getName() != null)
{
properties.setAttribute(ExtParserModule.NAMESPACE, "name", expression.getName());
}
properties.setAttribute(ExtParserModule.NAMESPACE, "class", expression.getClass().getName());
if (expression.getDependencyLevel() > 0)
{
properties.setAttribute(ExtParserModule.NAMESPACE, "deplevel", String.valueOf(
expression.getDependencyLevel()));
}
writer.writeTag(ExtParserModule.NAMESPACE, FunctionsWriter.EXPRESSION_TAG, properties, XmlWriterSupport.CLOSE);
}
else
{
final AttributeList properties = new AttributeList();
if (expression.getName() != null)
{
properties.setAttribute(ExtParserModule.NAMESPACE, "name", expression.getName());
}
properties.setAttribute(ExtParserModule.NAMESPACE, "class", expression.getClass().getName());
if (expression.getDependencyLevel() > 0)
{
properties.setAttribute(ExtParserModule.NAMESPACE, "deplevel", String.valueOf(
expression.getDependencyLevel()));
}
writer.writeTag(ExtParserModule.NAMESPACE, FunctionsWriter.EXPRESSION_TAG, properties, XmlWriterSupport.OPEN);
writeExpressionParameters(propertyNames, bu);
writer.writeCloseTag();
}
}
catch (Exception e)
{