Package net.fortytwo.ripple.libs.graph

Source Code of net.fortytwo.ripple.libs.graph.New

package net.fortytwo.ripple.libs.graph;

import net.fortytwo.flow.Sink;
import net.fortytwo.ripple.RippleException;
import net.fortytwo.ripple.model.ModelConnection;
import net.fortytwo.ripple.model.PrimitiveStackMapping;
import net.fortytwo.ripple.model.RippleList;
import net.fortytwo.ripple.util.ModelConnectionHelper;

/**
* A primitive which produces a new blank node.
*
* @author Joshua Shinavier (http://fortytwo.net)
*/
public class New extends PrimitiveStackMapping {
    private static final String[] IDENTIFIERS = {
            GraphLibrary.NS_2013_03 + "new",
            GraphLibrary.NS_2008_08 + "new",
            GraphLibrary.NS_2007_08 + "new",
            GraphLibrary.NS_2007_05 + "new"};

    public String[] getIdentifiers() {
        return IDENTIFIERS;
    }

    public New()
            throws RippleException {
        super();
    }

    public Parameter[] getParameters() {
        return new Parameter[]{};
    }

    public String getComment() {
        return "n  -- where n is a new blank node";
    }

    public void apply(final RippleList arg,
                      final Sink<RippleList> solutions,
                      final ModelConnection mc) throws RippleException {

        RippleList stack = arg;

        // Note: stack may be null (and this should not be a problem).
        RippleList result = stack.push(
                new ModelConnectionHelper(mc).createRandomURI());
//System.out.println( "Creating a new node" );

        solutions.put(result);
    }
}
TOP

Related Classes of net.fortytwo.ripple.libs.graph.New

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.