public Object clone() {
    JRBaseCategorySeries clone = null;

    try {
      clone = (JRBaseCategorySeries) super.clone();
    } catch (CloneNotSupportedException e) {
      throw new JRRuntimeException(e);
    }

    if (seriesExpression != null) {
      clone.seriesExpression = (JRExpression) seriesExpression.clone();
    }
    if (categoryExpression != null) {
      clone.categoryExpression = (JRExpression) categoryExpression.clone();
    }
    if (valueExpression != null) {
      clone.valueExpression = (JRExpression) valueExpression.clone();
    }
    if (labelExpression != null) {
      clone.labelExpression = (JRExpression) labelExpression.clone();
    }
    if (itemHyperlink != null) {
      clone.itemHyperlink = (JRHyperlink) itemHyperlink.clone();
    }

    return clone;
  }
Пример #2
0
  public Object clone() {
    JRBaseXyzSeries clone = null;

    try {
      clone = (JRBaseXyzSeries) super.clone();
    } catch (CloneNotSupportedException e) {
      throw new JRRuntimeException(e);
    }

    if (seriesExpression != null) {
      clone.seriesExpression = (JRExpression) seriesExpression.clone();
    }
    if (xValueExpression != null) {
      clone.xValueExpression = (JRExpression) xValueExpression.clone();
    }
    if (yValueExpression != null) {
      clone.yValueExpression = (JRExpression) yValueExpression.clone();
    }
    if (zValueExpression != null) {
      clone.zValueExpression = (JRExpression) zValueExpression.clone();
    }
    if (itemHyperlink != null) {
      clone.itemHyperlink = (JRHyperlink) itemHyperlink.clone();
    }

    return clone;
  }
  protected final String generateMethod(byte evaluationType, List expressionsList) {
    StringBuffer sb = new StringBuffer();

    /*   */
    sb.append("    Object evaluate");
    sb.append((String) methodSuffixMap.get(new Byte(evaluationType)));
    sb.append("(int id)\n");
    sb.append("    {\n");
    sb.append("        Object value = null;\n");
    sb.append("\n");
    sb.append("        switch (id)\n");
    sb.append("        {\n");

    if (expressionsList != null && !expressionsList.isEmpty()) {
      JRExpression expression = null;
      for (Iterator it = expressionsList.iterator(); it.hasNext(); ) {
        expression = (JRExpression) it.next();

        sb.append("            case ");
        sb.append(sourceTask.getExpressionId(expression));
        sb.append(" :\n");
        sb.append("            {\n");
        sb.append("                value = (");
        sb.append(expression.getValueClassName());
        sb.append(")(");
        sb.append(this.generateExpression(expression, evaluationType));
        sb.append(");\n");
        sb.append("                break;\n");
        sb.append("            }\n");
      }
    }

    /*   */
    sb.append("           default :\n");
    sb.append("           {\n");
    sb.append("           }\n");
    sb.append("        }\n");
    sb.append("        \n");
    sb.append("        return value;\n");
    sb.append("    }\n");
    sb.append("\n");
    sb.append("\n");

    return sb.toString();
  }
Пример #4
0
  public Object clone() {
    JRBaseTextField clone = (JRBaseTextField) super.clone();

    if (hyperlinkParameters != null) {
      clone.hyperlinkParameters = new JRHyperlinkParameter[hyperlinkParameters.length];
      for (int i = 0; i < hyperlinkParameters.length; i++) {
        clone.hyperlinkParameters[i] = (JRHyperlinkParameter) hyperlinkParameters[i].clone();
      }
    }

    if (expression != null) {
      clone.expression = (JRExpression) expression.clone();
    }
    if (anchorNameExpression != null) {
      clone.anchorNameExpression = (JRExpression) anchorNameExpression.clone();
    }
    if (hyperlinkReferenceExpression != null) {
      clone.hyperlinkReferenceExpression = (JRExpression) hyperlinkReferenceExpression.clone();
    }
    if (hyperlinkAnchorExpression != null) {
      clone.hyperlinkAnchorExpression = (JRExpression) hyperlinkAnchorExpression.clone();
    }
    if (hyperlinkPageExpression != null) {
      clone.hyperlinkPageExpression = (JRExpression) hyperlinkPageExpression.clone();
    }
    if (hyperlinkTooltipExpression != null) {
      clone.hyperlinkTooltipExpression = (JRExpression) hyperlinkTooltipExpression.clone();
    }

    return clone;
  }
 public static String getSimpleExpressionText(JRExpression expression) {
   String value = null;
   if (expression != null) {
     JRExpressionChunk[] chunks = expression.getChunks();
     if (chunks != null
         && chunks.length == 1
         && chunks[0].getType() == JRExpressionChunk.TYPE_TEXT) {
       String chunk = chunks[0].getText();
       Matcher matcher = SIMPLE_EXPRESSION_PATTERN.matcher(chunk);
       if (matcher.matches()) {
         String text = matcher.group(SIMPLE_EXPRESSION_TEXT_GROUP);
         value = TEXT_QUOTE_PATTERN.matcher(text).replaceAll(TEXT_QUOTE_REPLACEMENT);
       }
     }
   }
   return value;
 }
Пример #6
0
  public Object clone() {
    JRBaseChart clone = (JRBaseChart) super.clone();

    clone.lineBox = lineBox.clone(clone);

    if (hyperlinkParameters != null) {
      clone.hyperlinkParameters = new JRHyperlinkParameter[hyperlinkParameters.length];
      for (int i = 0; i < hyperlinkParameters.length; i++) {
        clone.hyperlinkParameters[i] = (JRHyperlinkParameter) hyperlinkParameters[i].clone();
      }
    }

    if (titleExpression != null) {
      clone.titleExpression = (JRExpression) titleExpression.clone();
    }
    if (subtitleExpression != null) {
      clone.subtitleExpression = (JRExpression) subtitleExpression.clone();
    }
    if (anchorNameExpression != null) {
      clone.anchorNameExpression = (JRExpression) anchorNameExpression.clone();
    }
    if (hyperlinkReferenceExpression != null) {
      clone.hyperlinkReferenceExpression = (JRExpression) hyperlinkReferenceExpression.clone();
    }
    if (hyperlinkAnchorExpression != null) {
      clone.hyperlinkAnchorExpression = (JRExpression) hyperlinkAnchorExpression.clone();
    }
    if (hyperlinkPageExpression != null) {
      clone.hyperlinkPageExpression = (JRExpression) hyperlinkPageExpression.clone();
    }
    if (hyperlinkTooltipExpression != null) {
      clone.hyperlinkTooltipExpression = (JRExpression) hyperlinkTooltipExpression.clone();
    }

    if (dataset != null) {
      clone.dataset = (JRChartDataset) dataset.clone();
    }
    if (plot != null) {
      clone.plot = (JRChartPlot) plot.clone(clone);
    }

    return clone;
  }
  public Object evaluateEstimated(JRExpression expression) throws JRExpressionEvalException {
    Object value = null;

    if (expression != null) {
      try {
        value = evaluateEstimated(expression.getId());
      } catch (NullPointerException e) // NOPMD
      {
      } catch (OutOfMemoryError e) {
        throw e;
      }
      // we have to catch Throwable because there is no way we could modify the signature
      // of the evaluate method, without breaking backward compatibility of compiled report
      // templates
      catch (Throwable e) // NOPMD
      {
        throw new JRExpressionEvalException(expression, e);
      }
    }

    return value;
  }
 public static String getExpressionText(JRExpression exp) {
   return exp == null ? null : exp.getText();
 }
  private String generateExpression(JRExpression expression, byte evaluationType) {
    JRParameter jrParameter = null;
    JRField jrField = null;
    JRVariable jrVariable = null;

    StringBuffer sbuffer = new StringBuffer();

    JRExpressionChunk[] chunks = expression.getChunks();
    JRExpressionChunk chunk = null;
    String chunkText = null;
    if (chunks != null && chunks.length > 0) {
      for (int i = 0; i < chunks.length; i++) {
        chunk = chunks[i];

        chunkText = chunk.getText();
        if (chunkText == null) {
          chunkText = "";
        }

        switch (chunk.getType()) {
          case JRExpressionChunk.TYPE_TEXT:
            {
              sbuffer.append(chunkText);
              break;
            }
          case JRExpressionChunk.TYPE_PARAMETER:
            {
              jrParameter = (JRParameter) parametersMap.get(chunkText);

              sbuffer.append("((");
              sbuffer.append(jrParameter.getValueClassName());
              sbuffer.append(")super.parameter_");
              sbuffer.append(JRStringUtil.getJavaIdentifier(chunkText));
              sbuffer.append(".getValue())");

              break;
            }
          case JRExpressionChunk.TYPE_FIELD:
            {
              jrField = (JRField) fieldsMap.get(chunkText);

              sbuffer.append("((");
              sbuffer.append(jrField.getValueClassName());
              sbuffer.append(")super.field_");
              sbuffer.append(JRStringUtil.getJavaIdentifier(chunkText));
              sbuffer.append(".get");
              sbuffer.append((String) fieldPrefixMap.get(new Byte(evaluationType)));
              sbuffer.append("Value())");

              break;
            }
          case JRExpressionChunk.TYPE_VARIABLE:
            {
              jrVariable = (JRVariable) variablesMap.get(chunkText);

              sbuffer.append("((");
              sbuffer.append(jrVariable.getValueClassName());
              sbuffer.append(")super.variable_");
              sbuffer.append(JRStringUtil.getJavaIdentifier(chunkText));
              sbuffer.append(".get");
              sbuffer.append((String) variablePrefixMap.get(new Byte(evaluationType)));
              sbuffer.append("Value())");

              break;
            }
          case JRExpressionChunk.TYPE_RESOURCE:
            {
              jrParameter = (JRParameter) parametersMap.get(chunkText);

              sbuffer.append("super.evaluator.str(\"");
              sbuffer.append(chunkText);
              sbuffer.append("\")");

              break;
            }
        }
      }
    }

    if (sbuffer.length() == 0) {
      sbuffer.append("null");
    }

    return sbuffer.toString();
  }