KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > commons > xhtml > Attributes


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.commons.xhtml;
6
7 /**
8  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
9  * @since Nov 7, 2004
10  * @version $Id$
11  */

12 public class Attributes {
13   StringBuffer JavaDoc b = null ;
14   
15   public Attributes() {
16     b = new StringBuffer JavaDoc(50) ;
17   }
18   
19   public Attributes(String JavaDoc s) {
20     b = new StringBuffer JavaDoc(s.length()) ;
21     String JavaDoc[] temp = s.split("\\|") ;
22     for(int i = 0 ; i < temp.length; i++) {
23       temp[i] = temp[i].trim() ;
24       appendAttribute(temp[i]) ;
25     }
26   }
27   
28   public void addAttribute(String JavaDoc name, String JavaDoc value) {
29     b.append(" ").append(name).append("='").append(value).append("'") ;
30   }
31   
32   private void appendAttribute(String JavaDoc s) {
33     String JavaDoc[] temp = s.split(":") ;
34     if(temp.length != 2) return ;
35     b.append(" ").append(temp[0].trim()).append("='").append(temp[1].trim()).append("'" );
36   }
37   
38   public String JavaDoc toString() { return b.toString() ; }
39 }
Popular Tags