Home | History | Annotate | Download | only in src
      1 /*
      2  * Copyright (C) 2015 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.ahat;
     18 
     19 import java.util.List;
     20 
     21 /**
     22  * An interface for rendering a page of content to the user.
     23  */
     24 interface Doc extends AutoCloseable {
     25   /**
     26    * Output the title of the page.
     27    */
     28   void title(String format, Object... args);
     29 
     30   /**
     31    * Print a line of text for a page menu.
     32    */
     33   void menu(DocString string);
     34 
     35   /**
     36    * Start a new section with the given title.
     37    */
     38   void section(String title);
     39 
     40   /**
     41    * Print a line of text in a normal font.
     42    */
     43   void println(DocString string);
     44 
     45   /**
     46    * Print a line of text in a large font that is easy to see and click on.
     47    */
     48   void big(DocString string);
     49 
     50   /**
     51    * Start a table with the given columns.
     52    *
     53    * An IllegalArgumentException is thrown if no columns are provided.
     54    *
     55    * This should be followed by calls to the 'row' method to fill in the table
     56    * contents and the 'end' method to end the table.
     57    */
     58   void table(Column... columns);
     59 
     60   /**
     61    * Start a table with the following heading structure:
     62    *   |  description  |  c2  | c3 | ... |
     63    *   | h1 | h2 | ... |      |    |     |
     64    *
     65    * Where subcols describes h1, h2, ...
     66    * and cols describes c2, c3, ...
     67    *
     68    * This should be followed by calls to the 'row' method to fill in the table
     69    * contents and the 'end' method to end the table.
     70    */
     71   void table(DocString description, List<Column> subcols, List<Column> cols);
     72 
     73   /**
     74    * Add a row to the currently active table.
     75    * The number of values must match the number of columns provided for the
     76    * currently active table.
     77    */
     78   void row(DocString... values);
     79 
     80   /**
     81    * Start a new description list.
     82    *
     83    * This should be followed by calls to description() and finally a call to
     84    * end().
     85    */
     86   void descriptions();
     87 
     88   /**
     89    * Add a description to the currently active description list.
     90    */
     91   void description(DocString key, DocString value);
     92 
     93   /**
     94    * End the currently active table or description list.
     95    */
     96   void end();
     97 }
     98