// En vez de ITerm Clone() voy a poner object Clone() public override object Clone() { Literal l = new LiteralImpl(this); l.hashCodeCache = hashCodeCache; return(l); }
/** creates a literal from a list with four elements: [namespace, functor, list of terms, list of annots] * (namespace is optional) */ public static Literal NewFromListOfTerms(IListTerm lt) { try { System.Collections.Generic.IEnumerator <ITerm> i = lt.GetEnumerator(); Atom ns = DefaultNS; if (lt.Count == 4) { ns = i.Current as Atom; } ITerm tFunctor = i.Current; bool pos = Literal.LPos; if (tFunctor.IsLiteral() && (tFunctor as Literal).Negated()) { pos = Literal.LNeg; } if (tFunctor.IsString()) { tFunctor = AsSyntax.ParseTerm((tFunctor as IStringTerm).GetString()); } Literal l = new LiteralImpl(ns, pos, (tFunctor as Atom).GetFunctor()); if (i.Current != null) { //l.SetTerms((i.Current as IListTerm).CloneLT()); return(null); } if (i.Current != null) { l.SetAnnots((i.Current as IListTerm).CloneLT()); } return(l); } catch (Exception) { throw new JasonityException("Error creating literal from" + lt); } }
public override bool Equals(object o) { if (o == null) { return(false); } if (o == this) { return(true); } if (o.GetType() == typeof(LiteralImpl)) { LiteralImpl l = (LiteralImpl)o; return(type == l.type && GetHashCode() == l.GetHashCode() && base.Equals(l)); } else if (o.GetType() == typeof(Atom) && !Negated()) { return(base.Equals(o)); } return(false); }