Tabnine Logo
CmsXmlContent.getValues
Code IndexAdd Tabnine to your IDE (free)

How to use
getValues
method
in
org.opencms.xml.content.CmsXmlContent

Best Java code snippets using org.opencms.xml.content.CmsXmlContent.getValues (Showing top 20 results out of 315)

origin: org.opencms/opencms-core

/** Helper to read an optional String value list.
 * @param path The XML path of the element to read.
 * @return The String list stored in the XML, or <code>null</code> if the value could not be read.
 */
protected List<String> parseOptionalStringValues(final String path) {
  final List<I_CmsXmlContentValue> values = m_xml.getValues(path, m_locale);
  if (values == null) {
    return null;
  } else {
    List<String> stringValues = new ArrayList<String>(values.size());
    for (I_CmsXmlContentValue value : values) {
      stringValues.add(value.getStringValue(null));
    }
    return stringValues;
  }
}
origin: org.opencms/opencms-solr

/**
 * Generates a new content sequence element from the given type, content and content definition.<p>
 * 
 * @param path the path in the document to generate the value sequence for
 * @param schemaType the schema type to generate the sequence element for
 * @param locale the locale to get the content values from
 * @param content the XML content to generate the sequence element out of
 */
public CmsXmlContentValueSequence(String path, I_CmsXmlSchemaType schemaType, Locale locale, CmsXmlContent content) {
  m_schemaType = schemaType;
  m_locale = locale;
  m_content = content;
  m_values = m_content.getValues(path, m_locale);
  m_path = CmsXmlUtils.removeXpathIndex(path);
}
origin: org.opencms/opencms-core

/**
 * Returns all values of the given element path.<p>
 *
 * @param elementPath the element path
 * @param locale the content locale
 *
 * @return the values
 */
public List<I_CmsXmlContentValue> getValuesByPath(String elementPath, Locale locale) {
  String[] pathElements = elementPath.split("/");
  List<I_CmsXmlContentValue> values = getValues(pathElements[0], locale);
  for (int i = 1; i < pathElements.length; i++) {
    List<I_CmsXmlContentValue> subValues = new ArrayList<I_CmsXmlContentValue>();
    for (I_CmsXmlContentValue value : values) {
      subValues.addAll(getValues(CmsXmlUtils.concatXpath(value.getPath(), pathElements[i]), locale));
    }
    if (subValues.isEmpty()) {
      values = Collections.emptyList();
      break;
    }
    values = subValues;
  }
  return values;
}
origin: org.opencms/opencms-core

/**
 * Removes all surplus values of locale independent fields in the other locales.<p>
 *
 * @param elementPath the element path
 * @param valueCount the value count
 * @param sourceLocale the source locale
 */
private void removeSurplusValuesInOtherLocales(String elementPath, int valueCount, Locale sourceLocale) {
  for (Locale locale : getLocales()) {
    if (locale.equals(sourceLocale)) {
      continue;
    }
    List<I_CmsXmlContentValue> localeValues = getValues(elementPath, locale);
    for (int i = valueCount; i < localeValues.size(); i++) {
      removeValue(elementPath, locale, 0);
    }
  }
}
origin: org.opencms/opencms-core

/** Helper to read a mandatory String value list.
 * @param path The XML path of the element to read.
 * @return The String list stored in the XML, or <code>null</code> if the value could not be read.
 * @throws Exception thrown if the list of String values can not be read.
 */
protected List<I_CmsFacetQueryItem> parseFacetQueryItems(final String path) throws Exception {
  final List<I_CmsXmlContentValue> values = m_xml.getValues(path, m_locale);
  if (values == null) {
    return null;
  } else {
    List<I_CmsFacetQueryItem> parsedItems = new ArrayList<I_CmsFacetQueryItem>(values.size());
    for (I_CmsXmlContentValue value : values) {
      I_CmsFacetQueryItem item = parseFacetQueryItem(value.getPath() + "/");
      if (null != item) {
        parsedItems.add(item);
      } else {
        // TODO: log
      }
    }
    return parsedItems;
  }
}
origin: org.opencms/opencms-core

/**
 * Returns the content values of the requested locale.<p>
 *
 * @param content the content document
 * @param locale the content locale
 *
 * @return the values
 */
protected Map<String, String> getContentValues(CmsXmlContent content, Locale locale) {
  Map<String, String> result = new HashMap<String, String>();
  List<I_CmsXmlContentValue> values = content.getValues(locale);
  for (I_CmsXmlContentValue value : values) {
    if (value.isSimpleType()) {
      result.put(value.getPath(), value.getStringValue(m_cms));
    }
  }
  return result;
}
origin: org.opencms/opencms-core

/** Returns a map with additional request parameters, mapping the parameter names to Solr query parts.
 * @return A map with additional request parameters, mapping the parameter names to Solr query parts.
 */
private Map<String, String> getAdditionalRequestParameters() {
  List<I_CmsXmlContentValue> parametersToParse = m_xml.getValues(XML_ELEMENT_ADDITIONAL_PARAMETERS, m_locale);
  Map<String, String> result = new HashMap<String, String>(parametersToParse.size());
  for (I_CmsXmlContentValue additionalParam : parametersToParse) {
    String param = m_xml.getValue(
      additionalParam.getPath() + "/" + XML_ELEMENT_ADDITIONAL_PARAMETERS_PARAM,
      m_locale).getStringValue(null);
    String solrQuery = m_xml.getValue(
      additionalParam.getPath() + "/" + XML_ELEMENT_ADDITIONAL_PARAMETERS_SOLRQUERY,
      m_locale).getStringValue(null);
    result.put(param, solrQuery);
  }
  return result;
}
origin: org.opencms/opencms-core

/**
 * Reads the referenced formatters.<p>
 *
 * @param xmlContent the XML content
 *
 * @return the referenced formatters
 */
private Map<String, CmsUUID> readReferencedFormatters(CmsXmlContent xmlContent) {
  Map<String, CmsUUID> result = new LinkedHashMap<String, CmsUUID>();
  List<I_CmsXmlContentValue> formatters = xmlContent.getValues(
    CmsMacroFormatterResolver.N_FORMATTERS,
    CmsLocaleManager.MASTER_LOCALE);
  for (I_CmsXmlContentValue formatterValue : formatters) {
    CmsXmlVfsFileValue file = (CmsXmlVfsFileValue)xmlContent.getValue(
      formatterValue.getPath() + "/" + CmsMacroFormatterResolver.N_FORMATTER,
      CmsLocaleManager.MASTER_LOCALE);
    CmsUUID formatterId = file.getLink(m_cms).getStructureId();
    String macroName = xmlContent.getStringValue(
      m_cms,
      formatterValue.getPath() + "/" + CmsMacroFormatterResolver.N_MACRO_NAME,
      CmsLocaleManager.MASTER_LOCALE);
    result.put(macroName, formatterId);
  }
  return result;
}
origin: org.opencms/opencms-core

  /**
   * Removes the value element of the sequence type at the selected index from XML content document.<p>
   *
   * @param index the index where to remove the value element
   *
   * @see CmsXmlContent#removeValue(String, Locale, int)
   */
  public void removeValue(int index) {

    m_content.removeValue(getPath(), getLocale(), index);

    // re-initialize the value list
    m_values = m_content.getValues(getPath(), getLocale());
  }
}
origin: org.opencms/opencms-core

/**
 * Adds a value element of the type indicated by the given xpath
 * at the selected index to the XML content document.<p>
 *
 * @param cms the current users OpenCms context
 * @param xpath the path that indicates the element type in the content definition
 * @param index the index where to add the new value element
 *
 * @return the added XML content value element
 *
 * @see CmsXmlContent#addValue(CmsObject, String, Locale, int)
 * @see #addValue(CmsObject, I_CmsXmlSchemaType, int)
 * @see #addValue(CmsObject, int)
 */
public I_CmsXmlContentValue addValue(CmsObject cms, String xpath, int index) {
  I_CmsXmlContentValue newValue = m_content.addValue(cms, xpath, getLocale(), index);
  // re-initialize the value list
  m_values = m_content.getValues(getPath(), getLocale());
  return newValue;
}
origin: org.opencms/opencms-solr

  /**
   * Removes the value element of the sequence type at the selected index from XML content document.<p> 
   * 
   * @param index the index where to remove the value element
   * 
   * @see CmsXmlContent#removeValue(String, Locale, int)
   */
  public void removeValue(int index) {

    m_content.removeValue(getPath(), getLocale(), index);

    // re-initialize the value list
    m_values = m_content.getValues(getPath(), getLocale());
  }
}
origin: org.opencms/opencms-core

  /**
   * @see org.opencms.i18n.CmsVfsResourceBundle.I_Loader#loadData(org.opencms.file.CmsObject, org.opencms.i18n.CmsVfsBundleParameters)
   */
  public Map<Locale, Map<String, String>> loadData(CmsObject cms, CmsVfsBundleParameters params) throws Exception {

    CmsFile file = cms.readFile(params.getBasePath());
    CmsXmlContent content = CmsXmlContentFactory.unmarshal(cms, file);
    Map<Locale, Map<String, String>> result = Maps.newHashMap();
    for (Locale locale : content.getLocales()) {
      List<I_CmsXmlContentValue> messages = content.getValues(N_MESSAGE, locale);
      Map<String, String> currentLocale = new HashMap<String, String>();
      for (I_CmsXmlContentValue messageValue : messages) {
        String path = messageValue.getPath();
        I_CmsXmlContentValue keyValue = content.getValue(CmsXmlUtils.concatXpath(path, N_KEY), locale);
        String keyStr = keyValue.getStringValue(cms);
        // Ignore leading/trailing spaces in the key to protect from user error
        keyStr = keyStr.trim();
        I_CmsXmlContentValue valueValue = content.getValue(CmsXmlUtils.concatXpath(path, N_VALUE), locale);
        String valueStr = valueValue.getStringValue(cms);
        currentLocale.put(keyStr, valueStr);
      }
      result.put(locale, currentLocale);
    }
    return result;
  }
}
origin: org.opencms.modules/org.opencms.frontend.templatetwo

/**
 * Returns the parameters of the collector with resolved macros.<p>
 * 
 * @return the parameters of the collector with resolved macros
 */
public String getParameter() {
  Locale locale = getRequestContext().getLocale();
  String params = m_content.getStringValue(getCmsObject(), NODE_PARAMETER, locale);
  List links = m_content.getValues(NODE_LINKS, locale);
  CmsMacroResolver macroResolver = CmsMacroResolver.newInstance();
  macroResolver.setKeepEmptyMacros(true);
  for (int i = 0; i < links.size(); i++) {
    I_CmsXmlContentValue xmlValue = (I_CmsXmlContentValue)links.get(i);
    String value = xmlValue.getStringValue(getCmsObject());
    if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(value)) {
      StringBuffer macro = new StringBuffer(10);
      macro.append(MACRO_LINK_PREFIX).append(i + 1);
      macroResolver.addMacro(macro.toString(), getRequestContext().removeSiteRoot(value));
    }
  }
  return macroResolver.resolveMacros(params);
}
origin: org.opencms/opencms-solr

/**
 * Adds a value element of the sequence type at the selected index to the XML content document.<p> 
 * 
 * @param cms the current users OpenCms context
 * @param index the index where to add the new value element
 * 
 * @return the added XML content value element
 * 
 * @see CmsXmlContent#addValue(CmsObject, String, Locale, int)
 */
public I_CmsXmlContentValue addValue(CmsObject cms, int index) {
  I_CmsXmlContentValue newValue = m_content.addValue(cms, getPath(), getLocale(), index);
  // re-initialize the value list
  m_values = m_content.getValues(getPath(), getLocale());
  return newValue;
}
origin: org.opencms/opencms-solr

/**
 * Removes an existing XML content value of the given element name and locale at the given index position
 * from this XML content document.<p> 
 * 
 * @param name the name of the XML content value element
 * @param locale the locale where to remove the value 
 * @param index the index where to remove the value (relative to all other values of this type)
 */
public void removeValue(String name, Locale locale, int index) {
  // first get the value from the selected locale and index
  I_CmsXmlContentValue value = getValue(name, locale, index);
  // check for the min / max occurs constrains
  List<I_CmsXmlContentValue> values = getValues(name, locale);
  if (values.size() <= value.getMinOccurs()) {
    // must not allow removing an element if min occurs would be violated
    throw new CmsRuntimeException(Messages.get().container(
      Messages.ERR_XMLCONTENT_ELEM_MINOCCURS_2,
      name,
      new Integer(value.getMinOccurs())));
  }
  // detach the value node from the XML document
  value.getElement().detach();
  // re-initialize this XML content 
  initDocument(m_document, m_encoding, m_contentDefinition);
}
origin: org.opencms.modules/com.alkacon.opencms.v8.list

/**
 * Returns the parameters of the collector with resolved macros.<p>
 * 
 * @return the parameters of the collector with resolved macros
 */
public String getParameter() {
  Locale locale = getRequestContext().getLocale();
  String params = m_content.getStringValue(getCmsObject(), NODE_PARAMETER, locale);
  List<I_CmsXmlContentValue> links = m_content.getValues(NODE_LINKS, locale);
  CmsMacroResolver macroResolver = CmsMacroResolver.newInstance().setCmsObject(getCmsObject());
  macroResolver.setKeepEmptyMacros(true);
  for (int i = 0; i < links.size(); i++) {
    I_CmsXmlContentValue xmlValue = links.get(i);
    String value = xmlValue.getStringValue(getCmsObject());
    if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(value)) {
      StringBuffer macro = new StringBuffer(10);
      macro.append(MACRO_LINK_PREFIX).append(i + 1);
      macroResolver.addMacro(macro.toString(), getRequestContext().removeSiteRoot(value));
    }
  }
  return macroResolver.resolveMacros(params);
}
origin: org.opencms/opencms-core

/**
 * Removes an existing inheritance container entry with a given name from the configuration file.<p>
 *
 * This does nothing if no such entry actually exists.<p>
 *
 * @param cms the current CMS context
 * @param content the XML content
 * @param locale the locale from which to remove the entry
 * @param name the name of the entry
 *
 */
protected void removeExistingEntry(CmsObject cms, CmsXmlContent content, Locale locale, String name) {
  if (!content.hasLocale(locale)) {
    return;
  }
  String entriesXpath = N_CONFIGURATION;
  List<I_CmsXmlContentValue> values = content.getValues(entriesXpath, locale);
  int valueIndex = 0;
  for (I_CmsXmlContentValue value : values) {
    String valueXpath = value.getPath();
    I_CmsXmlContentValue nameValue = content.getValue(CmsXmlUtils.concatXpath(valueXpath, N_NAME), locale);
    String currentName = nameValue.getStringValue(cms);
    if (currentName.equals(name)) {
      content.removeValue(valueXpath, locale, valueIndex);
      break;
    }
    valueIndex += 1;
  }
}
origin: org.opencms/opencms-core

/**
 * Removes an existing XML content value of the given element name and locale at the given index position
 * from this XML content document.<p>
 *
 * @param name the name of the XML content value element
 * @param locale the locale where to remove the value
 * @param index the index where to remove the value (relative to all other values of this type)
 */
public void removeValue(String name, Locale locale, int index) {
  // first get the value from the selected locale and index
  I_CmsXmlContentValue value = getValue(name, locale, index);
  if (!value.isChoiceOption()) {
    // check for the min / max occurs constrains
    List<I_CmsXmlContentValue> values = getValues(name, locale);
    if (values.size() <= value.getMinOccurs()) {
      // must not allow removing an element if min occurs would be violated
      throw new CmsRuntimeException(
        Messages.get().container(
          Messages.ERR_XMLCONTENT_ELEM_MINOCCURS_2,
          name,
          new Integer(value.getMinOccurs())));
    }
  }
  // detach the value node from the XML document
  value.getElement().detach();
  // re-initialize this XML content
  initDocument(m_document, m_encoding, m_contentDefinition);
}
origin: org.opencms/opencms-core

String name = content.getValue(namePath, locale).getStringValue(cms);
Iterator<I_CmsXmlContentValue> itValues = content.getValues(
  CmsXmlContainerPage.XmlNode.Containers.name(),
  locale).iterator();
origin: org.opencms/opencms-core

/**
 * Generates a new content sequence element from the given type, content and content definition.<p>
 *
 * @param path the path in the document to generate the value sequence for
 * @param locale the locale to get the content values from
 * @param content the XML content to generate the sequence element out of
 */
public CmsXmlContentValueSequence(String path, Locale locale, CmsXmlContent content) {
  m_locale = locale;
  m_content = content;
  m_path = CmsXmlUtils.removeXpathIndex(path);
  I_CmsXmlSchemaType type = m_content.getContentDefinition().getSchemaType(m_path);
  m_isChoiceSequence = type.isChoiceOption();
  if (m_isChoiceSequence) {
    m_values = m_content.getSubValues(CmsXmlUtils.removeLastXpathElement(m_path), m_locale);
  } else {
    m_values = m_content.getValues(path, m_locale);
  }
  if (type.getContentDefinition().getChoiceMaxOccurs() > 1) {
    m_minOccurs = 0;
    m_maxOccurs = type.getContentDefinition().getChoiceMaxOccurs();
  } else {
    if (m_isChoiceSequence && !m_values.isEmpty()) {
      type = m_values.get(0);
    }
    m_minOccurs = type.getMinOccurs();
    m_maxOccurs = type.getMaxOccurs();
  }
}
org.opencms.xml.contentCmsXmlContentgetValues

Javadoc

Returns all values of the given element path.

Popular methods of CmsXmlContent

  • getValue
  • getStringValue
  • hasLocale
  • getFile
  • getLocales
  • marshal
  • addValue
    Adds a new XML schema type with the default value to the given parent node.
  • getIndexCount
  • hasValue
  • addLocale
  • copyLocale
    Copies the content of the given source locale to the given destination locale in this XML document.
  • correctXmlStructure
  • copyLocale,
  • correctXmlStructure,
  • getEncoding,
  • getLocaleNode,
  • initDocument,
  • removeLocale,
  • setAutoCorrectionEnabled,
  • toString,
  • visitAllValuesWith

Popular in Java

  • Making http post requests using okhttp
  • getSupportFragmentManager (FragmentActivity)
  • getContentResolver (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Menu (java.awt)
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now