1 19 20 25 26 package org.netbeans.modules.css.visual.parser; 27 28 import java.util.StringTokenizer ; 29 import org.netbeans.modules.css.visual.model.CssStyleData; 30 31 36 public class CssStyleParser { 37 38 CssStyleData cssStyleDate = null; 39 40 public CssStyleParser(){ 41 this(new CssStyleData()); 42 } 43 44 public CssStyleParser(CssStyleData styleDate){ 45 this.cssStyleDate = styleDate; 46 } 47 48 52 public CssStyleData parse(String cssStyleString){ 53 if((cssStyleString == null) || cssStyleString.equals("")){ 54 return cssStyleDate; 55 } 56 cssStyleString = cssStyleString.replaceAll(""", "\""); StringTokenizer styleProperties = new StringTokenizer (cssStyleString,";"); while(styleProperties.hasMoreTokens()){ 59 String styleProperty = styleProperties.nextToken().trim(); 60 int delIndex = styleProperty.indexOf(":"); 62 if(delIndex != -1){ 63 String propertyName = styleProperty.substring(0,delIndex).trim(); String propertyValue = styleProperty.substring(delIndex + 1).trim(); cssStyleDate.addProperty(propertyName, propertyValue); 68 } 69 } 70 return cssStyleDate; 71 } 72 } 73 | Popular Tags |