Package org.syrup

Examples of org.syrup.LogEntry


    {

        XMLOutput o = new XMLOutput();
        SerializationHandler h = o.wrap(out);

        LogEntry l[] = sp.match(template);

        // Outputs the fetched PTasks to the OutputStream in XML format.
        o.startDocument("log", h);

        for (int i = 0; i < l.length; i++)
View Full Code Here


     */
   
    public LogEntry[] match(LogEntryTemplate template, SyrupConnection con)
    throws Exception
{
    LogEntry l[] = new LogEntry[0];
    String qq = null;

    List qParts = new LinkedList();

    // Add all the qualifiers, mapping from LogEntry attributes to SQL
    // attributes.
    qParts.add(new QueryOperation(template, "creation_time", "time"));
    qParts.add(new QueryOperation(template, "key_", "key"));
    qParts.add(new QueryOperation(template, "event", "event"));
    qParts.add(new QueryOperation(template, "worker", "worker"));

    // Builds the SQL query.
    // [TODO: use an StringBuffer to speed up the concatenation of Strings].
    // [TODO: factor out this code so that it can be share by the previous match function]
    Iterator qIterator = qParts.iterator();
    while (qIterator.hasNext())
    {
        QueryOperation op = (QueryOperation) qIterator.next();
        if (op.sqlOp != null)
        {
            if (qq != null)
            {
                qq = qq
                    + " and ";
            }
            else
            {
                qq = " ";
            }
            qq = qq
                + op.sqlAtt + " " + op.sqlOp + " ?";
        }
    }

    if (qq == null)
    {
        qq = sqlImpl().sqlStatements().selectLogEntriesStatement();
    }
    else
    {
        qq = sqlImpl().sqlStatements().selectLogEntriesStatement()
            + "where" + qq;
    }

    PreparedStatement ps = null;

        ps = con.prepareStatement(qq);

        qIterator = qParts.iterator();
        int ii = 1;

        while (qIterator.hasNext())
        {
            QueryOperation op = (QueryOperation) qIterator.next();

            // For each qualifier, the SQL value is set.
            if (op.sqlOp != null)
            {
                ps.setObject(ii++, op.value);
            }
        }

        ResultSet result = null;
       
        try
        {
        result = ps.executeQuery();

        // Build the result array
        // [TODO: Make this more efficient without the need of an extra
        // ArrayList object]
        ArrayList logs = new ArrayList();
        while (result.next())
        {
            LogEntry t = sqlImpl().queryFunctions().readLogEntry(result);
            logs.add(t);
        }

        l = new LogEntry[logs.size()];
        Object[] o = logs.toArray();
View Full Code Here

     *            The ResultSet that holds the LogEntry attributes.
     * @return The LogEntry held by a ResultSet.
     */
    protected LogEntry readLogEntry(ResultSet result) throws Exception
    {
        LogEntry logentry = new LogEntryImpl(result.getLong("creation_time"), result.getString("key_"), (int) result.getInt("event"), result.getString("worker"));

        return logentry;
    }
View Full Code Here

TOP

Related Classes of org.syrup.LogEntry

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.