001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software GmbH & Co. KG, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.xml.types; 029 030import org.opencms.file.CmsObject; 031import org.opencms.xml.I_CmsXmlDocument; 032 033import java.util.Locale; 034 035import org.dom4j.Element; 036 037/** 038 * Provides access to the value of a specific XML content node.<p> 039 * 040 * @since 6.0.0 041 */ 042public interface I_CmsXmlContentValue extends I_CmsXmlSchemaType { 043 044 /** 045 * Returns the XML content instance this value belongs to.<p> 046 * 047 * @return the XML content instance this value belongs to 048 */ 049 I_CmsXmlDocument getDocument(); 050 051 /** 052 * Returns the original XML element of this XML content value.<p> 053 * 054 * @return the original XML element of this XML content value 055 */ 056 Element getElement(); 057 058 /** 059 * Returns the node index of this XML content value in the source XML document, 060 * starting with 0, with special handling of elements in choice groups.<p> 061 * 062 * This is useful in case there are more than one elements 063 * with the same XML node name in the source XML document.<p> 064 * 065 * Elements in XML choice groups will share the same number space, so a choice 066 * sequence will be numbered like this: 067 * <code>Title[1], Text[2], Title[3], Image[4]</code><p> 068 * 069 * @return the index of this XML content node in the source document with special handling of elements in choice groups 070 * 071 * @see #getXmlIndex() 072 */ 073 int getIndex(); 074 075 /** 076 * Returns the locale of this XML content value was generated for.<p> 077 * 078 * @return the locale of this XML content value was generated for 079 */ 080 Locale getLocale(); 081 082 /** 083 * Returns the total number of XML elements of this type that currently exist in the source document.<p> 084 * 085 * @return the total number of XML elements of this type that currently exist in the source document 086 */ 087 int getMaxIndex(); 088 089 /** 090 * Returns the path of this XML content value in the source document.<p> 091 * 092 * @return the path of this XML content value in the source document 093 */ 094 String getPath(); 095 096 /** 097 * Returns the value of this XML content node as a plain text String.<p> 098 * 099 * Plain text in this context means a pure textual representation 100 * of the content (i.e. without html tags). 101 * The plain text may be <code>null</code>, too, if there is no sound or useful 102 * textual representation (i.e. color values).<p> 103 * 104 * @param cms an initialized instance of a CmsObject 105 * 106 * @return the value of this XML content node as a plain text String 107 */ 108 String getPlainText(CmsObject cms); 109 110 /** 111 * Returns the value of this XML content node as a String.<p> 112 * 113 * @param cms an initialized instance of a CmsObject 114 * 115 * @return the value of this XML content node as a String 116 */ 117 String getStringValue(CmsObject cms); 118 119 /** 120 * Returns the node index of this XML content value in the source XML document, 121 * starting with 0, based on the XML ordering.<p> 122 * 123 * Elements in choice groups will be numbered like this: 124 * <code>Title[1], Text[1], Title[2], Image[1]</code><p> 125 * 126 * @return the index of this XML content node in the source document with special handling of elements in choice groups 127 * 128 * @see #getIndex() 129 */ 130 int getXmlIndex(); 131 132 /** 133 * Returns <code>true</code> in case this value is searchable by default with 134 * the integrated full text search.<p> 135 * 136 * @return <code>true</code> in case this value is searchable by default 137 */ 138 boolean isSearchable(); 139 140 /** 141 * Moves this XML content value one position down in the source document, if possible.<p> 142 * 143 * If the XML content value is already the first in it's sequence, it is not moved.<p> 144 */ 145 void moveDown(); 146 147 /** 148 * Moves this XML content value one position up in the source document, if possible.<p> 149 * 150 * If the XML content value is already the last in it's sequence, it is not moved.<p> 151 */ 152 void moveUp(); 153 154 /** 155 * Sets the provided String as value of this XML content node.<p> 156 * 157 * This method does provide processing of the content based on the 158 * users current OpenCms context. This can be used e.g. for link 159 * extraction and replacement in the content.<p> 160 * 161 * @param cms an initialized instance of a CmsObject 162 * @param value the value to set 163 * 164 */ 165 void setStringValue(CmsObject cms, String value); 166}