FileDocCategorySizeDatePackage
LogQueryResultImpl.javaAPI DocGlassfish v2 API5548Fri May 04 22:30:50 BST 2007com.sun.appserv.management.ext.logging

LogQueryResultImpl

public final class LogQueryResultImpl extends Object implements LogQueryResult
INTERNAL USE ONLY--not part of the API
since
AS 9.0

Fields Summary
private String[]
mFieldNames
private LogQueryEntry[]
mEntries
private static final String
FIELD_DELIM
private static final String
NEWLINE
Constructors Summary
public LogQueryResultImpl(String[] fieldNames, LogQueryEntry[] entries)

        mFieldNames   = fieldNames;
        mEntries      = entries;
    
public LogQueryResultImpl(List records)
Instantiate using result from {@link Logging#queryServerLog}. The first Object[] is a String[] of the field names. Subsequent Object[] are the data values.

        mFieldNames   = (String[])records.get( 0 );
        
        mEntries    = new LogQueryEntry[ records.size() - 1 ];
        for( int i = 1; i < mEntries.length; ++i )
        {
            mEntries[ i ]   = new LogQueryEntryImpl( records.get( i ) );
        }
    
Methods Summary
public booleanequals(java.lang.Object rhs)

        boolean equal   = rhs instanceof LogQueryResult;
        
        if ( equal )
        {
            final LogQueryResult    r   = (LogQueryResult)rhs;
            
            equal   = ArrayUtil.arraysEqual( getFieldNames(), r.getFieldNames() ) &&
                      ArrayUtil.arraysEqual( getEntries(), r.getEntries() );
                        
        }
        
        return equal;
    
public LogQueryEntry[]getEntries()

        return mEntries;
    
public java.lang.String[]getFieldNames()

        return mFieldNames;
    
public inthashCode()

 	    return ObjectUtil.hashCode( getFieldNames(), getEntries() );
 	
public java.lang.StringtoString()
Output a tab-delimited String with a header line. Each subsequent line represents another log record.

                                      
         
    
    
        final StringBuilder builder = new StringBuilder();
        
        for( final String s : getFieldNames() )
        {
            builder.append( s );
            builder.append( FIELD_DELIM );
        }
        builder.replace( builder.length() - 1, builder.length(), NEWLINE );
        
        for ( final LogQueryEntry entry : getEntries() )
        {
            final Object[]  fields  = entry.getFields();
            for( final Object o : fields )
            {
                builder.append( o.toString() );
                builder.append( FIELD_DELIM );
            }
            builder.replace( builder.length() - 1, builder.length(), NEWLINE );
        }
        
        return builder.toString();