org.apache.chemistry.opencmis.util.content.loremipsum
Class LoremIpsum

java.lang.Object
  extended by org.apache.chemistry.opencmis.util.content.loremipsum.LoremIpsum

public class LoremIpsum
extends Object

A generator of lorem ipsum text ported from the Python implementation at http://code.google.com/p/lorem-ipsum-generator/. Note: original code licensed under the BSD license


Constructor Summary
LoremIpsum()
          Generates random strings of "lorem ipsum" text, based on the word distribution of a sample text, using the words in a dictionary.
LoremIpsum(String sample)
           
LoremIpsum(String sample, String dictionary)
           
LoremIpsum(String sample, String[] dictionary)
           
 
Method Summary
static boolean contains(String[] array, String val)
           
 String generateOneParagraphHtml(int quantity, boolean startWithLorem)
          Generates one paragraph of HTML, surrounded by HTML pararaph tags.
 String generateParagraph(boolean opt_startWithLorem)
          Generates a single lorem ipsum paragraph, of random length.
 void generateParagraphsFullHtml(Appendable writer, int quantity, boolean startWithLorem)
          Generates a number of paragraphs, with each paragraph surrounded by HTML paragraph tags as a full HTML page.
 String generateParagraphsFullHtml(int quantity, boolean startWithLorem)
          Generates a number of paragraphs, with each paragraph surrounded by HTML paragraph tags as a full HTML page.
 void generateParagraphsHtml(Appendable writer, int quantity, boolean startWithLorem)
          Generates a number of paragraphs, with each paragraph surrounded by HTML pararaph tags.
 String generateParagraphsHtml(int quantity, boolean startWithLorem)
          Generates a number of paragraphs, with each paragraph surrounded by HTML pararaph tags.
 void generateParagraphsPlainText(Appendable writer, int quantity, boolean startWithLorem)
          Generates a number of paragraphs, with each paragraph separated by two newlines.
 void generateParagraphsPlainText(Appendable writer, int quantity, int maxCols, boolean startWithLorem)
          Generates a number of paragraphs, with each paragraph separated by two newlines and no line exceeding maxCols columns
 String generateParagraphsPlainText(int quantity, boolean startWithLorem)
          Generates a number of paragraphs, with each paragraph separated by two newlines.
 String generateParagraphsPlainText(int quantity, int maxCols, boolean startWithLorem)
          Generates a number of paragraphs, with each paragraph separated by two newlines and no line exceeding maxCols columns
 String generateSentence(boolean opt_startWithLorem)
          Generates a single sentence, of random length.
 String getDictionary()
           
 String getSample()
           
static double mean(double[] values)
           
static double mean(int[] values)
           
 void setDictionary(String dictionary)
           
 void setSample(String sample)
           
static double sigma(double[] values)
           
static double sigma(int[] values)
           
static double sum(double[] values)
           
static int sum(int[] values)
           
static double variance(double[] values)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoremIpsum

public LoremIpsum()
Generates random strings of "lorem ipsum" text, based on the word distribution of a sample text, using the words in a dictionary.


LoremIpsum

public LoremIpsum(String sample,
                  String dictionary)

LoremIpsum

public LoremIpsum(String sample,
                  String[] dictionary)

LoremIpsum

public LoremIpsum(String sample)
Method Detail

generateParagraph

public String generateParagraph(boolean opt_startWithLorem)
Generates a single lorem ipsum paragraph, of random length.

Parameters:
{boolean} - opt_startWithLorem Whether to start the sentence with the standard "Lorem ipsum..." first sentence.
Returns:
{string} The generated sentence.

generateSentence

public String generateSentence(boolean opt_startWithLorem)
Generates a single sentence, of random length.

Parameters:
{boolean} - opt_startWithLorem Whether to start the setnence with the standard "Lorem ipsum..." first sentence.
Returns:
{string} The generated sentence.

getSample

public String getSample()

setSample

public void setSample(String sample)

getDictionary

public String getDictionary()

setDictionary

public void setDictionary(String dictionary)

mean

public static double mean(int[] values)

mean

public static double mean(double[] values)

variance

public static double variance(double[] values)

sigma

public static double sigma(int[] values)

sigma

public static double sigma(double[] values)

sum

public static int sum(int[] values)

sum

public static double sum(double[] values)

contains

public static boolean contains(String[] array,
                               String val)

generateParagraphsHtml

public String generateParagraphsHtml(int quantity,
                                     boolean startWithLorem)
Generates a number of paragraphs, with each paragraph surrounded by HTML pararaph tags.

Parameters:
quantity -
startWithLorem -
Returns:

generateParagraphsHtml

public void generateParagraphsHtml(Appendable writer,
                                   int quantity,
                                   boolean startWithLorem)
                            throws IOException
Generates a number of paragraphs, with each paragraph surrounded by HTML pararaph tags.

Parameters:
writer -
quantity -
startWithLorem -
Throws:
IOException

generateOneParagraphHtml

public String generateOneParagraphHtml(int quantity,
                                       boolean startWithLorem)
Generates one paragraph of HTML, surrounded by HTML pararaph tags.

Parameters:
quantity -
startWithLorem -
Returns:

generateParagraphsFullHtml

public String generateParagraphsFullHtml(int quantity,
                                         boolean startWithLorem)
Generates a number of paragraphs, with each paragraph surrounded by HTML paragraph tags as a full HTML page.

Parameters:
quantity -
startWithLorem -
Returns:

generateParagraphsFullHtml

public void generateParagraphsFullHtml(Appendable writer,
                                       int quantity,
                                       boolean startWithLorem)
                                throws IOException
Generates a number of paragraphs, with each paragraph surrounded by HTML paragraph tags as a full HTML page.

Parameters:
writer -
quantity -
startWithLorem -
Throws:
IOException

generateParagraphsPlainText

public String generateParagraphsPlainText(int quantity,
                                          boolean startWithLorem)
Generates a number of paragraphs, with each paragraph separated by two newlines.

Parameters:
quantity -
startWithLorem -
Returns:

generateParagraphsPlainText

public void generateParagraphsPlainText(Appendable writer,
                                        int quantity,
                                        boolean startWithLorem)
                                 throws IOException
Generates a number of paragraphs, with each paragraph separated by two newlines.

Parameters:
writer -
quantity -
startWithLorem -
Throws:
IOException

generateParagraphsPlainText

public String generateParagraphsPlainText(int quantity,
                                          int maxCols,
                                          boolean startWithLorem)
Generates a number of paragraphs, with each paragraph separated by two newlines and no line exceeding maxCols columns

Parameters:
quantity -
startWithLorem -
Returns:

generateParagraphsPlainText

public void generateParagraphsPlainText(Appendable writer,
                                        int quantity,
                                        int maxCols,
                                        boolean startWithLorem)
                                 throws IOException
Generates a number of paragraphs, with each paragraph separated by two newlines and no line exceeding maxCols columns

Parameters:
writer -
quantity -
startWithLorem -
Throws:
IOException


Copyright © 2009-2012 The Apache Software Foundation. All Rights Reserved.