1 27 package org.htmlparser.tags; 28 29 import org.htmlparser.Attribute; 30 import org.htmlparser.lexer.Page; 31 import org.htmlparser.nodes.TagNode; 32 import org.htmlparser.util.ParserException; 33 34 37 public class MetaTag 38 extends 39 TagNode 40 { 41 44 private static final String [] mIds = new String [] {"META"}; 45 46 49 public MetaTag () 50 { 51 } 52 53 57 public String [] getIds () 58 { 59 return (mIds); 60 } 61 62 public String getHttpEquiv () 63 { 64 return (getAttribute ("HTTP-EQUIV")); 65 } 66 67 public String getMetaContent () 68 { 69 return (getAttribute ("CONTENT")); 70 } 71 72 public String getMetaTagName () 73 { 74 return (getAttribute ("NAME")); 75 } 76 77 public void setHttpEquiv(String httpEquiv) 78 { 79 Attribute equiv; 80 equiv = getAttributeEx ("HTTP-EQUIV"); 81 if (null != equiv) 82 equiv.setValue (httpEquiv); 83 else 84 getAttributesEx ().add (new Attribute ("HTTP-EQUIV", httpEquiv)); 85 } 86 87 public void setMetaTagContents(String metaTagContents) 88 { 89 Attribute content; 90 content = getAttributeEx ("CONTENT"); 91 if (null != content) 92 content.setValue (metaTagContents); 93 else 94 getAttributesEx ().add (new Attribute ("CONTENT", metaTagContents)); 95 } 96 97 public void setMetaTagName(String metaTagName) 98 { 99 Attribute name; 100 name = getAttributeEx ("NAME"); 101 if (null != name) 102 name.setValue (metaTagName); 103 else 104 getAttributesEx ().add (new Attribute ("NAME", metaTagName)); 105 } 106 107 110 public void doSemanticAction () throws ParserException 111 { 112 String httpEquiv; 113 String charset; 114 115 httpEquiv = getHttpEquiv (); 116 if ("Content-Type".equalsIgnoreCase (httpEquiv)) 117 { 118 charset = Page.getCharset (getAttribute ("CONTENT")); 119 getPage ().setEncoding (charset); 120 } 121 } 122 } 123 | Popular Tags |