View Javadoc

1   /*
2    * Copyright 2004-2008 the Seasar Foundation and the Others.
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, 
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.seasar.uruma.util;
17  
18  /**
19   * HTMLタグの文字列を生成するユーティリティです。<br />
20   * 
21   * @author y.sugigami
22   */
23  public class HtmlTagUtil {
24  
25      public static String createTable() {
26          return "<table> ";
27      }
28  
29      public static String createTable(final String key, final String value) {
30          return "<table><tr><td class=\"header\" colspan=\"2\">" + key + " = "
31                  + value + "</td></tr>";
32      }
33  
34      public static String closeTable() {
35          return "</table> ";
36      }
37  
38      public static String createTrSub1(final String key, final String value) {
39          return "<tr><td class=\"sub_header\" colspan=\"2\">" + key + " = "
40                  + value + "</td></tr>";
41      }
42  
43      public static String createTrSub2(final String key, final String value) {
44          return "<tr><td class=\"sub_sub_header\" colspan=\"2\">" + key + " = "
45                  + value + "</td></tr>";
46      }
47  
48      public static String createTr(final String td1, final String td2) {
49          String tmp = "";
50          tmp += "<tr>";
51          tmp += "<th>";
52          tmp += td1;
53          tmp += "</td>";
54          tmp += "<td>";
55          tmp += td2;
56          tmp += "</td>";
57          tmp += "</td>";
58          return tmp;
59      }
60  
61      public static String createH1(final String value) {
62          return "<h1>" + value + "</h1>";
63      }
64  
65      public static String createH2(final String value) {
66          return "<h2>" + value + "</h2>";
67      }
68  
69      public static String createH3(final String value) {
70          return "<h3>" + value + "</h3>";
71      }
72  
73      public static String createHeader() {
74          String header = "<html><head>\n";
75          header += "<style type=\"text/css\">\n";
76          header += "<!--\n";
77          header += "h1 {font-size: 24px; padding: 2px; color: #ffffff; background-color: #666699; line-height: 130%;}\n";
78          header += "h2 {font-size: 18px; padding: 2px; color: #ffffff; background-color: #7778AA; line-height: 130%;}\n";
79          header += "h3 {font-size: 16px; padding: 2px; color: #ffffff; background-color: #9999CC; line-height: 130%;}\n";
80          header += "\n";
81          header += "table {font-size: 12px; color: #666666; border: 1px solid #CCCCCC; border-collapse: separate; border-spacing: 1px; margin-left: 10px;}\n";
82          header += "th {padding: 5px; border-right: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; background-color: #E1E2E6; text-align: left;}\n";
83          header += "td {padding: 5px; border-right: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; background-color: #EFF2F3;}\n";
84          header += "td.header {font-weight: bold; font-size: 18px; padding: 5px; border-right: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; background-color: #666699; color: #ffffff;}\n";
85          header += "td.sub_header {font-weight: bold; font-size: 12px; padding: 5px; border-right: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; background-color: #666699; color: #ffffff;}\n";
86          header += "td.sub_sub_header {font-weight: bold; font-size: 12px; padding: 5px; border-right: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; background-color: #AAAADD; color: #ffffff;}\n";
87          header += "\n";
88          header += "-->\n";
89          header += "</style>\n";
90          header += "</head>\n";
91          header += "<body>\n";
92  
93          return header;
94      }
95  
96      public static String closeHeader() {
97          return "</body></html>";
98      }
99  }