1// BEGIN LICENSE BLOCK 2// Version: CMPL 1.1 3// 4// The contents of this file are subject to the Cisco-style Mozilla Public 5// License Version 1.1 (the "License"); you may not use this file except 6// in compliance with the License. You may obtain a copy of the License 7// at www.eclipse-clp.org/license. 8// 9// Software distributed under the License is distributed on an "AS IS" 10// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 11// the License for the specific language governing rights and limitations 12// under the License. 13// 14// The Original Code is The ECLiPSe Constraint Logic Programming System. 15// The Initial Developer of the Original Code is Cisco Systems, Inc. 16// Portions created by the Initial Developer are 17// Copyright (C) 2001 - 2006 Cisco Systems, Inc. All Rights Reserved. 18// 19// Contributor(s): Josh Singer, Parc Technologies 20// 21// END LICENSE BLOCK 22 23//Title: Java/ECLiPSe interface 24//Version: $Id: DataExample1.java,v 1.1 2006/09/23 01:54:12 snovello Exp $ 25//Author: Josh Singer 26//Company: Parc Technologies 27//Description: Java/ECLiPSe Interface example Java program 28import com.parctechnologies.eclipse.*; 29import java.io.*; 30 31public class DataExample1 32{ 33 public static void main(String[] args) throws Exception 34 { 35 // Create some default Eclipse options 36 EclipseEngineOptions eclipseEngineOptions = new EclipseEngineOptions(); 37 38 // Object representing the Eclipse process 39 EclipseEngine eclipse; 40 41 // Connect the Eclipse's standard streams to the JVM's 42 eclipseEngineOptions.setUseQueues(false); 43 44 // Initialise Eclipse 45 eclipse = EmbeddedEclipse.getInstance(eclipseEngineOptions); 46 47 // Construct a term 48 CompoundTerm a_term = construct_term(); 49 50 // Get Eclipse to write the term to stdout and flush 51 eclipse.rpc( 52 new CompoundTermImpl(",", 53 new CompoundTermImpl("write", 54 new Atom("output"), a_term), 55 new CompoundTermImpl("flush", new Atom("output")) 56 ) 57 ); 58 59 // Destroy the Eclipse 60 ((EmbeddedEclipse) eclipse).destroy(); 61 } 62 63 // Construct a term in Java to represent the Eclipse term foo(a, b, 3). 64 private static CompoundTerm construct_term() 65 { 66 Atom a = new Atom("a"); 67 Atom b = new Atom("b"); 68 Integer numberThree = new Integer(3); 69 CompoundTerm theTerm = new CompoundTermImpl("foo", a, b, numberThree); 70 71 return(theTerm); 72 } 73 74} 75 76