1 package com.quikj.application.web.talk.messaging; 2 3 import org.w3c.dom.*; 5 6 import net.n3.nanoxml.*; 7 8 public class HREFElement implements MediaElementInterface 9 { 10 public HREFElement() 11 { 12 } 13 14 public boolean parse(Object node) 15 { 16 if (TalkMessageParser.getParserType() == TalkMessageParser.DOM_PARSER) 17 { 18 return parseDOM((Node)node); 19 } 20 else { 22 return parseNANO((IXMLElement)node); 23 } 24 } 25 26 private boolean parseDOM(Node node) 27 { 28 Node message_node = node.getFirstChild(); 30 if (message_node == null) 31 { 32 errorMessage = "There is no URL specified for the HREF element"; 33 return false; 34 } 35 url = message_node.getNodeValue(); 36 return true; 37 } 38 39 private boolean parseNANO (IXMLElement node) 40 { 41 url = node.getContent(); 42 if (url == null) 43 { 44 errorMessage = "There is no URL specified for the HREF element"; 45 return false; 46 } 47 return true; 48 } 49 50 public String getURL() 51 { 52 return url; 53 } 54 55 public String getErrorMessage() 56 { 57 return errorMessage; 58 } 59 60 public void setURL(String url) 61 { 62 this.url = url; 63 } 64 65 public String format() 66 { 67 return new String ("<href>" 68 + TalkMessageParser.encodeXMLString(url) + "</href>" + '\n'); 69 } 70 71 private String errorMessage = ""; 72 private String url = ""; 73 } 74 | Popular Tags |