1 5 package org.exoplatform.commons.xhtml; 6 7 12 public class Attributes { 13 StringBuffer b = null ; 14 15 public Attributes() { 16 b = new StringBuffer (50) ; 17 } 18 19 public Attributes(String s) { 20 b = new StringBuffer (s.length()) ; 21 String [] 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 name, String value) { 29 b.append(" ").append(name).append("='").append(value).append("'") ; 30 } 31 32 private void appendAttribute(String s) { 33 String [] 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 toString() { return b.toString() ; } 39 } | Popular Tags |