org.modelcc.io.log.MessageLogger Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ModelCC Show documentation
Show all versions of ModelCC Show documentation
ModelCC is a model-based parser generator (a.k.a. compiler compiler) that decouples language specification from language processing, avoiding some of the problems caused by grammar-driven parser generators. ModelCC receives a conceptual model as input, along with constraints that annotate it. It is then able to create a parser for the desired textual language and the generated parser fully automates the instantiation of the language conceptual model. ModelCC also includes a built-in reference resolution mechanism that results in abstract syntax graphs, rather than mere abstract syntax trees.
The newest version!
/*
* ModelCC, distributed under ModelCC Shared Software License, www.modelcc.org
*/
package org.modelcc.io.log;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
/**
* Message logger.
*
* @author Fernando Berzal ([email protected])
*/
public class MessageLogger extends Logger
{
/**
* Message list.
*/
private List messages;
/**
* Constructor.
*/
public MessageLogger()
{
super("org.modelcc",null);
messages = new ArrayList();
}
/**
* Log message.
*/
@Override
public void log (LogRecord record)
{
Message message = new Message (
record.getLevel(),
record.getSourceClassName(),
MessageFormat.format(record.getMessage(), record.getParameters()),
record.getThrown() );
messages.add(message);
}
/**
* Clear the message list
*/
public void clear ()
{
messages.clear();
}
/**
* Get the message list.
* @return the message list
*/
public List getMessages ()
{
return messages;
}
/**
* Get message count.
* @return Number of messages in the message list
*/
public int getMessageCount ()
{
return messages.size();
}
/**
* Get message.
* @param index Message index
* @return the desired message
*/
public Message getMessage (int index)
{
return messages.get(index);
}
}