Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010 JBoss Inc
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.drools.guvnor.server.util;
 
 import java.util.List;
 

Deprecated:
in favour of AbstractPagedTable
 
 public class RowLoader {
     private String[] headers;
     private String[] headerTypes;
     List<Method>             extractors;
 
     public String[] getHeaders() {
         return ;
     }
 
     public String[] getHeaderTypes() {
         return ;
     }
 
     public String[] getRow(AssetItem item) {
         String[] row = new String[.];
         for ( int i = 0; i < row.lengthi++ ) {
             Method meth = .geti );
             try {
                 Object val = meth.invokeitem,
                                           (Object[]) null );
                 if ( val instanceof String ) {
                     String s = (Stringval;
                     if ( s.length() > 64 ) {
                         s = s.substring( 0,
                                          61 ) + "...";
                     }
                     row[i] = s;
 
                 } else if ( val instanceof Calendar ) {
                     row[i] = Long.toString(((Calendarval).getTime().getTime());//DF.format( ((Calendar) val).getTime() );
                 } else {
                     row[i] = val.toString();
                 }
             } catch ( Exception e ) {
                 if ( e instanceof RuntimeException ) throw (RuntimeExceptione;
                 throw new RulesRepositoryExceptione );
             }
         }
         return row;
     }
 
 
     public RowLoader(String resourcename) {
 
         InputStream in = RowLoader.class.getResourceAsStream"/" + resourcename + ".properties" );
         if (in == null) {
             throw new IllegalStateException("can't find resource name: /" + resourcename + ".properties");
         }
         BufferedReader reader = new BufferedReadernew InputStreamReaderin ) );
         List<Stringfields = new ArrayList<String>();
         List<StringfieldTypes = new ArrayList<String>();
          = new ArrayList<Method>();
         String line;
 
         try {
 
             while ( (line = reader.readLine()) != null ) {
                 if ( !line.startsWith"#" ) && !line.trim().equals"" ) ) {
                     StringTokenizer tok = new StringTokenizerline,
                                                                "=" );
                     String field = tok.nextToken();
                     String method = tok.nextToken();
                     fields.addfield );
 
                     final Method meth = AssetItem.class.getMethodmethod,
                                                                    new Class[]{} );
                    .addmeth );
                    fieldTypes.addmeth.getGenericReturnType().toString() );
                }
            }
        } catch ( Exception e ) {
            if ( e instanceof RuntimeException ) {
                throw (RuntimeExceptione;
            }
            throw new RulesRepositoryExceptione );
        } finally {
            closeStreamreader );
        }
         = fields.toArraynew String[fields.size()] );
         = fieldTypes.toArraynew String[fieldTypes.size()] );
    }
    private void closeStream(BufferedReader reader) {
        try {
            reader.close();
        } catch ( IOException e ) {
            e.printStackTrace();
        }
    }
New to GrepCode? Check out our FAQ X