001 package railo.runtime.text.xml.struct; 002 003 import java.lang.reflect.Method; 004 005 import org.w3c.dom.CDATASection; 006 import org.w3c.dom.DOMException; 007 import org.w3c.dom.Node; 008 import org.w3c.dom.Text; 009 010 import railo.runtime.exp.PageRuntimeException; 011 import railo.runtime.op.Caster; 012 import railo.runtime.type.Collection; 013 import railo.runtime.type.util.ArrayUtil; 014 015 /** 016 * 017 */ 018 public final class XMLCDATASectionStruct extends XMLNodeStruct implements CDATASection { 019 020 private CDATASection section; 021 022 /** 023 * constructor of the class 024 * @param section 025 * @param caseSensitive 026 */ 027 public XMLCDATASectionStruct(CDATASection section, boolean caseSensitive) { 028 super(section,caseSensitive); 029 this.section=section; 030 } 031 032 @Override 033 public Text splitText(int offset) throws DOMException { 034 return section.splitText(offset); 035 } 036 037 @Override 038 public int getLength() { 039 return section.getLength(); 040 } 041 042 @Override 043 public void deleteData(int offset, int count) throws DOMException { 044 section.deleteData(offset,count); 045 } 046 047 @Override 048 public String getData() throws DOMException { 049 return section.getData(); 050 } 051 052 @Override 053 public String substringData(int offset, int count) throws DOMException { 054 return section.substringData(offset,count); 055 } 056 057 @Override 058 public void replaceData(int offset, int count, String arg) 059 throws DOMException { 060 section.replaceData(offset,count,arg); 061 } 062 063 @Override 064 public void insertData(int offset, String arg) throws DOMException { 065 section.insertData(offset,arg); 066 } 067 068 @Override 069 public void appendData(String arg) throws DOMException { 070 section.appendData(arg); 071 } 072 073 @Override 074 public void setData(String data) throws DOMException { 075 section.setData(data); 076 } 077 078 public String getWholeText() { 079 // dynamic load to support jre 1.4 and 1.5 080 try { 081 Method m = section.getClass().getMethod("getWholeText", new Class[]{}); 082 return Caster.toString(m.invoke(section, ArrayUtil.OBJECT_EMPTY)); 083 } 084 catch (Exception e) { 085 throw new PageRuntimeException(Caster.toPageException(e)); 086 } 087 } 088 089 public boolean isElementContentWhitespace() { 090 // dynamic load to support jre 1.4 and 1.5 091 try { 092 Method m = section.getClass().getMethod("isElementContentWhitespace", new Class[]{}); 093 return Caster.toBooleanValue(m.invoke(section, ArrayUtil.OBJECT_EMPTY)); 094 } 095 catch (Exception e) { 096 throw new PageRuntimeException(Caster.toPageException(e)); 097 } 098 } 099 100 public Text replaceWholeText(String arg0) throws DOMException { 101 // dynamic load to support jre 1.4 and 1.5 102 try { 103 Method m = section.getClass().getMethod("replaceWholeText", new Class[]{arg0.getClass()}); 104 return (Text)m.invoke(section, new Object[]{arg0}); 105 } 106 catch (Exception e) { 107 throw new PageRuntimeException(Caster.toPageException(e)); 108 } 109 } 110 111 112 113 @Override 114 public Collection duplicate(boolean deepCopy) { 115 return new XMLCDATASectionStruct((CDATASection)section.cloneNode(deepCopy),caseSensitive); 116 } 117 118 119 @Override 120 public Node cloneNode(boolean deep) { 121 return new XMLCDATASectionStruct((CDATASection)section.cloneNode(deep),caseSensitive); 122 } 123 124 }