/* (non-Javadoc)
@see com.ibm.ws.sib.processor.MPSelectorEvaluator#evaluateDiscriminator(java.lang.String, java.lang.String)
965339
public boolean evaluateDiscriminator(String fullTopic, String wildcardTopic) throws SIDiscriminatorSyntaxException
  {
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "evaluateDiscriminator", new Object[] { fullTopic, wildcardTopic });

    boolean ret = mpm.evaluateDiscriminator(fullTopic, wildcardTopic);
          
    if (tc.isEntryEnabled()) SibTr.exit(tc, "evaluateDiscriminator", new Boolean(ret));
    return ret;       
  }
992909
static ReferenceTypeSignature parseReferenceTypeSignature(final Parser parser, final String definingClassName)
            throws ParseException {
        final ClassRefTypeSignature classTypeSignature = ClassRefTypeSignature.parse(parser, definingClassName);
        if (classTypeSignature != null) {
            return classTypeSignature;
        }
        final TypeVariableSignature typeVariableSignature = TypeVariableSignature.parse(parser, definingClassName);
        if (typeVariableSignature != null) {
            return typeVariableSignature;
        }
        final ArrayTypeSignature arrayTypeSignature = ArrayTypeSignature.parse(parser, definingClassName);
        if (arrayTypeSignature != null) {
            return arrayTypeSignature;
        }
        return null;
    }
1087540
private void evaluateExpressions() throws JspException {
        /* 
         * Note: we don't check for type mismatches here; we assume
         * the expression evaluator will return the expected type
         * (by virtue of knowledge we give it about what that type is).
         * A ClassCastException here is truly unexpected, so we let it
         * propagate up.
         */

        if (keySpecified) {
            keyAttrValue = (String) ExpressionEvaluatorManager.evaluate(
                    "key", key_, String.class, this, pageContext);
        }

        if (bundleSpecified) {
            bundleAttrValue = (LocalizationContext)
                    ExpressionEvaluatorManager.evaluate(
                            "bundle", bundle_, LocalizationContext.class, this,
                            pageContext);
        }
    }
1265053
public void onEvaluatorException(final EvaluatorException exception) {
    synchronized (this.evaluatorDescriptor) {

      if (this.stateManager.isCompleted()) {
        LOG.log(Level.FINE,
            "Ignoring an exception received for Evaluator {0} which is already in state {1}.",
            new Object[] {this.getId(), this.stateManager});
        return;
      }

      LOG.log(Level.WARNING, "Failed evaluator: " + getId(), exception);

      try {

        final List<FailedContext> failedContextList = this.contextRepresenters.getFailedContextsForEvaluatorFailure();

        final Optional<FailedTask> failedTaskOptional;
        if (this.task.isPresent()) {

          final String taskId = this.task.get().getId();
          final Optional<ActiveContext> evaluatorContext = Optional.empty();
          final Optional<byte[]> bytes = Optional.empty();
          final Optional<Throwable> taskException = Optional.<Throwable>of(new Exception("Evaluator crash"));
          final String message = "Evaluator crash";
          final Optional<String> description = Optional.empty();
          final FailedTask failedTask =
              new FailedTask(taskId, message, description, taskException, bytes, evaluatorContext);

          failedTaskOptional = Optional.of(failedTask);

        } else {
          failedTaskOptional = Optional.empty();
        }

        final FailedEvaluator failedEvaluator = new FailedEvaluatorImpl(
            exception, failedContextList, failedTaskOptional, this.evaluatorId);

        if (driverRestartManager.getEvaluatorRestartState(evaluatorId).isFailedOrExpired()) {
          this.messageDispatcher.onDriverRestartEvaluatorFailed(failedEvaluator);
        } else {
          this.messageDispatcher.onEvaluatorFailed(failedEvaluator);
        }
      } catch (final Exception e) {
        LOG.log(Level.SEVERE, "Exception while handling FailedEvaluator", e);
      } finally {
        this.stateManager.setFailed();
        this.close();
      }
    }
  }
732532
@Override
	public Object evaluate(Message message) throws JMSException
    {
        Object operandValue = operand.evaluate(message);
        return operandValue == null ? Boolean.TRUE : Boolean.FALSE;
    }
215352
private void evaluateExpressions() throws JspException {
        if (valueEL != null) {
            value = (Date) ExpressionEvaluatorManager.evaluate(
                    "value", valueEL, Date.class, this, pageContext);
        }

        if (typeEL != null) {
            type = (String) ExpressionEvaluatorManager.evaluate(
                    "type", typeEL, String.class, this, pageContext);
        }
    }
389985
@Override
	public Object evaluate(Message message) throws JMSException
    {
        Number leftValue = leftOperand.evaluateNumeric(message);
        Number rightValue = rightOperand.evaluateNumeric(message);
        if (leftValue == null || rightValue == null)
            return null;
        
        return ArithmeticUtils.multiply(leftValue, rightValue);
    }
279129
private static TypeQualifierAnnotation computeEffectiveTypeQualifierAnnotation(TypeQualifierValue<?> typeQualifierValue,
            XMethod xmethod, int parameter) {
        if (DEBUG) {
            // System.out.println("XX: "
            // +System.identityHashCode(typeQualifierValue));
            if (typeQualifierValue.value != null) {
                System.out.println("  Value is " + typeQualifierValue.value + "("
                        + typeQualifierValue.value.getClass().toString() + ")");
            }
        }
        Map<TypeQualifierValue<?>, DualKeyHashMap<XMethod, Integer, TypeQualifierAnnotation>> effectiveParameterAnnotations = getEffectiveParameterAnnotations();
        DualKeyHashMap<XMethod, Integer, TypeQualifierAnnotation> map = effectiveParameterAnnotations.get(typeQualifierValue);
        if (map == null) {
            if (DEBUG) {
                System.out.println("computeEffectiveTypeQualifierAnnotation: Creating map for " + typeQualifierValue);
            }
            map = new DualKeyHashMap<>();
            effectiveParameterAnnotations.put(typeQualifierValue, map);
        }

        // Check cached answer
        TypeQualifierAnnotation result;
        if (map.containsKey(xmethod, parameter)) {
            result = map.get(xmethod, parameter);
        } else {
            if (DEBUG) {
                System.out.println("Looking up application of " + typeQualifierValue + " on " + xmethod + " parameter "
                        + parameter);
            }

            // String desc =
            // xmethod.toString()+":"+parameter+":"+typeQualifierValue;
            // if (checked.containsKey(desc)) {
            // //throw new IllegalStateException("Repeating computation of " +
            // desc, checked.get(desc));
            // System.out.println("Repeating computation of " + desc);
            // System.out.println("Previously computed:");
            // checked.get(desc).printStackTrace(System.out);
            // throw new IllegalStateException();
            // }
            // checked.put(desc, new Throwable().fillInStackTrace());

            // Compute answer
            TypeQualifierAnnotation tqa;

            if (xmethod.isVarArgs() && parameter == xmethod.getNumParams()-1) {
                tqa = null;
                if (DEBUG) {
                    System.out.print("  vararg parameters don't get type qualifiers");
                }
            }
            else {
                // Check direct application
                if (DEBUG) {
                    System.out.print("  (1) Checking direct application...");
                }
                tqa = getDirectTypeQualifierAnnotation(xmethod, parameter, typeQualifierValue);
                if (DEBUG) {
                    System.out.println(tqa != null ? "FOUND" : "none");
                }

                // If it's an instance method, check for inherited annotation
                if (tqa == null && !xmethod.isStatic() && !xmethod.isPrivate() && !"<init>".equals(xmethod.getName())) {
                    if (DEBUG) {
                        System.out.print("  (2) Checking inherited...");
                    }
                    tqa = getInheritedTypeQualifierAnnotation(xmethod, parameter, typeQualifierValue);
                    if (DEBUG) {
                        if (tqa == TypeQualifierAnnotation.OVERRIDES_BUT_NO_ANNOTATION) {
                            System.out.println("Overrides, no annotation inherited");
                        } else if (tqa != null) {
                            System.out.println("Inherited " + tqa.when);
                        } else {
                            System.out.println("Nothing inherited");
                        }
                    }
                }
                boolean overriddenMethod = false;
                if (tqa == TypeQualifierAnnotation.OVERRIDES_BUT_NO_ANNOTATION) {
                    overriddenMethod = true;
                    tqa = null;
                }
                // Check for default (outer scope) annotation
                if (tqa == null) {
                    if (xmethod.isVariableSynthetic((xmethod.isStatic() ? 0 : 1) + parameter)) {
                        if (DEBUG) {
                            System.out.print("  (3) Skipping default for synthetic parameter");
                        }
                    } else {
                        if (DEBUG) {
                            System.out.print("  (3) Checking default...");
                        }

                        tqa = getDefaultTypeQualifierAnnotationForParameters(xmethod, typeQualifierValue, overriddenMethod);

                        if (DEBUG) {
                            System.out.println(tqa != null ? "FOUND" : "none");
                        }
                    }
                }
            }

            // Cache answer
            result = tqa;
            map.put(xmethod, parameter, result);

            if (DEBUG) {
                if (result == null) {
                    System.out.println("  => Answer: no annotation on parameter " + parameter + " of " + xmethod);
                } else {
                    System.out.println("  => Answer: " + result.when + " on parameter " + parameter + " of " + xmethod);
                }
            }
        }

        if (!map.containsKey(xmethod, parameter)) {
            throw new IllegalStateException("Did not populate cache?");
        }

        // Return cached answer
        return result;
    }
1439
public Object evaluate(String expression) throws CompilationFailedException {
        GroovyShell shell = new GroovyShell(getClass().getClassLoader(), binding);
        return shell.evaluate(expression);
    }
631012
private void evaluateExpressions() throws JspException {

        // 'value' attribute (mandatory)
        value = ExpressionEvaluatorManager.evaluate(
                "value", value_, Object.class, this, pageContext);

        // 'variant' attribute (optional)
        if (variant_ != null) {
            variant = (String) ExpressionEvaluatorManager.evaluate(
                    "variant", variant_, String.class, this, pageContext);
        }
    }
890699
private void seqeval() throws IOException {

    final String metric = this.parsedArguments.getString("metric");
    final String lang = this.parsedArguments.getString("language");
    final String model = this.parsedArguments.getString("model");
    final String testset = this.parsedArguments.getString("testset");
    final String corpusFormat = this.parsedArguments.getString("corpusFormat");
    final String netypes = this.parsedArguments.getString("types");
    final String clearFeatures = this.parsedArguments
        .getString("clearFeatures");
    final String unknownAccuracy = this.parsedArguments
        .getString("unknownAccuracy");
    final Properties props = setEvalProperties(lang, model, testset,
        corpusFormat, netypes, clearFeatures, unknownAccuracy);
    final SequenceLabelerEvaluate evaluator = new SequenceLabelerEvaluate(
        props);

    if (metric.equalsIgnoreCase("accuracy")) {
      evaluator.evaluateAccuracy();
    } else {
      if (this.parsedArguments.getString("evalReport") != null) {
        if (this.parsedArguments.getString("evalReport")
            .equalsIgnoreCase("brief")) {
          evaluator.evaluate();
        } else if (this.parsedArguments.getString("evalReport")
            .equalsIgnoreCase("error")) {
          evaluator.evalError();
        } else if (this.parsedArguments.getString("evalReport")
            .equalsIgnoreCase("detailed")) {
          evaluator.detailEvaluate();
        }
      } else {
        evaluator.detailEvaluate();
      }
    }
  }
477956
private void evaluateExpressions() throws JspException {
        /* 
         * Note: we don't check for type mismatches here; we assume
         * the expression evaluator will return the expected type
         * (by virtue of knowledge we give it about what that type is).
         * A ClassCastException here is truly unexpected, so we let it
         * propagate up.
         */

        if (escapeXml_ != null) {
            Boolean b = (Boolean) ExpressionUtil.evalNotNull(
                    "out",
                    "escapeXml",
                    escapeXml_,
                    Boolean.class,
                    this,
                    pageContext);
            if (b == null) {
                escapeXml = false;
            } else {
                escapeXml = b.booleanValue();
            }
        }
    }
54835
public boolean evaluateMessage(
    Selector selectorTree,
    Selector discriminatorTree,
    SIBusMessage msg)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "evaluateMessage", new Object[] { selectorTree, msg });

    boolean ret = false;
    Object result = null;
    boolean discriminatorMatches = true; //assume it does match

    // Use the dummy evaluation cache, we don't need one hear as we're not
    // searching the MatchSpace
    EvalCache cache = EvalCache.DUMMY;

    try
    {
      Evaluator evaluator = Matching.getEvaluator();
      //    See if we need to process a discriminator expression first
      if (discriminatorTree != null)
      {
        discriminatorMatches = false; //can no longer assume it does match
        String discriminator = msg.getDiscriminator();

        MatchSpaceKey msk = new DiscriminatorMatchSpaceKey(discriminator);
        // Evaluate message against selector tree
        result = evaluator.eval(discriminatorTree, msk, cache, null, false);
        if (result != null && ((Boolean) result).booleanValue())
        {
          discriminatorMatches = true;
        }
      }

      // Evaluate message against selector tree
      if (selectorTree != null && discriminatorMatches)
      {
        result =
          evaluator.eval(selectorTree, (MatchSpaceKey) msg, cache, null, false);
      }

    }
    catch (BadMessageFormatMatchingException qex)
    {
      FFDCFilter.processException(
        qex,
        "com.ibm.ws.sib.processor.matching.MessageProcessorMatching.evaluateMessage",
        "1:1824:1.117.1.11",
        this);

      SibTr.exception(tc, qex);

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "evaluateMessage", "SICoreException");

      SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0002",
        new Object[] {
          "com.ibm.ws.sib.processor.matching.MessageProcessorMatching",
          "1:1834:1.117.1.11",
          qex });

      // For now, I'll throw a core exception, but in due course this (or something with a
      // better name) will be externalised in the Core API.
      throw new SIErrorException(
        nls.getFormattedMessage(
          "INTERNAL_MESSAGING_ERROR_CWSIP0002",
          new Object[] {
            "com.ibm.ws.sib.processor.matching.MessageProcessorMatching",
            "1:1844:1.117.1.11",
            qex },
          null),
        qex);
    }

    // The result of expression evaluation can be either a
    // boolean, or not, which is interpreted as false.
    if (result instanceof Boolean)
    {
      // This turns a BooleanValue into a boolean
      // it will return false for unknown which is what we want.
      ret = ((Boolean) result).booleanValue();
    }
    else if (result == null)
    {
      ret = false;
    }
    else
    {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "evaluateMessage", "SICoreException");
      // For now, I'll throw a core exception, but in due course this (or something with a
      // better name) will be externalised in the Core API.
      SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0001",
        new Object[] {
          "com.ibm.ws.sib.processor.matching.MessageProcessorMatching",
          "1:1870:1.117.1.11" });

      throw new SIErrorException(
        nls.getFormattedMessage(
          "INTERNAL_MESSAGING_ERROR_CWSIP0001",
          new Object[] {
            "com.ibm.ws.sib.processor.matching.MessageProcessorMatching",
            "1:1877:1.117.1.11" },
          null));
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "evaluateMessage", Boolean.valueOf(ret));
    return ret;
  }
964011
public <T extends Evaluation> T evaluate(DataSetIterator iterator) {
        return (T)evaluate(iterator, (List<String>)null);
    }
1062953
private EvaluatorManager getNewEvaluatorManagerInstance(final String id, final EvaluatorDescriptor desc) {
    LOG.log(Level.FINEST, "Creating Evaluator Manager for Evaluator ID {0}", id);
    final Injector child = this.injector.forkInjector();

    try {
      child.bindVolatileParameter(EvaluatorManager.EvaluatorIdentifier.class, id);
      child.bindVolatileParameter(EvaluatorManager.EvaluatorDescriptorName.class, desc);
    } catch (final BindException e) {
      throw new RuntimeException("Unable to bind evaluator identifier and name.", e);
    }

    final EvaluatorManager result;
    try {
      result = child.getInstance(EvaluatorManager.class);
    } catch (final InjectionException e) {
      throw new RuntimeException("Unable to instantiate a new EvaluatorManager for Evaluator ID: " + id, e);
    }
    return result;
  }
220008
public void evaluate(final ObjectStream<SequenceLabelSample> samples,
      final int nFolds) throws IOException {

    // Note: The name samples need to be grouped on a document basis.

    final CrossValidationPartitioner<DocumentSample> partitioner = new CrossValidationPartitioner<DocumentSample>(
        new NameToDocumentSampleStream(samples), nFolds);

    while (partitioner.hasNext()) {

      final CrossValidationPartitioner.TrainingSampleStream<DocumentSample> trainingSampleStream = partitioner
          .next();

      SequenceLabelerModel model = null;
      if (this.factory != null) {
        model = SequenceLabelerME.train(this.languageCode,
            new DocumentToNameSampleStream(trainingSampleStream), this.params,
            this.factory);
      } else {
        System.err.println("You need to implement a SequenceLabelerFactory!");
        System.exit(1);
      }
      
      String corpusFormat = Flags.getCorpusFormat(this.params);
      // do testing
      final SequenceLabelerEvaluator evaluator = new SequenceLabelerEvaluator(corpusFormat,
          new SequenceLabelerME(model), this.listeners);

      evaluator.evaluate(new DocumentToNameSampleStream(
          trainingSampleStream.getTestSampleStream()));

      this.fmeasure.mergeInto(evaluator.getFMeasure());
    }
  }
404868
private void evaluateExpressions() throws JspException {
        if (dataSourceEL != null) {
            dataSource = ExpressionEvaluatorManager.evaluate
                    ("dataSource", dataSourceEL, Object.class, this, pageContext);
        }

        if (driverClassNameEL != null) {
            driverClassName = (String) ExpressionEvaluatorManager.evaluate
                    ("driver", driverClassNameEL, String.class, this, pageContext);
        }

        if (jdbcURLEL != null) {
            jdbcURL = (String) ExpressionEvaluatorManager.evaluate
                    ("url", jdbcURLEL, String.class, this, pageContext);
        }

        if (userNameEL != null) {
            userName = (String) ExpressionEvaluatorManager.evaluate
                    ("user", userNameEL, String.class, this, pageContext);
        }

        if (passwordEL != null) {
            password = (String) ExpressionEvaluatorManager.evaluate
                    ("password", passwordEL, String.class, this, pageContext);
        }
    }