Search in sources :

Example 1 with ParserException

use of ch.ethz.iks.slp.impl.attr.gen.ParserException in project ecf by eclipse.

the class SLPMessage method attributeStringToList.

/**
 * @param input
 * @return
 * @throws ServiceLocationException
 *
 * @author Markus Alexander Kuppe
 * @since 1.1
 */
protected List attributeStringToList(String input) throws ServiceLocationException {
    if ("".equals(input)) {
        return new ArrayList();
    }
    Parser parser = new Parser();
    try {
        Rule parse = parser.parse("attr-list", input);
        AttributeListVisitor visitor = new AttributeListVisitor();
        parse.visit(visitor);
        return visitor.getAttributes();
    } catch (IllegalArgumentException e) {
        throw new ServiceLocationException(ServiceLocationException.PARSE_ERROR, e.getMessage());
    } catch (ParserException e) {
        throw new ServiceLocationException(ServiceLocationException.PARSE_ERROR, e.getMessage());
    }
}
Also used : AttributeListVisitor(ch.ethz.iks.slp.impl.attr.AttributeListVisitor) ParserException(ch.ethz.iks.slp.impl.attr.gen.ParserException) ArrayList(java.util.ArrayList) Rule(ch.ethz.iks.slp.impl.attr.gen.Rule) Parser(ch.ethz.iks.slp.impl.attr.gen.Parser) ServiceLocationException(ch.ethz.iks.slp.ServiceLocationException)

Example 2 with ParserException

use of ch.ethz.iks.slp.impl.attr.gen.ParserException in project ecf by eclipse.

the class SLPMessage method attributeStringToListLiberal.

/**
 * @param input
 * @return
 * @throws ServiceLocationException
 *
 * @author Markus Alexander Kuppe
 * @since 1.1
 */
protected List attributeStringToListLiberal(String input) {
    if ("".equals(input)) {
        return new ArrayList();
    }
    Parser parser = new Parser();
    Rule rule = null;
    try {
        rule = parser.parse("attr-list", input);
    } catch (IllegalArgumentException e) {
        SLPCore.platform.logError(e.getMessage(), e);
        return new ArrayList();
    // may never happen!!!
    } catch (ParserException e) {
        SLPCore.platform.logTraceDrop(e.getMessage());
        rule = e.getRule();
    }
    AttributeListVisitor visitor = new AttributeListVisitor();
    rule.visit(visitor);
    return visitor.getAttributes();
}
Also used : ParserException(ch.ethz.iks.slp.impl.attr.gen.ParserException) AttributeListVisitor(ch.ethz.iks.slp.impl.attr.AttributeListVisitor) ArrayList(java.util.ArrayList) Rule(ch.ethz.iks.slp.impl.attr.gen.Rule) Parser(ch.ethz.iks.slp.impl.attr.gen.Parser)

Aggregations

AttributeListVisitor (ch.ethz.iks.slp.impl.attr.AttributeListVisitor)2 Parser (ch.ethz.iks.slp.impl.attr.gen.Parser)2 ParserException (ch.ethz.iks.slp.impl.attr.gen.ParserException)2 Rule (ch.ethz.iks.slp.impl.attr.gen.Rule)2 ArrayList (java.util.ArrayList)2 ServiceLocationException (ch.ethz.iks.slp.ServiceLocationException)1