Package org.nlogo.prim.etc

Source Code of org.nlogo.prim.etc._myself

// (C) Uri Wilensky. https://github.com/NetLogo/NetLogo

package org.nlogo.prim.etc;

import org.nlogo.agent.Agent;
import org.nlogo.agent.Observer;
import org.nlogo.api.I18N;
import org.nlogo.api.LogoException;
import org.nlogo.api.Syntax;
import org.nlogo.nvm.Context;
import org.nlogo.nvm.EngineException;
import org.nlogo.nvm.Reporter;

public final strictfp class _myself
    extends Reporter {
  @Override
  public Syntax syntax() {
    return Syntax.reporterSyntax
        (Syntax.AgentType(), "-TPL");
  }

  @Override
  public Object report(final Context context) throws LogoException {
    Agent myself = context.myself();
    if (myself == null || myself instanceof Observer) {
      throw new EngineException
          (context, this, I18N.errorsJ().get("org.nlogo.prim.etc._myself.noAgentMyself"));
    }
    return myself;
  }

  public Agent report_1(Context context) throws LogoException {
    Agent myself = context.myself();
    if (myself == null || myself instanceof Observer) {
      throw new EngineException
          (context, this, I18N.errorsJ().get("org.nlogo.prim.etc._myself.noAgentMyself"));
    }
    return myself;
  }
}
TOP

Related Classes of org.nlogo.prim.etc._myself

TOP
Copyright © 2018 www.massapi.com. 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.