Package jp.ac.kobe_u.cs.prolog.lang

Examples of jp.ac.kobe_u.cs.prolog.lang.ExistenceException


    a1 = a1.dereference();
    if (a1.isVariable()) {
      throw new PInstantiationException(this, 1);
    } else if (a1.isSymbol()) {
      if (!engine.getStreamManager().containsKey(a1)) {
        throw new ExistenceException(this, 1, "stream", a1, "");
      }
      stream = ((JavaObjectTerm) engine.getStreamManager().get(a1))
          .object();
    } else if (a1.isJavaObject()) {
      stream = ((JavaObjectTerm) a1).object();
View Full Code Here


    a1 = a1.dereference();
    if (a1.isVariable()) {
      throw new PInstantiationException(this, 1);
    } else if (a1.isSymbol()) {
      if (!engine.getStreamManager().containsKey(a1)) {
        throw new ExistenceException(this, 1, "stream", a1, "");
      }
      stream = ((JavaObjectTerm) engine.getStreamManager().get(a1))
          .object();
    } else if (a1.isJavaObject()) {
      stream = ((JavaObjectTerm) a1).object();
View Full Code Here

    a1 = a1.dereference();
    if (a1.isVariable()) {
      throw new PInstantiationException(this, 1);
    } else if (a1.isSymbol()) {
      if (!engine.getStreamManager().containsKey(a1)) {
        throw new ExistenceException(this, 1, "stream", a1, "");
      }
      stream = ((JavaObjectTerm) engine.getStreamManager().get(a1))
          .object();
    } else if (a1.isJavaObject()) {
      stream = ((JavaObjectTerm) a1).object();
View Full Code Here

    a1 = a1.dereference();
    if (a1.isVariable()) {
      throw new PInstantiationException(this, 1);
    } else if (a1.isSymbol()) {
      if (!engine.getStreamManager().containsKey(a1)) {
        throw new ExistenceException(this, 1, "stream", a1, "");
      }
      stream = ((JavaObjectTerm) engine.getStreamManager().get(a1))
          .object();
    } else if (a1.isJavaObject()) {
      stream = ((JavaObjectTerm) a1).object();
View Full Code Here

      } else if (a2.isStructure()) { // Parameterized method
        methodName = ((StructureTerm) a2).name();
        arity = ((StructureTerm) a2).arity();
        methods = clazz.getMethods();
        if (methods.length == 0) {
          throw new ExistenceException(this, 2, "method", a2, "");
        }
        pArgs = ((StructureTerm) a2).args();
        jArgs = new Object[arity];
        for (int i = 0; i < arity; i++) {
          pArgs[i] = pArgs[i].dereference();
          if (!pArgs[i].isJavaObject()) {
            pArgs[i] = new JavaObjectTerm(pArgs[i]);
          }
          jArgs[i] = pArgs[i].toJava();
        }
        for (Method method : methods) {
          if (method.getName().equals(methodName)
              && checkParameterTypes(method.getParameterTypes(),
                  pArgs)) {
            try {
              m = method;
              // m.setAccessible(true);
              value = m.invoke(instance, jArgs);
              break; // Succeeds to invoke the method
            } catch (Exception e) {
              m = null; // Back to loop
            }
          }
        }
        if (m == null) {
          throw new ExistenceException(this, 2, "method", a2, "");
        }
      } else {
        throw new IllegalTypeException(this, 2, "callable", a2);
      }
      if (value == null) {
View Full Code Here

    a1 = a1.dereference();
    if (a1.isVariable()) {
      throw new PInstantiationException(this, 1);
    } else if (a1.isSymbol()) {
      if (!engine.getHashManager().containsKey(a1)) {
        throw new ExistenceException(this, 1, "hash", a1, "");
      }
      hash = ((JavaObjectTerm) engine.getHashManager().get(a1)).object();
    } else if (a1.isJavaObject()) {
      hash = ((JavaObjectTerm) a1).object();
    } else {
View Full Code Here

      }
      if (a1.isSymbol()) { // No argument constructor
        clazz = Class.forName(((SymbolTerm) a1).name());
        c = clazz.getDeclaredConstructor();
        if (c == null) {
          throw new ExistenceException(this, 1, "constructor", a1, "");
        }
        c.setAccessible(true);
        instance = c.newInstance();
        if (!a2.unify(toPrologTerm(instance), engine.trail)) {
          return engine.fail();
        }
        return cont;
      }
      // Parameterized constructor
      clazz = Class.forName(((StructureTerm) a1).name());
      arity = ((StructureTerm) a1).arity();
      constrs = clazz.getDeclaredConstructors();
      if (constrs.length == 0) {
        throw new ExistenceException(this, 1, "constructor", a1, "");
      }
      pArgs = ((StructureTerm) a1).args();
      jArgs = new Object[arity];
      for (int i = 0; i < arity; i++) {
        pArgs[i] = pArgs[i].dereference();
        if (!pArgs[i].isJavaObject()) {
          pArgs[i] = new JavaObjectTerm(pArgs[i]);
        }
        jArgs[i] = pArgs[i].toJava();
      }
      for (Constructor constr : constrs) {
        if (checkParameterTypes(constr.getParameterTypes(), pArgs)) {
          try {
            c = constr;
            c.setAccessible(true);
            instance = c.newInstance(jArgs);
            break; // Succeeds to create new instance
          } catch (Exception e) {
            c = null; // Back to loop
          }
        }
      }
      if (c == null) {
        throw new ExistenceException(this, 1, "constructor", a1, "");
      }
      if (!a2.unify(toPrologTerm(instance), engine.trail)) {
        return engine.fail();
      }
      return cont;
View Full Code Here

    a1 = a1.dereference();
    if (a1.isVariable()) {
      throw new PInstantiationException(this, 1);
    } else if (a1.isSymbol()) {
      if (!engine.getHashManager().containsKey(a1)) {
        throw new ExistenceException(this, 1, "hash", a1, "");
      }
      hash = ((JavaObjectTerm) engine.getHashManager().get(a1)).object();
    } else if (a1.isJavaObject()) {
      hash = ((JavaObjectTerm) a1).object();
    } else {
View Full Code Here

    a1 = a1.dereference();
    if (a1.isVariable()) {
      throw new PInstantiationException(this, 1);
    } else if (a1.isSymbol()) {
      if (!engine.getStreamManager().containsKey(a1)) {
        throw new ExistenceException(this, 1, "stream", a1, "");
      }
      stream = ((JavaObjectTerm) engine.getStreamManager().get(a1))
          .object();
    } else if (a1.isJavaObject()) {
      stream = ((JavaObjectTerm) a1).object();
View Full Code Here

    a1 = a1.dereference();
    if (a1.isVariable()) {
      throw new PInstantiationException(this, 1);
    } else if (a1.isSymbol()) {
      if (!engine.getHashManager().containsKey(a1)) {
        throw new ExistenceException(this, 1, "hash", a1, "");
      }
      hash = ((JavaObjectTerm) engine.getHashManager().get(a1)).object();
    } else if (a1.isJavaObject()) {
      hash = ((JavaObjectTerm) a1).object();
    } else {
View Full Code Here

TOP

Related Classes of jp.ac.kobe_u.cs.prolog.lang.ExistenceException

Copyright © 2018 www.massapicom. 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.