// Path: src/main/java/org/apache/jena/grande/NodeEncoder.java
// public class NodeEncoder {
// 
// 	private static final PrefixMap emptyPrefixMap = new PrefixMap();
// 	
// 	public static String asString(Node node) {
//         StringWriter sw = new StringWriter() ;
//         NodeFmtLib.serialize(sw, node, null, emptyPrefixMap);
//         return sw.toString() ; 
// 	}
// 	
// 	public static String asString(Node node, PrefixMap prefixMap) {
//         StringWriter sw = new StringWriter() ;
//         NodeFmtLib.serialize(sw, node, null, prefixMap);
//         return sw.toString() ; 
// 	}
// 
// 	public static Node asNode(String str) {
// 		return NodeFactory.parseNode(str);
// 	}
// 
// }


import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
import java.util.List;
import org.apache.jena.grande.NodeEncoder;
import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.graph.Triple;
import com.hp.hpl.jena.sparql.algebra.OpVisitorBase;
import com.hp.hpl.jena.sparql.algebra.op.OpBGP;
import com.hp.hpl.jena.util.FileUtils;
        		if (!triple.getPredicate().isVariable()) {
        			if ( first ) {
            			filter = "FILTER dataset BY ";
        			} else {
        				filter = filter.concat(" AND ") ;
        			}
        			filter = filter.concat("( p == '" + out(triple.getPredicate()) + "' )");
        			first = false;        			
        		}

        		if (!triple.getObject().isVariable()) {
        			if ( first ) {
            			filter = "FILTER dataset BY ";
        			} else {
        				filter = filter.concat(" AND ") ;
        			}
        			filter = filter.concat("( o == '" + out(triple.getObject()) + "' )");
        			first = false;
        		}
        		
        		if (filter != null) {
        			out.write(filter);
        		}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
    }

    private String out(Node node) {
// Path: src/main/java/org/apache/jena/grande/NodeEncoder.java
// public class NodeEncoder {
// 
// 	private static final PrefixMap emptyPrefixMap = new PrefixMap();
// 	
// 	public static String asString(Node node) {
//         StringWriter sw = new StringWriter() ;
//         NodeFmtLib.serialize(sw, node, null, emptyPrefixMap);
//         return sw.toString() ; 
// 	}
// 	
// 	public static String asString(Node node, PrefixMap prefixMap) {
//         StringWriter sw = new StringWriter() ;
//         NodeFmtLib.serialize(sw, node, null, prefixMap);
//         return sw.toString() ; 
// 	}
// 
// 	public static Node asNode(String str) {
// 		return NodeFactory.parseNode(str);
// 	}
// 
// }


// Path: src/main/java/org/apache/jena/grande/pig/Sparql2PigLatinWriter.java
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
import java.util.List;
import org.apache.jena.grande.NodeEncoder;
import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.graph.Triple;
import com.hp.hpl.jena.sparql.algebra.OpVisitorBase;
import com.hp.hpl.jena.sparql.algebra.op.OpBGP;
import com.hp.hpl.jena.util.FileUtils;

        		if (!triple.getPredicate().isVariable()) {
        			if ( first ) {
            			filter = "FILTER dataset BY ";
        			} else {
        				filter = filter.concat(" AND ") ;
        			}
        			filter = filter.concat("( p == '" + out(triple.getPredicate()) + "' )");
        			first = false;        			
        		}

        		if (!triple.getObject().isVariable()) {
        			if ( first ) {
            			filter = "FILTER dataset BY ";
        			} else {
        				filter = filter.concat(" AND ") ;
        			}
        			filter = filter.concat("( o == '" + out(triple.getObject()) + "' )");
        			first = false;
        		}
        		
        		if (filter != null) {
        			out.write(filter);
        		}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
    }

    private String out(Node node) {
    	return NodeEncoder.asString(node);