Manipulates the content String and removes leading and trailing white spaces.<p>

@param save if set to true, the content parameter is not updated
@return the prepared content String
9095
@Override
    protected String prepareContent(boolean save) {

        String content = getParamContent().trim();
        // ensure all chars in the content are valid for the selected encoding
        content = CmsEncoder.adjustHtmlEncoding(content, getFileEncoding());
        if (!save) {
            setParamContent(content);
        }
        return content;
    }
437338
public static Function<String, String> createStringTemplateSource(
        I_CmsFormatterBean formatter,
        Supplier<CmsXmlContent> contentSupplier) {

        return key -> {
            String result = null;
            if (formatter != null) {
                result = formatter.getAttributes().get(key);
            }
            if (result == null) {
                CmsXmlContent content = contentSupplier.get();
                if (content != null) {
                    result = content.getHandler().getParameter(key);
                }
            }
            return result;
        };
    }
527859
void save() {

        try {
            byte[] content = m_codeMirror.getValue().getBytes(m_file.getEncoding());
            m_file.getFile().setContents(content);
            A_CmsUI.getCmsObject().writeFile(m_file.getFile());
            m_changed = false;
            m_save.setEnabled(false);
            m_saveAndExit.setEnabled(false);
        } catch (Exception e) {
            CmsErrorDialog.showErrorDialog(e);
        }
    }
625246
private byte[] replaceInXml(CmsFile cmsFile) throws Exception {

        Exception e = null;
        CmsXmlContent xmlContent = CmsXmlContentFactory.unmarshal(getCms(), cmsFile);
        Pattern pattern = Pattern.compile(m_settings.getSearchpattern());
        // loop over the locales of the content
        boolean modified = false;
        boolean matched = false;
        String requestedLocale = m_settings.getLocale();
        for (Locale locale : xmlContent.getLocales()) {
            if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(requestedLocale)
                && !locale.toString().equalsIgnoreCase(requestedLocale)) {
                // does not match the requested locale, skip it
                continue;
            }
            // loop over the available element paths of the current content locale
            List<String> paths = xmlContent.getNames(locale);
            for (String xpath : paths) {
                // try to get the value extraction for the current element path
                I_CmsXmlContentValue value = xmlContent.getValue(xpath, locale);
                if (value.isSimpleType()) {
                    try {
                        String currPath = value.getPath();
                        if (CmsStringUtil.isEmptyOrWhitespaceOnly(m_settings.getXpath())
                            || currPath.equals(m_settings.getXpath())
                            || (CmsXmlUtils.removeXpath(currPath).equals(m_settings.getXpath()))) {
                            // xpath match
                            String oldVal = value.getStringValue(getCms());
                            Matcher matcher = pattern.matcher(oldVal);
                            matcher = Pattern.compile(m_settings.getSearchpattern()).matcher(oldVal);
                            if (matcher.find()) {
                                matched = true;
                                m_matchedResources.add(cmsFile);
                                if (m_replace) {
                                    String newVal = matcher.replaceAll(m_settings.getReplacepattern());
                                    if (!oldVal.equals(newVal)) {
                                        value.setStringValue(getCms(), newVal);
                                        modified = true;
                                    }
                                }
                            }
                        }
                    } catch (Exception ex) {
                        // log and go on
                        LOG.error(ex.getMessage(), ex);
                        e = ex;
                    }
                }
            }
        }
        if (e != null) {
            throw e;
        }
        if (matched) {
            getReport().println(Messages.get().container(Messages.RPT_SOURCESEARCH_MATCHED_0), I_CmsReport.FORMAT_OK);
        } else {
            getReport().println(
                Messages.get().container(Messages.RPT_SOURCESEARCH_NOT_MATCHED_0),
                I_CmsReport.FORMAT_NOTE);
        }
        if (modified) {
            return xmlContent.marshal();
        }
        return null;
    }
453301
function cleanUpData(){
      var v = $contentDomNode.html().replace(/<br\s*\/?>/mg,"\n");
      v = v.replace(/<div>/gi,"\n").replace(/<\/div>/gi,'');
      v = v.replace(/(<([^>]+)>)/ig,'');
      return $.trim(v.replace(/&nbsp;/ig,''));
    }
312938
public String escapeHTMLString(String s)
    {
        if (s == null)
        {
            return null;
        }
        
        StringBuilder buffer = new StringBuilder();
        for(int i = 0; i < s.length(); i++)
        {
            char ch = s.charAt(i);
            switch (ch)
            {
                case ' ':
                    // All spaces in a block of consecutive spaces are converted to
                    // non-breaking space (&nbsp;) except for the last one.  This allows
                    // significant whitespace to be retained without prohibiting wrapping.
                    char nextCh = i + 1 < s.length() ? s.charAt(i + 1) : 0;
                    buffer.append(nextCh==' ' ? "&nbsp;" : " ");
                    break;
                case '\n':
                    buffer.append("<br/>\n");
                    break;
                default:
                    buffer.append(escapeChar(ch));
            }
        }
        return buffer.toString();
    }
1107872
public Set<String> parseRemoveFormatters(I_CmsXmlContentLocation node) {

        Set<String> removeFormatters = new HashSet<String>();
        for (I_CmsXmlContentValueLocation removeLoc : node.getSubValues(
            N_REMOVE_FORMATTERS + "/" + N_REMOVE_FORMATTER)) {
            CmsXmlVfsFileValue value = (CmsXmlVfsFileValue)removeLoc.getValue();
            CmsLink link = value.getLink(m_cms);
            if (link != null) {
                removeFormatters.add(link.getStructureId().toString());
            }
        }
        return removeFormatters;
    }
807289
private String formatItem(CmsReportUpdateItem updateItem) {

        StringBuffer buf = new StringBuffer();
        CmsReportFormatType format = updateItem.getType();
        if (format == CmsReportFormatType.fmtException) {
            return formatException((Throwable)(updateItem.getMessage()));
        } else {
            String value = CmsStringUtil.escapeJavaScript((String)(updateItem.getMessage()));
            switch (format) {
                case fmtHeadline:
                    buf = new StringBuffer();
                    buf.append("aH('");
                    buf.append(value);
                    buf.append("'); ");
                    break;
                case fmtWarning:
                    buf = new StringBuffer();
                    buf.append("aW('");
                    buf.append(value);
                    buf.append("'); ");
                    break;
                case fmtError:
                    buf = new StringBuffer();
                    buf.append("aE('");
                    buf.append(value);
                    buf.append("'); ");
                    break;
                case fmtNote:
                    buf = new StringBuffer();
                    buf.append("aN('");
                    buf.append(value);
                    buf.append("'); ");
                    break;
                case fmtOk:
                    buf = new StringBuffer();
                    buf.append("aO('");
                    buf.append(value);
                    buf.append("'); ");
                    break;
                case fmtNewline:
                    buf = new StringBuffer();
                    buf.append("a('" + CmsHtmlReport.LINEBREAK + "');");
                    break;
                case fmtDefault:
                default:
                    buf = new StringBuffer();
                    buf.append("a('");
                    buf.append(value);
                    buf.append("'); ");
            }

            // the output lines get split back into single lines on the client-side.
            // thus, a separate JavaScript call has to be added here to tell the
            // client that we want a linebreak here...
            if (value.trim().endsWith(CmsHtmlReport.LINEBREAK)) {
                buf.append("aB(); ");
            }
        }
        return buf.toString();
    }
448289
public static String removeSemicolonContent(String requestUri) {
		int semicolonIndex = requestUri.indexOf(';');
		while (semicolonIndex != -1) {
			int slashIndex = requestUri.indexOf('/', semicolonIndex);
			String start = requestUri.substring(0, semicolonIndex);
			requestUri = (slashIndex != -1) ? start + requestUri.substring(slashIndex) : start;
			semicolonIndex = requestUri.indexOf(';', semicolonIndex);
		}
		return requestUri;
	}
612083
protected void adjustServerPrefix() {

        CmsSSLMode mode = (CmsSSLMode)m_encryption.getValue();
        if (simpleReturn(mode)) {
            return;
        }
        String toBeReplaced = "http:";
        String newString = "https:";

        if (mode.equals(CmsSSLMode.NO) | mode.equals(CmsSSLMode.SECURE_SERVER)) {
            toBeReplaced = "https:";
            newString = "http:";
        }

        if (((CmsSite)m_server.getValue()).getUrl().contains(toBeReplaced)) {

            String newURL = ((CmsSite)m_server.getValue()).getUrl().replaceAll(toBeReplaced, newString);
            CmsSite newSite = new CmsSite("dummy", newURL);
            if (!m_serverContainer.containsId(newSite)) {
                m_serverContainer.addItem(newSite);
            }
            m_server.select(newSite);
        }

    }
321053
private String createStringValue(CmsObject cms) {

        Attribute enabled = m_element.attribute(CmsXmlPage.ATTRIBUTE_ENABLED);

        String content = "";
        if ((enabled == null) || Boolean.valueOf(enabled.getText()).booleanValue()) {
            CmsLink link = getLink(cms);
            if (link != null) {
                content = link.getUri();
                if (cms != null) {
                    content = cms.getRequestContext().removeSiteRoot(link.getUri());
                }
            }
        }
        return content;
    }
1235322
protected function getPreparedCssContent()
    {
        if ($this->preparedContent === null) {
            $this->preparedContent = Placeholder::replaceStringsAndComments($this->getCssContent());

            // Move comments from the end of the line to the beginning to make it easier to
            // detect, to which rule they belong to
            $this->preparedContent = preg_replace(
                '/^([^\r\n]+)(_COMMENT_[a-f0-9]{32}_)([\r\n\t\f]+)/m',
                "\\2\n\\1\\3",
                $this->preparedContent
            );

            // Remove white space characters before comments
            $this->preparedContent = preg_replace(
                '/^([ \t\f]*)(_COMMENT_[a-f0-9]{32}_)/m',
                "\\2\n",
                $this->preparedContent
            );

            // Very important: Split long lines, because parsing long lines (char by char) costs a lot performance
            // (several thousand percent...).
            $this->preparedContent = str_replace(["{", "}", ";"], ["{\n", "}\n", ";\n"], $this->preparedContent);
        }

        return $this->preparedContent;
    }
132397
private void setXmlContentFromFile(
        CmsResource cmsResource,
        CmsFile cmsFile,
        CmsObject cmsObject,
        String xmlContent,
        String encodingType,
        I_CmsReport report) {

        try {
            byte[] fileContent = xmlContent.getBytes(encodingType);
            cmsFile.setContents(fileContent);
            // write into file
            cmsObject.writeFile(cmsFile);
            // unlock resource
            try {
                cmsObject.unlockResource(cmsObject.getSitePath(cmsResource));
            } catch (CmsException e) {
                m_errorTransform += 1;
                report.println(
                    Messages.get().container(Messages.RPT_CONVERTXML_UNLOCK_FILE_1, cmsObject.getSitePath(cmsResource)),
                    I_CmsReport.FORMAT_ERROR);
                if (LOG.isErrorEnabled()) {
                    LOG.error(e.getMessageContainer(), e);
                }
            }
        } catch (Exception e) {
            m_errorTransform += 1;
            String reportContent = "<br/>";
            reportContent = reportContent + CmsEncoder.escapeXml(xmlContent);
            reportContent = reportContent.replaceAll("\r\n", "<br/>");
            report.println(
                Messages.get().container(Messages.RPT_CONVERTXML_WRITE_ERROR_1, reportContent),
                I_CmsReport.FORMAT_ERROR);
            if (LOG.isErrorEnabled()) {
                LOG.error(e.toString());
            }
        }
    }
502
public String cleanFixedLine(final String line) {

        StringBuilder cleanedLine = new StringBuilder();
        int length = line.length();

        /* Clear sequence numbering */
        for (int i = 0; i < _startColumn - 1; i++) {
            cleanedLine.append(" ");
        }

        /* Trim anything beyond end column */
        if (length > _startColumn - 1) {
            String areaA = line.substring(_startColumn - 1,
                    (length > _endColumn) ? _endColumn : length);

            cleanedLine.append(areaA);
        }
        return cleanedLine.toString();
    }
304314
public Set<String> parseAddFormatters(I_CmsXmlContentLocation node) {

        Set<String> addFormatters = new HashSet<String>();
        for (I_CmsXmlContentValueLocation addLoc : node.getSubValues(N_ADD_FORMATTERS + "/" + N_ADD_FORMATTER)) {
            CmsXmlVfsFileValue value = (CmsXmlVfsFileValue)addLoc.getValue();
            CmsLink link = value.getLink(m_cms);
            if (link != null) {
                addFormatters.add(link.getStructureId().toString());
            }
        }
        return addFormatters;
    }
675768
public Message contentEncoding(String charset) {
        basicProperties = basicProperties.builder()
                .contentEncoding(charset)
                .build();
        return this;
    }
1373209
public CmsXmlContentErrorHandler validateContent(Map<String, String> contentValues) throws CmsUgcException {

        checkNotFinished();
        try {
            CmsFile file = m_cms.readFile(m_editResource);
            CmsXmlContent content = addContentValues(file, contentValues);
            return content.validate(m_cms);
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage(), e);
            throw new CmsUgcException(e, CmsUgcConstants.ErrorCode.errMisc, e.getLocalizedMessage());
        }
    }