1 17 package org.apache.ws.jaxme.xs.xml.impl; 18 19 import java.util.ArrayList ; 20 import java.util.List ; 21 22 import javax.xml.XMLConstants ; 23 import javax.xml.parsers.ParserConfigurationException ; 24 25 import org.apache.ws.jaxme.xs.XSParser; 26 import org.apache.ws.jaxme.xs.parser.DOMBuilder; 27 import org.apache.ws.jaxme.xs.xml.*; 28 import org.xml.sax.ContentHandler ; 29 import org.xml.sax.SAXException ; 30 31 32 51 public class XsEDocumentationImpl extends XsObjectImpl implements XsEDocumentation { 52 private XmlLang lang; 53 private XsAnyURI source; 54 private List childs = new ArrayList (); 55 private boolean isSimple; 56 57 protected XsEDocumentationImpl(XsObject pParent) { 58 super(pParent); 59 } 60 61 protected void addChild(Object pObject) { 62 childs.add(pObject); 63 } 64 65 public void setLang(XmlLang pLang) { 66 lang = pLang; 67 } 68 69 public XmlLang getLang() { 70 return lang; 71 } 72 73 public void setSource(XsAnyURI pSource) { 74 source = pSource; 75 } 76 77 public XsAnyURI getSource() { 78 return source; 79 } 80 81 public void addText(String pText) { 82 childs.add(pText); 83 } 84 85 public String getText() { 86 StringBuffer sb = new StringBuffer (); 87 for (int i = 0; i < childs.size(); i++) { 88 Object o = childs.get(i); 89 if (o instanceof String ) { 90 sb.append(o); 91 } 92 } 93 return sb.toString(); 94 } 95 96 public boolean isTextOnly() { 97 for (int i = 0; i < childs.size(); i++) { 98 if (!(childs.get(i) instanceof String )) { 99 return false; 100 } 101 } 102 return true; 103 } 104 105 public Object [] getChilds() { 106 return childs.toArray(); 107 } 108 109 public boolean setAttribute(String pQName, String pNamespaceURI, String pLocalName, String pValue) { 110 if (XMLConstants.XML_NS_URI.equals(pNamespaceURI) && "lang".equals(pLocalName)) { 111 setLang(new XmlLang(pValue)); 112 return true; 113 } else { 114 return false; 115 } 116 } 117 118 public ContentHandler getChildHandler(String pQName, String pNamespaceURI, String pLocalName) 119 throws SAXException { 120 isSimple = false; 121 try { 122 DOMBuilder db = new DOMBuilder(); 123 addChild(db.getDocument()); 124 return db; 125 } catch (ParserConfigurationException e) { 126 throw new SAXException (e); 127 } 128 } 129 } 130 | Popular Tags |