/** * Creates a SAX event handler that generates XML / HTML Strings from the events caught * using a new <code>{@link StringWriter}</code> and the given encoding.<p> * * @param writer the Writer to write to output to */ public CmsXmlSaxWriter(Writer writer) { this(writer, OpenCms.getSystemInfo().getDefaultEncoding()); }
/** * Creates a SAX event handler that generates XML / HTML Strings from the events caught * using a new <code>{@link StringWriter}</code> and the given encoding.<p> * * @param writer the Writer to write to output to */ public CmsXmlSaxWriter(Writer writer) { this(writer, OpenCms.getSystemInfo().getDefaultEncoding()); }
/** * Creates a SAX event handler that generates XML / HTML Strings from the events caught * using a new <code>{@link StringWriter}</code> and the OpenCms default encoding.<p> */ public CmsXmlSaxWriter() { this(new StringWriter(), OpenCms.getSystemInfo().getDefaultEncoding()); }
/** * Creates a SAX event handler that generates XML / HTML Strings from the events caught * using a new <code>{@link StringWriter}</code> and the OpenCms default encoding.<p> */ public CmsXmlSaxWriter() { this(new StringWriter(), OpenCms.getSystemInfo().getDefaultEncoding()); }
/** * Initializes the cache objects.<p> */ private void initConfiguration() { m_configuration = new Configuration(); m_configuration.setDefaultEncoding(OpenCms.getSystemInfo().getDefaultEncoding()); m_configuration.setTemplateLoader(new StringTemplateLoader()); }
/** * Returns the "content encoding" property value of the requested uri.<p> * * @return the "content encoding" property value of the requested uri */ public String getEncoding() { return property( CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, "search", OpenCms.getSystemInfo().getDefaultEncoding()); }
/** * Re-decodes a String that has not been correctly decoded and thus has scrambled * character bytes.<p> * * This is an equivalent to the JavaScript "decodeURIComponent" function. * It converts from the default "UTF-8" to the currently selected system encoding.<p> * * @param input the String to convert * * @return String the converted String */ public static String redecodeUriComponent(String input) { if (input == null) { return input; } return new String( changeEncoding(input.getBytes(), ENCODING_UTF_8, OpenCms.getSystemInfo().getDefaultEncoding())); }
/** * Re-decodes a String that has not been correctly decoded and thus has scrambled * character bytes.<p> * * This is an equivalent to the JavaScript "decodeURIComponent" function. * It converts from the default "UTF-8" to the currently selected system encoding.<p> * * @param input the String to convert * * @return String the converted String */ public static String redecodeUriComponent(String input) { if (input == null) { return input; } return new String( changeEncoding(input.getBytes(), ENCODING_UTF_8, OpenCms.getSystemInfo().getDefaultEncoding())); }
/** * Helper method to determine the encoding of the given file in the VFS, * which must be set using the "content-encoding" property.<p> * * @param cms the CmsObject * @param filename the name of the file which is to be checked * @return the encoding for the file */ protected String getFileEncoding(CmsObject cms, String filename) { try { return cms.readPropertyObject(filename, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true).getValue( OpenCms.getSystemInfo().getDefaultEncoding()); } catch (CmsException e) { return OpenCms.getSystemInfo().getDefaultEncoding(); } }
/** * Helper method to determine the encoding of the given file in the VFS, * which must be set using the "content-encoding" property.<p> * * @param cms the CmsObject * @param filename the name of the file which is to be checked * @return the encoding for the file */ protected String getFileEncoding(CmsObject cms, String filename) { try { return cms.readPropertyObject(filename, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true).getValue( OpenCms.getSystemInfo().getDefaultEncoding()); } catch (CmsException e) { return OpenCms.getSystemInfo().getDefaultEncoding(); } }
/** * Gets the encoding which should be used to read the properties file.<p> * * @param cms the CMS context to use * @param res the resource for which we want the encoding * * @return the encoding value */ private String getEncoding(CmsObject cms, CmsResource res) { String defaultEncoding = OpenCms.getSystemInfo().getDefaultEncoding(); try { CmsProperty encProp = cms.readPropertyObject(res, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true); String encoding = encProp.getValue(defaultEncoding); return encoding; } catch (Exception e) { LOG.warn(e.getLocalizedMessage(), e); return defaultEncoding; } }
/** * Helper method to determine the encoding of the given file in the VFS, * which must be set using the "content-encoding" property.<p> * * @param cms the CmsObject * @param file the file which is to be checked * @return the encoding for the file */ protected String getFileEncoding(CmsObject cms, CmsResource file) { String result; try { result = cms.readPropertyObject(file, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true).getValue( OpenCms.getSystemInfo().getDefaultEncoding()); } catch (CmsException e) { result = OpenCms.getSystemInfo().getDefaultEncoding(); } return CmsEncoder.lookupEncoding(result, OpenCms.getSystemInfo().getDefaultEncoding()); }
/** * Sets the encoding.<p> * * @param encoding the encoding to set * * @see CmsRequestContext#setEncoding(String) */ public void setEncoding(String encoding) { checkFrozen(); m_encoding = CmsEncoder.lookupEncoding(encoding, OpenCms.getSystemInfo().getDefaultEncoding()); }
/** * Sets the encoding.<p> * * @param encoding the encoding to set * * @see CmsRequestContext#setEncoding(String) */ public void setEncoding(String encoding) { checkFrozen(); m_encoding = CmsEncoder.lookupEncoding(encoding, OpenCms.getSystemInfo().getDefaultEncoding()); }
/** * Decodes a string used as parameter in an uri in a way independent of other encodings/decodings applied before.<p> * * @param input the encoded parameter string * * @return the decoded parameter string * * @see #encodeParameter(String) */ public static String decodeParameter(String input) { String result = CmsStringUtil.substitute(input, ENTITY_REPLACEMENT, ENTITY_PREFIX); return CmsEncoder.decodeHtmlEntities(result, OpenCms.getSystemInfo().getDefaultEncoding()); }
/** * Decodes a string used as parameter in an uri in a way independent of other encodings/decodings applied before.<p> * * @param input the encoded parameter string * * @return the decoded parameter string * * @see #encodeParameter(String) */ public static String decodeParameter(String input) { String result = CmsStringUtil.substitute(input, ENTITY_REPLACEMENT, ENTITY_PREFIX); return CmsEncoder.decodeHtmlEntities(result, OpenCms.getSystemInfo().getDefaultEncoding()); }
/** * Starts the report.<p> */ public void start() { if (m_writeHtml) { try { m_printStream.println(CmsReport.generatePageStartExtended( OpenCms.initCmsObject(OpenCms.getDefaultUsers().getUserGuest()), OpenCms.getSystemInfo().getDefaultEncoding())); } catch (CmsException e) { // ignore } } }
/** * Starts the report.<p> */ public void start() { if (m_writeHtml) { try { m_printStream.println( CmsWorkplace.generatePageStartExtended( OpenCms.initCmsObject(OpenCms.getDefaultUsers().getUserGuest()), OpenCms.getSystemInfo().getDefaultEncoding())); } catch (CmsException e) { // ignore } } }
/** * Returns the encoding of the file. * Encoding is read from the content-encoding property and defaults to the systems default encoding. * Since properties can change without rewriting content, the actual encoding can differ. * * @param cms {@link CmsObject} used to read properties of the given file. * @param file the file for which the encoding is requested * @return the file's encoding according to the content-encoding property, or the system's default encoding as default. */ public static String getEncoding(CmsObject cms, CmsResource file) { CmsProperty encodingProperty = CmsProperty.getNullProperty(); try { encodingProperty = cms.readPropertyObject(file, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true); } catch (CmsException e) { LOG.debug(e.getLocalizedMessage(), e); } return CmsEncoder.lookupEncoding(encodingProperty.getValue(""), OpenCms.getSystemInfo().getDefaultEncoding()); }
/** * Helper method to convert the content of a resource to a string.<p> * * @param file the file * @return the file content as a string * * @throws CmsException if something goes wrong */ protected String getContentAsString(CmsFile file) throws CmsException { CmsProperty p = m_cms.readPropertyObject(file, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true); String e = p.getValue(); if (e == null) { e = OpenCms.getSystemInfo().getDefaultEncoding(); } return CmsEncoder.createString(file.getContents(), e); }