use of dr.util.Property in project beast-mcmc by beast-dev.
the class LoggerParser method parseXMLObject.
/**
* @return an object based on the XML element it was passed.
*/
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
// You must say how often you want to log
final int logEvery = xo.getIntegerAttribute(LOG_EVERY);
final PrintWriter pw = getLogFile(xo, getParserName());
final LogFormatter formatter = new TabDelimitedFormatter(pw);
boolean performanceReport = false;
if (!xo.hasAttribute(FILE_NAME)) {
// is a screen log
performanceReport = true;
}
// added a performance measurement delay to avoid the full evaluation period.
final MCLogger logger = new MCLogger(formatter, logEvery, performanceReport, 10000);
String title = null;
if (xo.hasAttribute(TITLE)) {
title = xo.getStringAttribute(TITLE);
}
String header = null;
if (xo.hasAttribute(HEADER)) {
header = xo.getStringAttribute(HEADER);
}
if (title == null) {
final BeastVersion version = new BeastVersion();
title = "BEAST " + version.getVersionString() + "\n" + (header != null ? header + "\n" : "") + "Generated " + (new Date()).toString() + " [seed=" + MathUtils.getSeed() + "]\n" + System.getProperty("command_line", "");
} else {
if (header != null) {
title += "\n" + header;
}
}
logger.setTitle(title);
for (int i = 0; i < xo.getChildCount(); i++) {
final Object child = xo.getChild(i);
if (child instanceof Columns) {
logger.addColumns(((Columns) child).getColumns());
} else if (child instanceof Loggable) {
logger.add((Loggable) child);
} else if (child instanceof Identifiable) {
logger.addColumn(new LogColumn.Default(((Identifiable) child).getId(), child));
} else if (child instanceof Property) {
logger.addColumn(new LogColumn.Default(((Property) child).getAttributeName(), child));
} else {
logger.addColumn(new LogColumn.Default(child.getClass().toString(), child));
}
}
return logger;
}
use of dr.util.Property in project beast-mcmc by beast-dev.
the class PropertyParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Object object = xo.getChild(0);
String name = xo.getStringAttribute("name");
Property property;
if (xo.hasAttribute("index")) {
int index = xo.getIntegerAttribute("index");
property = new Property(object, name, index);
} else if (xo.hasAttribute("label")) {
String label = xo.getStringAttribute("label");
property = new Property(object, name, label);
} else {
property = new Property(object, name);
}
if (property.getGetter() == null)
throw new XMLParseException("unknown property, " + name + ", for object, " + object + ", in property element");
return property;
}
Aggregations