1 31 32 package org.opencms.xml.types; 33 34 import org.opencms.file.CmsObject; 35 import org.opencms.main.CmsRuntimeException; 36 import org.opencms.xml.CmsXmlContentDefinition; 37 import org.opencms.xml.I_CmsXmlDocument; 38 39 import java.util.Locale ; 40 41 import org.dom4j.Element; 42 43 52 public class CmsXmlNestedContentDefinition extends A_CmsXmlContentValue implements I_CmsXmlSchemaType { 53 54 55 private CmsXmlContentDefinition m_nestedContentDefinition; 56 57 66 public CmsXmlNestedContentDefinition( 67 CmsXmlContentDefinition contentDefinition, 68 I_CmsXmlDocument document, 69 Element element, 70 Locale locale, 71 I_CmsXmlSchemaType type) { 72 73 super(document, element, locale, type); 74 m_nestedContentDefinition = contentDefinition; 75 } 76 77 85 public CmsXmlNestedContentDefinition( 86 CmsXmlContentDefinition contentDefinition, 87 String name, 88 String minOccurs, 89 String maxOccurs) { 90 91 super(name, minOccurs, maxOccurs); 92 m_nestedContentDefinition = contentDefinition; 93 } 94 95 98 public I_CmsXmlContentValue createValue(I_CmsXmlDocument document, Element element, Locale locale) { 99 100 return new CmsXmlNestedContentDefinition(m_nestedContentDefinition, document, element, locale, this); 101 } 102 103 106 public Element generateXml(CmsObject cms, I_CmsXmlDocument document, Element root, Locale locale) { 107 108 Element element = root.addElement(getName()); 110 element = m_nestedContentDefinition.createDefaultXml(cms, document, element, Locale.ENGLISH); 112 return element; 114 } 115 116 121 public CmsXmlContentDefinition getNestedContentDefinition() { 122 123 return m_nestedContentDefinition; 124 } 125 126 129 public String getSchemaDefinition() { 130 131 throw new CmsRuntimeException(Messages.get().container(Messages.ERR_NESTED_SCHEMA_0)); 132 } 133 134 137 public String getStringValue(CmsObject cms) throws CmsRuntimeException { 138 139 throw new CmsRuntimeException(Messages.get().container(Messages.ERR_NESTED_GETVALUE_0)); 140 } 141 142 145 public String getTypeName() { 146 147 return m_nestedContentDefinition.getTypeName(); 148 } 149 150 155 public boolean isSimpleType() { 156 157 return false; 158 } 159 160 163 public I_CmsXmlSchemaType newInstance(String name, String minOccurs, String maxOccurs) { 164 165 throw new CmsRuntimeException(Messages.get().container(Messages.ERR_NESTED_NEWINSTANCE_0)); 166 } 167 168 171 public void setStringValue(CmsObject cms, String value) { 172 173 throw new CmsRuntimeException(Messages.get().container(Messages.ERR_NESTED_SETVALUE_0)); 174 } 175 } | Popular Tags |