本文整理汇总了Java中org.alfresco.service.cmr.repository.ContentReader.setEncoding方法的典型用法代码示例。如果您正苦于以下问题:Java ContentReader.setEncoding方法的具体用法?Java ContentReader.setEncoding怎么用?Java ContentReader.setEncoding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.service.cmr.repository.ContentReader
的用法示例。
在下文中一共展示了ContentReader.setEncoding方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testProjectTrivialDiffProjectFiles
import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的package包/类
/**
* Open and close of a project file changes certain header properties.
* Test File 1 has been opened and closed.
* @throws Exception
*/
public void testProjectTrivialDiffProjectFiles() throws Exception
{
CIFSContentComparator contentComparator = new CIFSContentComparator();
contentComparator.init();
ClassPathResource file0Resource = new ClassPathResource("filesys/ContentComparatorTest0.mpp");
assertNotNull("unable to find test resource filesys/ContentComparatorTest0.mpp", file0Resource);
ClassPathResource file1Resource = new ClassPathResource("filesys/ContentComparatorTest1.mpp");
assertNotNull("unable to find test resource filesys/ContentComparatorTest1.mpp", file1Resource);
/**
* Compare trivially different project files, should ignore trivial differences and be equal
*/
{
File file0 = file0Resource.getFile();
File file1 = file1Resource.getFile();
ContentReader reader = new FileContentReader(file0);
reader.setMimetype("application/vnd.ms-project");
reader.setEncoding("UTF-8");
boolean result = contentComparator.isContentEqual(reader, file1);
assertTrue("compare trivially different project file, should be equal", result);
}
}
示例2: buildContentReader
import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的package包/类
/**
* Writes the supplied text out to a temporary file, and opens
* a content reader onto it.
*/
protected static ContentReader buildContentReader(String text, Charset encoding)
throws IOException
{
File tmpFile = TempFileProvider.createTempFile("AlfrescoTest_", ".txt");
FileOutputStream out = new FileOutputStream(tmpFile);
OutputStreamWriter wout = new OutputStreamWriter(out, encoding);
wout.write(text);
wout.close();
out.close();
ContentReader reader = new FileContentReader(tmpFile);
reader.setEncoding(encoding.displayName());
reader.setMimetype("text/plain");
return reader;
}
示例3: testMediaWikiToHTML
import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的package包/类
public void testMediaWikiToHTML() throws Exception
{
File input = TempFileProvider.createTempFile("mediaWikiTest", ".mw");
FileOutputStream fos = new FileOutputStream(input);
fos.write(WIKI_TEXT.getBytes());
fos.close();
File output = TempFileProvider.createTempFile("mediaWikiTest", ".htm");
ContentReader contentReader = new FileContentReader(input);
contentReader.setMimetype(MimetypeMap.MIMETYPE_TEXT_MEDIAWIKI);
contentReader.setEncoding("UTF-8");
ContentWriter contentWriter = new FileContentWriter(output);
contentWriter.setMimetype(MimetypeMap.MIMETYPE_HTML);
contentWriter.setEncoding("UTF-8");
transformer.transform(contentReader, contentWriter);
String line = null;
BufferedReader reader = new BufferedReader(new FileReader(output));
while ((line = reader.readLine()) != null)
{
System.out.println(line);
}
}
示例4: getReader
import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的package包/类
/**
* Performs checks and copies required reader attributes
*/
public final ContentReader getReader() throws ContentIOException
{
String contentUrl = getContentUrl();
if (!isClosed())
{
return new EmptyContentReader(contentUrl);
}
ContentReader reader = createReader();
if (reader == null)
{
throw new AlfrescoRuntimeException("ContentReader failed to create new reader: \n" +
" writer: " + this);
}
else if (reader.getContentUrl() == null || !reader.getContentUrl().equals(contentUrl))
{
throw new AlfrescoRuntimeException("ContentReader has different URL: \n" +
" writer: " + this + "\n" +
" new reader: " + reader);
}
// copy across common attributes
reader.setMimetype(this.getMimetype());
reader.setEncoding(this.getEncoding());
reader.setLocale(this.getLocale());
// done
if (logger.isDebugEnabled())
{
logger.debug("Writer spawned new reader: \n" +
" writer: " + this + "\n" +
" new reader: " + reader);
}
return reader;
}
示例5: getReader
import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的package包/类
/**
* Performs checks and copies required reader attributes
*/
public final ContentReader getReader() throws ContentIOException
{
ContentReader reader = createReader();
if (reader == null)
{
throw new AlfrescoRuntimeException("ContentReader failed to create new reader: \n" +
" reader: " + this);
}
else if (reader.getContentUrl() == null || !reader.getContentUrl().equals(getContentUrl()))
{
throw new AlfrescoRuntimeException("ContentReader has different URL: \n" +
" reader: " + this + "\n" +
" new reader: " + reader);
}
// copy across common attributes
reader.setMimetype(this.getMimetype());
reader.setEncoding(this.getEncoding());
reader.setLocale(this.getLocale());
// done
if (logger.isDebugEnabled())
{
logger.debug("Reader spawned new reader: \n" +
" reader: " + this + "\n" +
" new reader: " + reader);
}
return reader;
}
示例6: getRawReader
import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的package包/类
/** {@inheritDoc} */
public ContentReader getRawReader(String contentUrl)
{
ContentReader reader = null;
try
{
reader = store.getReader(contentUrl);
}
catch (UnsupportedContentUrlException e)
{
// The URL is not supported, so we spoof it
reader = new EmptyContentReader(contentUrl);
}
if (reader == null)
{
throw new AlfrescoRuntimeException("ContentStore implementations may not return null ContentReaders");
}
// set extra data on the reader
reader.setMimetype(MimetypeMap.MIMETYPE_BINARY);
reader.setEncoding("UTF-8");
reader.setLocale(I18NUtil.getLocale());
// Done
if (logger.isDebugEnabled())
{
logger.debug(
"Direct request for reader: \n" +
" Content URL: " + contentUrl + "\n" +
" Reader: " + reader);
}
return reader;
}