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

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


      stream = ((JavaObjectTerm) engine.getStreamManager().get(a1))
          .object();
    } else if (a1.isJavaObject()) {
      stream = ((JavaObjectTerm) a1).object();
    } else {
      throw new IllegalDomainException(this, 1, "stream_or_alias", a1);
    }
    if (!(stream instanceof PrintWriter)) {
      throw new PermissionException(this, "output", "stream", a1, "");
    }
    // print single character
View Full Code Here


          if (bool.equals(SYM_TRUE)) {
            forceFlag = true;
          } else if (bool.equals(SYM_FALSE)) {
            forceFlag = false;
          } else {
            throw new IllegalDomainException(this, 2,
                "close_option", car);
          }
        } else {
          throw new IllegalDomainException(this, 2, "close_option",
              car);
        }
      } else {
        throw new IllegalDomainException(this, 2, "close_option", car);
      }
      tmp = ((ListTerm) tmp).cdr().dereference();
    }
    // stream
    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();
    } else {
      throw new IllegalDomainException(this, 1, "stream_or_alias", a1);
    }
    if (stream instanceof PushbackReader) {
      PushbackReader in = (PushbackReader) stream;
      if (in.equals(engine.getUserInput())) {
        return cont;
      }
      if (in.equals(engine.getCurrentInput())) {
        engine.setCurrentInput(engine.getUserInput());
      }
      try {
        in.close();
      } catch (IOException e) {
        throw new TermException(new JavaObjectTerm(e));
      }
    } else if (stream instanceof PrintWriter) {
      PrintWriter out = (PrintWriter) stream;
      if (out.checkError()) {
        if (!forceFlag) {
          throw new SystemException("output stream error");
        }
      }
      out.flush();
      if (out.equals(engine.getUserOutput())
          || out.equals(engine.getUserError())) {
        return cont;
      }
      if (out.equals(engine.getCurrentOutput())) {
        engine.setCurrentOutput(engine.getUserOutput());
      }
      out.close();
    } else {
      throw new IllegalDomainException(this, 1, "stream_or_alias", a1);
    }
    // delete associated entries from the stream manager
    HashMapOfTerm streamManager = engine.getStreamManager();
    if (a1.isSymbol()) {
      streamManager.remove(engine.getStreamManager().get(a1));
      streamManager.remove(a1);
    } else if (a1.isJavaObject()) {
      Term tmp2 = streamManager.get(a1);
      while (!tmp2.isNil()) {
        Term car = ((ListTerm) tmp2).car().dereference();
        if (car.isStructure()) {
          SymbolTerm functor = ((StructureTerm) car).functor();
          Term[] args = ((StructureTerm) car).args();
          if (functor.equals(SYM_ALIAS_1)) {
            Term alias = args[0].dereference();
            streamManager.remove(alias);
          }
        }
        tmp2 = ((ListTerm) tmp2).cdr().dereference();
      }
      streamManager.remove(a1);
    } else {
      throw new IllegalDomainException(this, 1, "stream_or_alias", a1);
    }
    return cont;
  }
View Full Code Here

      stream = ((JavaObjectTerm) engine.getStreamManager().get(a1))
          .object();
    } else if (a1.isJavaObject()) {
      stream = ((JavaObjectTerm) a1).object();
    } else {
      throw new IllegalDomainException(this, 1, "stream_or_alias", a1);
    }
    if (!(stream instanceof PrintWriter)) {
      throw new PermissionException(this, "output", "stream", a1, "");
    }
    // print single byte
View Full Code Here

      stream = ((JavaObjectTerm) engine.getStreamManager().get(a1))
          .object();
    } else if (a1.isJavaObject()) {
      stream = ((JavaObjectTerm) a1).object();
    } else {
      throw new IllegalDomainException(this, 1, "stream_or_alias", a1);
    }
    if (!(stream instanceof PrintWriter)) {
      throw new PermissionException(this, "output", "stream", a1, "");
    }
    // print term
View Full Code Here

      }
      hash = ((JavaObjectTerm) engine.getHashManager().get(a1)).object();
    } else if (a1.isJavaObject()) {
      hash = ((JavaObjectTerm) a1).object();
    } else {
      throw new IllegalDomainException(this, 1, "hash_or_alias", a1);
    }
    if (!(hash instanceof HashMapOfTerm)) {
      throw new InternalException(this + ": Hash is not HashtableOfTerm");
    }
    Term keys = SYM_NIL;
View Full Code Here

      }
      hash = ((JavaObjectTerm) engine.getHashManager().get(a1)).object();
    } else if (a1.isJavaObject()) {
      hash = ((JavaObjectTerm) a1).object();
    } else {
      throw new IllegalDomainException(this, 1, "hash_or_alias", a1);
    }
    if (!(hash instanceof HashMapOfTerm)) {
      throw new InternalException(this + ": Hash is not HashtableOfTerm");
    }
    a2 = a2.dereference();
View Full Code Here

      stream = ((JavaObjectTerm) engine.getStreamManager().get(a1))
          .object();
    } else if (a1.isJavaObject()) {
      stream = ((JavaObjectTerm) a1).object();
    } else {
      throw new IllegalDomainException(this, 1, "stream_or_alias", a1);
    }
    if (!(stream instanceof PrintWriter)) {
      throw new PermissionException(this, "output", "stream", a1, "");
    }
    // tab
View Full Code Here

        SymbolTerm functor = ((StructureTerm) car).functor();
        Term[] args = ((StructureTerm) car).args();
        if (functor.equals(SYM_ALIAS_1)) {
          Term alias = args[0].dereference();
          if (!alias.isSymbol()) {
            throw new IllegalDomainException(this, 2,
                "hash_option", car);
          } else {
            if (engine.getHashManager().containsKey(alias)) {
              throw new PermissionException(this, "new", "hash",
                  car, "");
            }
            engine.getHashManager().put(alias, newHash);
          }
        } else {
          throw new IllegalDomainException(this, 2, "hash_option",
              car);
        }
      } else {
        throw new IllegalDomainException(this, 2, "hash_option", car);
      }
      tmp = ((ListTerm) tmp).cdr().dereference();
    }
    if (!a1.unify(newHash, engine.trail)) {
      return engine.fail();
View Full Code Here

      }
      hash = ((JavaObjectTerm) engine.getHashManager().get(a1)).object();
    } else if (a1.isJavaObject()) {
      hash = ((JavaObjectTerm) a1).object();
    } else {
      throw new IllegalDomainException(this, 1, "hash_or_alias", a1);
    }
    if (!(hash instanceof HashMapOfTerm)) {
      throw new InternalException(this + ": Hash is not HashtableOfTerm");
    }
    a2 = a2.dereference();
View Full Code Here

      stream = ((JavaObjectTerm) engine.getStreamManager().get(a1))
          .object();
    } else if (a1.isJavaObject()) {
      stream = ((JavaObjectTerm) a1).object();
    } else {
      throw new IllegalDomainException(this, 1, "stream_or_alias", a1);
    }
    if (!(stream instanceof PushbackReader)) {
      throw new PermissionException(this, "input", "stream", a1, "");
    }
    // read line
View Full Code Here

TOP

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

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.