Package org.jfree.report

Examples of org.jfree.report.ReportDataFactoryException


          throws ReportDataFactoryException
  {
    ClassLoader classLoader = getClassLoader();
    if (classLoader == null)
    {
      throw new ReportDataFactoryException("No classloader!");
    }

    try
    {
      Class c = classLoader.loadClass(className);
      if (TableModel.class.isAssignableFrom(c) == false &&
          ReportData.class.isAssignableFrom(c) == false)
      {
        throw new ReportDataFactoryException("The specified class must be either a TableModel or a ReportData implementation.");
      }
      if (Modifier.isAbstract(c.getModifiers()))
      {
        throw new ReportDataFactoryException("The specified class cannot be instantiated: it is abstract.");
      }

      Constructor[] methods = c.getConstructors();
      for (int i = 0; i < methods.length; i++)
      {
        final Constructor method = methods[i];
        if (Modifier.isPublic(method.getModifiers()) == false)
        {
          continue;
        }
        if (method.getParameterTypes().length != paramCount)
        {
          continue;
        }
        return method;
      }
    }
    catch (ClassNotFoundException e)
    {
      throw new ReportDataFactoryException("No such Class", e);
    }
    throw new ReportDataFactoryException
        ("There is no constructor in class " + className +
            " that accepts " + paramCount + " parameters.");
  }
View Full Code Here


          throws ReportDataFactoryException
  {
    ClassLoader classLoader = getClassLoader();
    if (classLoader == null)
    {
      throw new ReportDataFactoryException("No classloader!");
    }

    try
    {
      Class c = classLoader.loadClass(className);
      if (Modifier.isAbstract(c.getModifiers()))
      {
        throw new ReportDataFactoryException("The specified class cannot be instantiated: it is abstract.");
      }

      Constructor[] methods = c.getConstructors();
      for (int i = 0; i < methods.length; i++)
      {
        final Constructor method = methods[i];
        if (Modifier.isPublic(method.getModifiers()) == false)
        {
          continue;
        }
        if (method.getParameterTypes().length != paramCount)
        {
          continue;
        }
        return method;
      }
    }
    catch (ClassNotFoundException e)
    {
      throw new ReportDataFactoryException("No such Class", e);
    }
    throw new ReportDataFactoryException
        ("There is no constructor in class " + className +
            " that accepts " + paramCount + " parameters.");
  }
View Full Code Here

        final Object pvalue = DataSetUtility.getByName(parameters, param, NULL_TOKEN);
        if (pvalue == NULL_TOKEN)
        {
          // this either means, that the parameter is explicitly set to null
          // or that there is no such column.
          throw new ReportDataFactoryException ("Setting parameter '" +
                    param + "' failed: No such column.");
        }
        else if (pvalue == null)
        {
          // this should work, but some driver are known to die here.
          // they should be fed with setNull(..) instead; something
          // we cant do as JDK1.2's JDBC does not define it.
          pstmt.setObject(i+1, null);
        }
        else
        {
          pstmt.setObject(i+1, pvalue);
        }
      }
      ResultSet res = pstmt.executeQuery();
      final int resultSetType = res.getType();

      if (resultSetType == ResultSet.TYPE_FORWARD_ONLY)
      {
        TableModel model = generateDefaultTableModel(res, labelMapping);
        res.close();
        return new TableReportData(model);
      }
      else
      {
        return new SQLReportData(res, labelMapping);
      }
    }
    catch(ReportDataFactoryException rdfe)
    {
      throw rdfe;
    }
    catch (Exception e)
    {
      throw new ReportDataFactoryException("Failed at query: " + query, e);
    }
  }
View Full Code Here

    catch(DataSourceException dse)
    {
        String message = dse.getMessage();
        if ( message.length() == 0 )
            message = "Failed to create report data wrapper";
      throw new ReportDataFactoryException(message,dse);
    }
    catch (org.jfree.report.DataSourceException e)
    {
        String message = e.getMessage();
        if ( message.length() == 0 )
            message = "Failed to query data";
      throw new ReportDataFactoryException(message);
    }
  }
View Full Code Here

      }
      return new StarReportData(backend.queryData(query, map));
    }
    catch(DataSourceException dse)
    {
      throw new ReportDataFactoryException("Failed to create report data wrapper");
    }
    catch (org.jfree.report.DataSourceException e)
    {
      throw new ReportDataFactoryException("Failed to query data");
    }
  }
View Full Code Here

      throw new NullPointerException("Query is null.");
    }
    final String realQuery = getQuery(query);
    if (realQuery == null)
    {
      throw new ReportDataFactoryException("Query '" + query + "' is not recognized.");
    }
    return super.queryData(realQuery, parameters);
  }
View Full Code Here

      throw new NullPointerException("Query is null.");
    }
    final String realQuery = getQuery(query);
    if (realQuery == null)
    {
      throw new ReportDataFactoryException("Query '" + query + "' is not recognized.");
    }
    return super.queryData(realQuery, parameters);
  }
View Full Code Here

    final int methodSeparatorIdx = query.indexOf('#');

    if ((methodSeparatorIdx + 1) >= query.length())
    {
      // If we have a method separator, then it cant be at the end of the text.
      throw new ReportDataFactoryException("Malformed query: " + query);
    }

    if (methodSeparatorIdx == -1)
    {
      // we have no method. So this query must be a reference to a tablemodel
      // instance.
      final String[] parameterNames;
      final int parameterStartIdx = query.indexOf('(');
      final String constructorName;
      if (parameterStartIdx == -1)
      {
        parameterNames = new String[0];
        constructorName = query;
      }
      else
      {
        parameterNames = createParameterList(query, parameterStartIdx);
        constructorName = query.substring(0, parameterStartIdx);
      }

      try
      {
        final Constructor c = findDirectConstructor(constructorName, parameterNames.length);

        final Object[] params = new Object[parameterNames.length];
        for (int i = 0; i < parameterNames.length; i++)
        {
          final String name = parameterNames[i];
          params[i] = DataSetUtility.getByName(parameters, name);
        }
        final Object o = c.newInstance(params);
        if (o instanceof TableModel)
        {
          return new TableReportData ((TableModel) o);
        }

        return (ReportData) o;
      }
      catch (Exception e)
      {
        throw new ReportDataFactoryException
                ("Unable to instantiate class for non static call.", e);
      }
    }

    return createComplexTableModel
View Full Code Here

      }
      return (ReportData) data;
    }
    catch (Exception e)
    {
      throw new ReportDataFactoryException
              ("Unable to instantiate class for non static call.");
    }
  }
View Full Code Here

      final ClassLoader classLoader = getClassLoader();
      final Class c = classLoader.loadClass(className);
      final Object o = c.newInstance();
      if (o == null)
      {
        throw new ReportDataFactoryException
                ("Unable to instantiate class for non static call.");
      }
      final Object data = m.invoke(o, params);
      if (data instanceof TableModel)
      {
        return new TableReportData((TableModel) data);
      }
      return (ReportData) data;
    }
    catch (ReportDataFactoryException rdfe)
    {
      throw rdfe;
    }
    catch (Exception e)
    {
      throw new ReportDataFactoryException
              ("Something went terribly wrong: ", e);
    }
  }
View Full Code Here

TOP

Related Classes of org.jfree.report.ReportDataFactoryException

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.