00001 //tabstop=4 00002 //*****************************************************************************/ 00003 // Project: jpl 00004 // 00005 // File: $Id$ 00006 // Date: $Date$ 00007 // Author: Fred Dushin <fadushin@syr.edu> 00008 // Author: Paul Singleton <paul@jbgb.com> 00009 // 00010 // 00011 // Description: 00012 // 00013 // 00014 // ------------------------------------------------------------------------- 00015 // Copyright (c) 2004 Paul Singleton 00016 // Copyright (c) 1998 Fred Dushin 00017 // All rights reserved. 00018 // 00019 // This library is free software; you can redistribute it and/or 00020 // modify it under the terms of the GNU Library Public License 00021 // as published by the Free Software Foundation; either version 2 00022 // of the License, or (at your option) any later version. 00023 // 00024 // This library is distributed in the hope that it will be useful, 00025 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00026 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00027 // GNU Library Public License for more details. 00028 //*****************************************************************************/ 00029 package jpl; 00030 00031 import java.util.Map; 00032 00033 import jpl.fli.Prolog; 00034 import jpl.fli.StringHolder; 00035 import jpl.fli.term_t; 00036 00037 //----------------------------------------------------------------------/ 00038 // Atom 00065 public class Atom extends Compound { 00066 00067 //==================================================================/ 00068 // Attributes (none) 00069 //==================================================================/ 00070 00071 //==================================================================/ 00072 // Constructors 00073 //==================================================================/ 00074 00078 public Atom(String name) { 00079 super(name); 00080 } 00081 00082 //==================================================================/ 00083 // Methods (common) 00084 //==================================================================/ 00085 00086 // these are all inherited from Compound 00087 00088 public final int type() { 00089 return Prolog.ATOM; 00090 } 00091 00097 public String typeName() { // overrides same in jpl.Term 00098 return "Atom"; 00099 } 00100 00101 public Object jrefToObject() { 00102 throw new JPLException("Atom.jrefToObject: term is not a JRef"); 00103 } 00104 //==================================================================/ 00105 // Methods (deprecated) 00106 //==================================================================/ 00107 00114 public String debugString() { 00115 return "(Atom " + toString() + ")"; 00116 } 00117 00118 //==================================================================/ 00119 // Converting JPL Terms to Prolog terms 00120 //==================================================================/ 00121 00122 // (this is done with the put() method inherited from Compound) 00123 00124 //==================================================================/ 00125 // Converting Prolog terms to JPL Terms 00126 //==================================================================/ 00127 00137 protected static Term getTerm1(Map vars_to_Vars, term_t term) { 00138 StringHolder holder = new StringHolder(); 00139 Prolog.get_atom_chars(term, holder); // ignore return val; assume success... 00140 00141 return new Atom(holder.value); 00142 } 00143 00155 protected static Term getString(Map vars_to_Vars, term_t term) { 00156 StringHolder holder = new StringHolder(); 00157 Prolog.get_string_chars(term, holder); // ignore return val; assume success... 00158 return new Atom(holder.value); 00159 } 00160 00161 //==================================================================/ 00162 // Computing substitutions 00163 //==================================================================/ 00164 00165 // (done with the inherited Compound.getSubst() method) 00166 00167 } 00168 00169 //345678901234567890123456789012346578901234567890123456789012345678901234567890