Class SpoofedTextContentReader
java.lang.Object
org.alfresco.repo.content.AbstractContentAccessor
org.alfresco.repo.content.AbstractContentReader
org.alfresco.repo.content.filestore.SpoofedTextContentReader
- All Implemented Interfaces:
ContentAccessor,ContentReader
Provides access to text data that is generated when requested.
The URL has the format: spoofed://{locale=en_GB,seed=12345,length=1024,strings=["Alfresco", "Cloud"]}
The lexicon for the given locale is found by taking the language part of the locale (en in en_GB)
and finding the resource alfresco/textgen/lexicon-stem-en.txt.
- Since:
- 5.1
- Author:
- Derek Hulley
- See Also:
-
TextGenerator
-
Nested Class Summary
Nested classes/interfaces inherited from class org.alfresco.repo.content.AbstractContentAccessor
AbstractContentAccessor.CallbackFileChannel, AbstractContentAccessor.ChannelCloseCallbackAdvise -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcreateContentUrl(Locale locale, long seed, long size, String... words) Helper to create a content URL that represents spoofed textprotected ContentReaderThe URL of the write is known from the start and this method contract states that no consideration needs to be taken w.r.t.booleanexists()protected ReadableByteChannelProvides low-level access to read content from the repository.longlonggetSeed()longgetSize()org.alfresco.textgen.TextGeneratorstatic org.alfresco.textgen.TextGeneratorgetTextGenerator(Locale locale) Get a text generator for the given localeString[]getWords()protected final voidsetContentUrl(String contentUrl) Allow derived implementations to set the Content URL.Methods inherited from class org.alfresco.repo.content.AbstractContentReader
addListener, compareContentReaders, getContent, getContent, getContentInputStream, getContentString, getContentString, getFileChannel, getLimits, getReadableChannel, getReader, getTransformerDebug, getUseBufferedInputStream, isChannelOpen, isClosed, setLimits, setTransformerDebug, setUseBufferedInputStreamMethods inherited from class org.alfresco.repo.content.AbstractContentAccessor
channelOpened, finalize, getCallbackFileChannel, getContentData, getContentUrl, getEncoding, getLocale, getMimetype, setEncoding, setLocale, setMimetype, toStringMethods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.alfresco.service.cmr.repository.ContentAccessor
getContentData, getContentUrl, getEncoding, getLocale, getMimetype, setEncoding, setLocale, setMimetype
-
Field Details
-
LEXICON_STEM_PATH
- See Also:
-
KEY_LOCALE
- See Also:
-
KEY_SEED
- See Also:
-
KEY_SIZE
- See Also:
-
KEY_WORDS
- See Also:
-
-
Constructor Details
-
SpoofedTextContentReader
- Parameters:
url- a URL describing the type of text to produce (see class comments)
-
-
Method Details
-
getTextGenerator
Get a text generator for the given locale- Throws:
RuntimeException- if the locale has no lexicon exists for the locale
-
createContentUrl
Helper to create a content URL that represents spoofed text- Parameters:
locale- the text local (must be supported by an appropriate lexicon config resource)seed- numerical seed to ensure repeatable sequences of random textsize- the size (bytes) of the text to generatewords- additional words with decreasing frequency- Returns:
- the content URL
- Throws:
IllegalArgumentException- if the resulting URL exceeds 255 characters
-
exists
public boolean exists()- Returns:
- true always
-
getTextGenerator
public org.alfresco.textgen.TextGenerator getTextGenerator()- Returns:
- the text generator that will make the spoofed text
-
getSeed
public long getSeed()- Returns:
- the random seed for the spoofed text
-
getWords
- Returns:
- the words to add to the spoofed text
-
getSize
public long getSize()- Returns:
- spoofed text size
-
getLastModified
public long getLastModified()- See Also:
-
createReader
The URL of the write is known from the start and this method contract states that no consideration needs to be taken w.r.t. the stream state.- Specified by:
createReaderin classAbstractContentReader- Returns:
- Returns a reader onto the location referenced by this instance. The instance must always be a new instance.
- Throws:
ContentIOException
-
getDirectReadableChannel
Description copied from class:AbstractContentReaderProvides low-level access to read content from the repository.This is the only of the content reading methods that needs to be implemented by derived classes. All other content access methods make use of this in their underlying implementations.
- Specified by:
getDirectReadableChannelin classAbstractContentReader- Returns:
- Returns a channel from which content can be read
- Throws:
ContentIOException- if the channel could not be opened or the underlying content has disappeared
-
setContentUrl
Description copied from class:AbstractContentAccessorAllow derived implementations to set the Content URL. This allows for implementations where the URL is not known when the accessor is first constructed.- Overrides:
setContentUrlin classAbstractContentAccessor- Parameters:
contentUrl- the new content URL
-