1 27 package org.htmlparser.tags; 28 29 import org.htmlparser.Node; 30 import org.htmlparser.scanners.ScriptScanner; 31 import org.htmlparser.util.SimpleNodeIterator; 32 33 36 public class ScriptTag extends CompositeTag 37 { 38 41 private static final String [] mIds = new String [] {"SCRIPT"}; 42 43 46 private static final String [] mEndTagEnders = new String [] {"BODY", "HTML"}; 47 48 51 protected String mCode; 52 53 56 public ScriptTag () 57 { 58 setThisScanner (new ScriptScanner ()); 59 } 60 61 65 public String [] getIds () 66 { 67 return (mIds); 68 } 69 70 74 public String [] getEndTagEnders () 75 { 76 return (mEndTagEnders); 77 } 78 79 82 public String getLanguage() 83 { 84 return (getAttribute("LANGUAGE")); 85 } 86 87 93 public String getScriptCode () 94 { 95 String ret; 96 97 if (null != mCode) 98 ret = mCode; 99 else 100 ret = getChildrenHTML (); 101 102 return (ret); 103 } 104 105 109 public void setScriptCode (String code) 110 { 111 mCode = code; 112 } 113 114 117 public String getType() 118 { 119 return (getAttribute("TYPE")); 120 } 121 122 126 public void setLanguage (String language) 127 { 128 setAttribute ("LANGUAGE", language); 129 } 130 131 135 public void setType (String type) 136 { 137 setAttribute ("TYPE", type); 138 } 139 140 protected void putChildrenInto(StringBuffer sb) 141 { 142 Node node; 143 144 if (null != getScriptCode ()) 145 sb.append (getScriptCode ()); 146 else 147 for (SimpleNodeIterator e = children (); e.hasMoreNodes ();) 148 { 149 node = e.nextNode (); 150 sb.append (node.toHtml ()); 153 } 154 } 155 156 159 public String toString() 160 { 161 StringBuffer sb = new StringBuffer (); 162 sb.append("Script Node : \n"); 163 if (getLanguage () != null || getType () != null) 164 { 165 sb.append("Properties -->\n"); 166 if (getLanguage () != null && getLanguage ().length () !=0) 167 sb.append("[Language : "+ getLanguage ()+"]\n"); 168 if (getType () != null && getType ().length () != 0) 169 sb.append("[Type : "+ getType ()+"]\n"); 170 } 171 sb.append("\n"); 172 sb.append("Code\n"); 173 sb.append("****\n"); 174 sb.append(getScriptCode()+"\n"); 175 return sb.toString(); 176 } 177 } 178 | Popular Tags |