?? classinfobuild.java
字號:
public String replaceTop1( String idx1,String name1,String idx2,String name2, String linkUrl,String type)
throws SaasApplicationException
{
String title ="<tr> "+
"<td width=\"50%\" valign=\"top\" bgcolor=\"EDF2F8\"> "+
" <a href=\""+linkUrl+type+ "&class_id=" + idx1 +"\" class=\"cpbt\">" + name1 + "</a><br>"+
createHtmlTemplate( idx1,name1,linkUrl,type) +
"</td> "+
"<td width=\"50%\" valign=\"top\"> "+
" <a href=\""+linkUrl+type+ "&class_id=" + idx2 +"\" class=\"cpbt\">"+name2+"</a><br> "+
createHtmlTemplate(idx2,name2,linkUrl,type ) +
"</td> "+
"</tr> ";
return title;
}
public String replaceTop2( String idx3,String name3,String idx4,String name4, String linkUrl,String type)
throws SaasApplicationException
{
String title ="<tr> "+
"<td valign=\"top\"> "+
" <a href=\""+linkUrl +type+ "&class_id=" + idx3 +"\" class=\"cpbt\">"+name3+"</a><br>"+
createHtmlTemplate(idx3,name3,linkUrl,type ) +
"</td> "+
"<td valign=\"top\" bgcolor=\"EDF2F8\"> "+
" <a href=\""+linkUrl +type+ "&class_id=" + idx4 +"\" class=\"cpbt\">"+name4+"</a><br>"+
createHtmlTemplate(idx4,name4,linkUrl,type ) +
"</td> "+
"</tr> ";
return title;
}
// 生成分類HTML
@SuppressWarnings("unused")
public String createHtmlTemplate(String id, String name, String linkUrl, String type ) throws SaasApplicationException {
String classHtml=""; //[4]= new String[]{};
ArrayList secondList = getClassInfoByUpType(id, type);
classHtml = classHtml + replaceTwo( secondList,linkUrl,type);
return classHtml;
}
public String replaceTwo( ArrayList secondList, String linkUrl,String type)
throws SaasApplicationException
{
String title="";
for( int i = 0; i < 9; i++ )
{
HashMap map = ( HashMap )secondList.get( i );
String id = map.get( "class_id" ).toString();
String name = "",allName="";
if( map.get( "class_name" ) != null )
{
allName = map.get( "class_name" ).toString();
if( allName.length() > 4 )
{
name = StringUtil.getLimitLengthString( allName,"",9 );
}
else
{
name = allName;
for( int j = 0; j < 6 - name.length(); j++ )
{
name = name + " ";
}
}
}
title = title + "<a href=\"" + linkUrl + type + "&class_id=" + id +"\" title=\"" + allName + "\"class=\"news\">" + name + " |</a> ";
}
return title;
}
//生成分類Html
@SuppressWarnings("unchecked")
public String creatHtml(Map map1,Map map2,String linkUrl, String type)throws SaasApplicationException
{
String htmlSource=getClassSourceStr();
String leftTitleHtml="", rightTitleHtml="", leftHtml="", rightHtml="";
List Left_list=new ArrayList();
List Ritht_list=new ArrayList();
//log.LOG_INFO("生成分類Html...");
if (map1 != null && map1.size() > 0)
{
Iterator it = map1.entrySet().iterator();
while (it.hasNext())
{
Map.Entry entry = (Map.Entry) it.next();
String id =String.valueOf( entry.getKey() );
Object name = entry.getValue();
// log.LOG_INFO("id=="+id);
leftTitleHtml=leftTitleHtml+"<a href=" + linkUrl + id + ">" + name + "</a> ";
List l_list=getClassInfoByLimit( id,type,10 );
if( l_list !=null && l_list.size() > 0 )
{
Left_list.addAll(l_list);
}
}
if( Left_list !=null && Left_list.size() > 0 )
{
for (int j=1,i = 0; i < Left_list.size(); i++,j++)
{
HashMap map=(HashMap)Left_list.get(i);
String idx = map.get("class_id").toString();
String name = map.get("class_name").toString();
if(j%5==0)
{
leftHtml=leftHtml+"<a href=" + linkUrl + idx + ">" + name + "</a> ";
}
else
{
leftHtml=leftHtml+"<a href=" + linkUrl + idx + ">" + name + "</a> ";
}
}
}
htmlSource= StrReplace.replace(htmlSource,"{#s_left_title#}", leftTitleHtml );
htmlSource= StrReplace.replace(htmlSource,"{#left:list#}",leftHtml);
}
try {
if (map2 != null && map2.size() > 0) {
Iterator it = map2.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
String id =String.valueOf(entry.getKey());
Object name = entry.getValue();
// log.LOG_INFO("name=="+name);
rightTitleHtml=rightTitleHtml+"<a href=" + linkUrl + id + ">" + name + "</a> ";
List r_list=getClassInfoByLimit(id,type,10);
if(r_list !=null && r_list.size()>0){
Ritht_list.addAll(r_list);
}
}
if(Ritht_list !=null && Ritht_list.size()>0){
for (int j=1,i = 0; i < Ritht_list.size(); i++,j++) {
HashMap map=(HashMap)Ritht_list.get(i);
String idx = map.get("class_id").toString();
String name = map.get("class_name").toString();
if(j%5==0){
rightHtml=rightHtml+"<a href=" + linkUrl + idx + ">" + name + "</a>";
}else{
rightHtml=rightHtml+"<a href=" + linkUrl + idx + ">" + name + "</a> ";
}
}
}
htmlSource= StrReplace.replace(htmlSource,"{#s_right_title#}", rightTitleHtml );
htmlSource= StrReplace.replace(htmlSource,"{#right:list#}",rightHtml);
}
}
catch (RuntimeException e) {
log.LOG_INFO(e.getMessage());
}
//log.LOG_INFO("htmlSource==" + htmlSource.length() + htmlSource );
htmlSource= StrReplace.replace(htmlSource,"{#other:list#}","");
return htmlSource;
}
// 替換模板
public static String replace(String strSource, String strFrom, String strTo)
{
String strDest = "";
int intFromLen = strFrom.length();
int intPos;
while ( ( intPos = strSource.indexOf( strFrom )) != -1 )
{
strDest = strDest + strSource.substring(0, intPos);
strDest = strDest + strTo;
strSource = strSource.substring(intPos + intFromLen);
}
strDest = strDest + strSource;
return strDest;
}
/**
* 替換源
*
* @return
*/
public static String getClassSourceStr(){
String class_Info=
" <li class='new-index-contentone-bottom2'> "+
" <div class='new-index-contentone-bottom4'> "+
" <div class='new-index-contentone-bottom6'> "+
" {#s_left_title#} "+
" </div> "+
" <ol> "+
" {#left:list#} "+
" </ol> "+
" </div> "+
" <div class='new-index-contentone-bottom5'> "+
" <div class='new-index-contentone-bottom6'> "+
" {#s_right_title#} "+
" </div> "+
" <ol> "+
" {#right:list#} "+
" </ol> "+
" </div> "+
" </li> ";
return class_Info;
}
public static ArrayList getList()
{
ArrayList list=new ArrayList();
for(int i=0;i<10;i++)
{
HashMap map=new HashMap();
String name="name"+i;
String id="idx"+i;
map.put("class_id", id);
map.put("class_name", name);
list.add(map);
}
return list;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -