/** * Converts the given HTML code according to the settings of this converter.<p> * * @param htmlInput HTML input stored in a string * @return array of bytes containing the converted HTML * * @throws UnsupportedEncodingException if the encoding set for the conversion is not supported */ public byte[] convertToByte(String htmlInput) throws UnsupportedEncodingException { return convertToString(htmlInput).getBytes(getEncoding()); }
/** * Converts the given HTML code according to the settings of this converter.<p> * * @param htmlInput HTML input stored in an array of bytes * @return string containing the converted HTML * * @throws UnsupportedEncodingException if the encoding set for the conversion is not supported */ public String convertToString(byte[] htmlInput) throws UnsupportedEncodingException { return convertToString(new String(htmlInput, getEncoding())); }
/** * Converts the given HTML code according to the settings of this converter.<p> * * @param htmlInput HTML input stored in a string * @return array of bytes containing the converted HTML * * @throws UnsupportedEncodingException if the encoding set for the conversion is not supported */ public byte[] convertToByte(String htmlInput) throws UnsupportedEncodingException { return convertToString(htmlInput).getBytes(getEncoding()); }
/** * Converts the given HTML code according to the settings of this converter.<p> * * @param htmlInput HTML input stored in an array of bytes * @return string containing the converted HTML * * @throws UnsupportedEncodingException if the encoding set for the conversion is not supported */ public String convertToString(byte[] htmlInput) throws UnsupportedEncodingException { return convertToString(new String(htmlInput, getEncoding())); }
/** * Internally tidies with cleanup and XHTML.<p> * * @param content HTML to clean * * @return the tidy HTML */ private String tidy(final String content) { CmsHtmlConverter converter = new CmsHtmlConverter(CmsEncoder.ENCODING_UTF_8, new StringBuffer( CmsHtmlConverter.PARAM_WORD).append(";").append(CmsHtmlConverter.PARAM_XHTML).toString()); String result = content; try { result = converter.convertToString(content); } catch (UnsupportedEncodingException e) { // should never happen if (LOG.isWarnEnabled()) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_WARN_TIDY_FAILURE_0), e); } } return result; } }
/** * Internally tidies with cleanup and XHTML.<p> * * @param content HTML to clean * * @return the tidy HTML */ private String tidy(final String content) { CmsHtmlConverter converter = new CmsHtmlConverter( CmsEncoder.ENCODING_UTF_8, new StringBuffer(CmsHtmlConverter.PARAM_WORD).append(";").append(CmsHtmlConverter.PARAM_XHTML).toString()); String result = content; try { result = converter.convertToString(content); } catch (UnsupportedEncodingException e) { // should never happen if (LOG.isWarnEnabled()) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_WARN_TIDY_FAILURE_0), e); } } return result; } }
/** * Converts the given HTML code according to the settings of this converter.<p> * * If an any error occurs during the conversion process, the original input is returned unmodified.<p> * * @param htmlInput HTML input stored in string * * @return string containing the converted HTML */ public String convertToStringSilent(String htmlInput) { try { return convertToString(htmlInput); } catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_CONVERSION_BYTE_FAILED_0), e); } return htmlInput; } }
/** * Converts the given HTML code according to the settings of this converter.<p> * * If an any error occurs during the conversion process, the original input is returned unmodified.<p> * * @param htmlInput HTML input stored in string * * @return string containing the converted HTML */ public String convertToStringSilent(String htmlInput) { try { return convertToString(htmlInput); } catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_CONVERSION_BYTE_FAILED_0), e); } return htmlInput; } }
/** * Converts the given HTML code according to the settings of this converter.<p> * * If an any error occurs during the conversion process, the original input is returned unmodified.<p> * * @param htmlInput HTML input stored in an array of bytes * * @return string containing the converted HTML */ public String convertToStringSilent(byte[] htmlInput) { try { return convertToString(htmlInput); } catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_CONVERSION_BYTE_FAILED_0), e); } try { return new String(htmlInput, getEncoding()); } catch (UnsupportedEncodingException e1) { if (LOG.isWarnEnabled()) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_CONVERSION_BYTE_FAILED_0), e1); } return new String(htmlInput); } } }
/** * Converts the given HTML code according to the settings of this converter.<p> * * If an any error occurs during the conversion process, the original input is returned unmodified.<p> * * @param htmlInput HTML input stored in an array of bytes * * @return string containing the converted HTML */ public String convertToStringSilent(byte[] htmlInput) { try { return convertToString(htmlInput); } catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_CONVERSION_BYTE_FAILED_0), e); } try { return new String(htmlInput, getEncoding()); } catch (UnsupportedEncodingException e1) { if (LOG.isWarnEnabled()) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_CONVERSION_BYTE_FAILED_0), e1); } return new String(htmlInput); } } }