1 31 32 package org.opencms.xml.content; 33 34 import org.opencms.file.CmsObject; 35 import org.opencms.xml.CmsXmlUtils; 36 import org.opencms.xml.types.I_CmsXmlContentValue; 37 import org.opencms.xml.types.I_CmsXmlSchemaType; 38 39 import java.util.List ; 40 import java.util.Locale ; 41 42 51 public class CmsXmlContentValueSequence { 52 53 54 private CmsXmlContent m_content; 55 56 57 private Locale m_locale; 58 59 60 private String m_path; 61 62 63 private I_CmsXmlSchemaType m_schemaType; 64 65 66 private List m_values; 67 68 76 public CmsXmlContentValueSequence(String path, I_CmsXmlSchemaType schemaType, Locale locale, CmsXmlContent content) { 77 78 m_schemaType = schemaType; 79 m_locale = locale; 80 m_content = content; 81 m_values = m_content.getValues(path, m_locale); 82 m_path = CmsXmlUtils.removeXpathIndex(path); 83 } 84 85 95 public I_CmsXmlContentValue addValue(CmsObject cms, int index) { 96 97 I_CmsXmlContentValue newValue = m_content.addValue(cms, getPath(), getLocale(), index); 98 99 m_values = m_content.getValues(getPath(), getLocale()); 101 102 return newValue; 103 } 104 105 110 public int getElementCount() { 111 112 return m_values.size(); 113 } 114 115 127 public String getElementName() { 128 129 return m_schemaType.getName(); 130 } 131 132 137 public Locale getLocale() { 138 139 return m_locale; 140 } 141 142 149 public int getMaxOccurs() { 150 151 return m_schemaType.getMaxOccurs(); 152 } 153 154 161 public int getMinOccurs() { 162 163 return m_schemaType.getMinOccurs(); 164 } 165 166 173 public String getPath() { 174 175 return m_path; 176 } 177 178 185 public I_CmsXmlContentValue getValue(int index) { 186 187 return (I_CmsXmlContentValue)m_values.get(index); 188 } 189 190 197 public List getValues() { 198 199 return m_values; 200 } 201 202 207 public I_CmsXmlSchemaType getXmlSchemaType() { 208 209 return m_schemaType; 210 } 211 212 217 public boolean isExtendable() { 218 219 return getElementCount() < getMaxOccurs(); 220 } 221 222 227 public boolean isReducable() { 228 229 return getElementCount() > getMinOccurs(); 230 } 231 232 242 public boolean isSimpleType() { 243 244 return m_schemaType.isSimpleType(); 245 } 246 247 254 public void removeValue(int index) { 255 256 m_content.removeValue(getPath(), getLocale(), index); 257 258 m_values = m_content.getValues(getPath(), getLocale()); 260 } 261 } | Popular Tags |