/*
(c) Copyright 2008, 2009 Hewlett-Packard Development Company, LP
All rights reserved.
$Id$
*/
/*
(c) Copyright 2008 Hewlett-Packard Development Company, LP
All rights reserved.
$Id$
*/
package com.hp.jena3.rules.grammar.tests;
import java.io.StringReader;
import java.util.*;
import com.hp.jena.rules.ast.StringInLanguage;
import com.hp.jena3.rules.grammar.JenaRules;
public class Utils
{
public static JenaRules parserOn( String text )
{ return new JenaRules( new StringReader( text ) ); }
public static List<StringInLanguage> labels( String s )
{
List<StringInLanguage> result = new ArrayList<StringInLanguage>();
if (s.length() > 0)
for (String label: s.split( " +" )) result.add( stringInLanguage( label ) );
return result;
}
public static StringInLanguage stringInLanguage( String label )
{
int atPos = label.indexOf( '@' );
return atPos < 0
? new StringInLanguage( label )
: new StringInLanguage( label.substring( 0, atPos ), label.substring( atPos + 1 ) ) ;
}
}