List of usage examples for org.apache.commons.lang CharEncoding UTF_8
String UTF_8
To view the source code for org.apache.commons.lang CharEncoding UTF_8.
Click Source Link
Eight-bit Unicode Transformation Format.
From source file:org.craftercms.search.service.impl.RestClientSearchService.java
public RestClientSearchService() { restTemplate = new RestTemplate(); List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>(); messageConverters.add(new ByteArrayHttpMessageConverter()); StringHttpMessageConverterExtended stringHttpMessageConverter = new StringHttpMessageConverterExtended( Charset.forName(CharEncoding.UTF_8)); messageConverters.add(stringHttpMessageConverter); messageConverters.add(new FormHttpMessageConverter()); messageConverters.add(new ResourceHttpMessageConverter()); messageConverters.add(new SourceHttpMessageConverter()); messageConverters.add(new XmlAwareFormHttpMessageConverter()); if (jaxb2Present) { messageConverters.add(new Jaxb2RootElementHttpMessageConverter()); }//from www . ja va 2s. co m if (jacksonPresent) { messageConverters.add(new MappingJacksonHttpMessageConverter()); } if (romePresent) { messageConverters.add(new AtomFeedHttpMessageConverter()); messageConverters.add(new RssChannelHttpMessageConverter()); } restTemplate.setMessageConverters(messageConverters); }
From source file:org.craftercms.search.service.impl.SolrDocumentBuilder.java
protected SAXReader createSAXReader() { SAXReader reader = new SAXReader(); reader.setEncoding(CharEncoding.UTF_8); reader.setMergeAdjacentText(true); return reader; }
From source file:org.eclipse.gyrex.admin.ui.cloud.internal.zookeeper.ZooKeeperData.java
private String asString(final byte[] data) { if (null == data) return StringUtils.EMPTY; try {/* w w w . j ava 2 s .c o m*/ return new String(data, CharEncoding.UTF_8); } catch (final UnsupportedEncodingException e) { return ExceptionUtils.getRootCauseMessage(e); } }
From source file:org.eclipse.gyrex.admin.ui.internal.application.AdminApplicationConfiguration.java
@Override public void configure(final Application application) { final Map<String, String> brandingProps = new HashMap<String, String>(4); brandingProps.put(WebClient.PAGE_TITLE, "Gyrex Admin"); brandingProps.put(WebClient.BODY_HTML, readBundleResource("html/body.html", CharEncoding.UTF_8)); brandingProps.put(WebClient.FAVICON, "img/gyrex/eclipse.ico"); brandingProps.put(WebClient.HEAD_HTML, "<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,800,600' rel='stylesheet' type='text/css'>"); application.addEntryPoint("/admin", AdminApplication.class, brandingProps); application.addStyleSheet(RWT.DEFAULT_THEME_ID, "theme/admin.css"); application.addResource("img/gyrex/eclipse.ico", new ResourceLoader() { @Override/* w ww. j av a 2 s .c om*/ public InputStream getResourceAsStream(final String resourceName) throws IOException { return FileLocator.openStream(AdminUiActivator.getInstance().getBundle(), new Path("img/gyrex/eclipse.ico"), false); } }); }
From source file:org.eclipse.gyrex.cloud.internal.zk.ZooKeeperGate.java
/** * Creates a path in ZooKeeper and sets the specified data. * <p>/*from w w w.j ava 2 s .c o m*/ * If the path parents don't exist they will be created using * {@link CreateMode#PERSISTENT}. * </p> * * @param path * the path to create * @param createMode * the creation mode * @param recordData * the record data * @throws KeeperException * @throws InterruptedException * @throws IOException */ public IPath createPath(final IPath path, final CreateMode createMode, final String recordData) throws KeeperException, InterruptedException, IOException { if (recordData == null) throw new IllegalArgumentException("recordData must not be null"); try { return createPath(path, createMode, recordData.getBytes(CharEncoding.UTF_8)); } catch (final UnsupportedEncodingException e) { throw new IllegalStateException("JVM does not support UTF-8.", e); } }
From source file:org.eclipse.gyrex.cloud.internal.zk.ZooKeeperGate.java
/** * Reads a record from the specified path in ZooKeeper if it exists. * <p>//w ww . ja va 2s . co m * Returns the specified {@code defaultValue} if the path does not exists. * </p> * * @param path * the path to the record * @param defaultValue * a default value to return if the record does not exist or no * data is stored at the specified path. * @param stat * optional object to populated with ZooKeeper statistics of the * underlying node * @return the record data (maybe <code>null</code> if * <code>defaultValue</code> was <code>null</code>) * @throws KeeperException * @throws InterruptedException * @throws IOException */ public String readRecord(final IPath path, final String defaultValue, final Stat stat) throws KeeperException, InterruptedException, IOException { try { final byte[] data = readRecord(path, stat); if (data == null) return defaultValue; return new String(data, CharEncoding.UTF_8); } catch (final NoNodeException e) { return defaultValue; } catch (final UnsupportedEncodingException e) { throw new IllegalStateException("JVM does not support UTF-8.", e); } }
From source file:org.eclipse.gyrex.cloud.internal.zk.ZooKeeperGate.java
/** * Writes a record at the specified path in ZooKeeper. * <p>/*www . j a v a 2 s.c o m*/ * If the path parents don't exist they will be created using the specified * creation mode. * </p> * * @param path * the path to create * @param createMode * the creation mode * @param recordData * the record data * @return ZooKeeper statistics about the underlying node * @throws KeeperException * @throws InterruptedException * @throws IOException */ public Stat writeRecord(final IPath path, final CreateMode createMode, final String recordData) throws KeeperException, InterruptedException, IOException { if (recordData == null) throw new IllegalArgumentException("recordData must not be null"); if (createMode == null) throw new IllegalArgumentException("createMode must not be null"); try { return writeRecord(path, createMode, recordData.getBytes(CharEncoding.UTF_8)); } catch (final UnsupportedEncodingException e) { throw new IllegalStateException("JVM does not support UTF-8.", e); } }
From source file:org.eclipse.gyrex.cloud.internal.zk.ZooKeeperGate.java
/** * Writes a record at the specified path in ZooKeeper. * <p>// w w w .j ava 2 s . co m * If the path does not exist a {@link NoNodeException} will be thrown. * </p> * <p> * If the version does not match a {@link BadVersionException} will be * thrown. * </p> * * @param path * the path to create * @param recordData * the record data * @param version * @return ZooKeeper statistics about the underlying node * @throws KeeperException * @throws InterruptedException * @throws IOException */ public Stat writeRecord(final IPath path, final String recordData, final int version) throws InterruptedException, KeeperException, IOException { try { return writeRecord(path, recordData.getBytes(CharEncoding.UTF_8), version); } catch (final UnsupportedEncodingException e) { throw new IllegalStateException("JVM does not support UTF-8.", e); } }
From source file:org.eclipse.gyrex.jobs.internal.schedules.ScheduleManagerImpl.java
/** * Creates a new instance.//from w w w. ja v a 2 s .co m */ @Inject public ScheduleManagerImpl(final IRuntimeContext context) { this.context = context; try { internalIdPrefix = DigestUtils.shaHex(context.getContextPath().toString().getBytes(CharEncoding.UTF_8)) + SEPARATOR; } catch (final UnsupportedEncodingException e) { throw new IllegalStateException("Please use a JVM that supports UTF-8."); } }
From source file:org.eclipse.gyrex.jobs.internal.util.ContextHashUtil.java
private static String getInternalIdPrefix(final IPath contextPath) { try {/*from w w w .j a va 2s .c o m*/ return DigestUtils.shaHex(contextPath.toString().getBytes(CharEncoding.UTF_8)) + SEPARATOR; } catch (final UnsupportedEncodingException e) { throw new IllegalStateException("Please use a JVM that supports UTF-8."); } }