Package com.hp.jena3.rules.grammar.tests

Source Code of com.hp.jena3.rules.grammar.tests.Utils

/*
  (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 + ) )            ;
        }

    }
TOP

Related Classes of com.hp.jena3.rules.grammar.tests.Utils

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.