Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jbehave.core.reporters
Class PrintStreamOutput

    java.lang.Object
      org.jbehave.core.reporters.PrintStreamOutput

All Implemented Interfaces:
  StoryReporter

Direct Known Subclasses:
  HtmlOutput, TxtOutput, XmlOutput

    public abstract class PrintStreamOutput

extends Object
implements StoryReporter

Abstract story reporter that outputs to a PrintStream.

The output of the reported event is configurable via:

- custom output patterns, providing only the patterns that differ from default
- keywords localised for different languages, providing the i18n Locale
- flag to report failure trace

Let's look at example of providing custom output patterns, e.g. for the failed event.
we'd need to provide the custom pattern, say we want to have something like "(step being executed) <<< FAILED", keyed on the method name:

     Properties patterns = new Properties();
     patterns.setProperty("failed", "{0} <<< {1}");

The pattern is by default processed and formatted by the `MessageFormat`. Both the `format(String key, String defaultPattern, Object... args)` and `lookupPattern(String key, String defaultPattern)` methods are override-able and a different formatter or pattern lookup can be used by subclasses.

If the keyword "FAILED" (or any other keyword used by the reporter) needs to be expressed in a different language, all we need to do is to provide an instance of `LocalizedKeywords` using the appropriate `Locale`, e.g.

     Keywords keywords = new LocalizedKeywords(new Locale("it"));

Nested Class Summary
`static class` | `PrintStreamOutput.Format`

Constructor Summary
`protected` | `PrintStreamOutput(PrintStreamOutput.Format format, PrintStream output, Properties outputPatterns, Keywords keywords, boolean reportFailureTrace, boolean compressFailureTrace)`

Method Summary
`void` | `afterExamples()`
`void` | `afterScenario()`
`void` | `afterStory(boolean givenStory)`
`void` | `beforeExamples(List<String> steps, ExamplesTable table)`
`void` | `beforeScenario(String title)`
`void` | `beforeStep(String step)`
`void` | `beforeStory(Story story, boolean givenStory)`
`boolean` | `compressFailureTrace()`
`PrintStreamOutput` | `doCompressFailureTrace(boolean compressFailureTrace)`
`PrintStreamOutput` | `doReportFailureTrace(boolean reportFailureTrace)`
`void` | `dryRun()`
`protected Object[]` | `escape(PrintStreamOutput.Format format, Object... args)` Escapes args' string values according to format
`void` | `example(Map<String,String> tableRow)`
`void` | `failed(String step, Throwable storyFailure)`
`void` | `failedOutcomes(String step, OutcomesTable table)`
`protected String` | `format(String key, String defaultPattern, Object... args)` Formats event output by key, usually equal to the method name.
`protected String` | `formatTable(ExamplesTable table)`
`void` | `givenStories(GivenStories givenStories)`
`void` | `givenStories(List<String> storyPaths)`
`void` | `ignorable(String step)`
`protected String` | `lookupPattern(String key, String defaultPattern)` Looks up the format pattern for the event output by key, conventionally equal to the method name.
`void` | `narrative(Narrative narrative)`
`void` | `notPerformed(String step)`
`protected void` | `overwritePattern(String key, String pattern)`
`void` | `pending(String step)`
`void` | `pendingMethods(List<String> methods)`
`protected void` | `print(String text)` Prints text to output stream, replacing parameter start and end placeholders
`boolean` | `reportFailureTrace()`
`void` | `restarted(String step, Throwable cause)`
`void` | `scenarioMeta(Meta meta)`
`void` | `scenarioNotAllowed(Scenario scenario, String filter)`
`void` | `storyCancelled(Story story, StoryDuration storyDuration)`
`void` | `storyNotAllowed(Story story, String filter)`
`void` | `successful(String step)`
`String` | `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### PrintStreamOutput

    protected PrintStreamOutput(PrintStreamOutput.Format format,
                                PrintStream output,
                                Properties outputPatterns,
                                Keywords keywords,
                                boolean reportFailureTrace,
                                boolean compressFailureTrace)

Method Detail

### beforeStep

    public void beforeStep(String step)

  Specified by:
    `beforeStep` in interface `StoryReporter`

### successful

    public void successful(String step)

  Specified by:
    `successful` in interface `StoryReporter`

### ignorable

    public void ignorable(String step)

  Specified by:
    `ignorable` in interface `StoryReporter`

### pending

    public void pending(String step)

  Specified by:
    `pending` in interface `StoryReporter`

### notPerformed

    public void notPerformed(String step)

  Specified by:
    `notPerformed` in interface `StoryReporter`

### failed

    public void failed(String step,
                       Throwable storyFailure)

  Specified by:
    `failed` in interface `StoryReporter`

### failedOutcomes

    public void failedOutcomes(String step,
                               OutcomesTable table)

  Specified by:
    `failedOutcomes` in interface `StoryReporter`

### storyNotAllowed

    public void storyNotAllowed(Story story,
                                String filter)

  Specified by:
    `storyNotAllowed` in interface `StoryReporter`

### storyCancelled

    public void storyCancelled(Story story,
                               StoryDuration storyDuration)

  Specified by:
    `storyCancelled` in interface `StoryReporter`

### beforeStory

    public void beforeStory(Story story,
                            boolean givenStory)

  Specified by:
    `beforeStory` in interface `StoryReporter`

### narrative

    public void narrative(Narrative narrative)

  Specified by:
    `narrative` in interface `StoryReporter`

### afterStory

    public void afterStory(boolean givenStory)

  Specified by:
    `afterStory` in interface `StoryReporter`

### givenStories

    public void givenStories(GivenStories givenStories)

  Specified by:
    `givenStories` in interface `StoryReporter`

### givenStories

    public void givenStories(List<String> storyPaths)

  Specified by:
    `givenStories` in interface `StoryReporter`

### scenarioNotAllowed

    public void scenarioNotAllowed(Scenario scenario,
                                   String filter)

  Specified by:
    `scenarioNotAllowed` in interface `StoryReporter`

### beforeScenario

    public void beforeScenario(String title)

  Specified by:
    `beforeScenario` in interface `StoryReporter`

### scenarioMeta

    public void scenarioMeta(Meta meta)

  Specified by:
    `scenarioMeta` in interface `StoryReporter`

### afterScenario

    public void afterScenario()

  Specified by:
    `afterScenario` in interface `StoryReporter`

### beforeExamples

    public void beforeExamples(List<String> steps,
                               ExamplesTable table)

  Specified by:
    `beforeExamples` in interface `StoryReporter`

### example

    public void example(Map<String,String> tableRow)

  Specified by:
    `example` in interface `StoryReporter`

### afterExamples

    public void afterExamples()

  Specified by:
    `afterExamples` in interface `StoryReporter`

### dryRun

    public void dryRun()

  Specified by:
    `dryRun` in interface `StoryReporter`

### pendingMethods

    public void pendingMethods(List<String> methods)

  Specified by:
    `pendingMethods` in interface `StoryReporter`

### restarted

    public void restarted(String step,
                          Throwable cause)

  Specified by:
    `restarted` in interface `StoryReporter`

### format

    protected String format(String key,
                            String defaultPattern,
                            Object... args)

  Formats event output by key, usually equal to the method name.

  Parameters:
    `key` - the event key
    `defaultPattern` - the default pattern to return if a custom pattern is not found
    `args` - the args used to format output
  Returns:
    A formatted event output

### formatTable

    protected String formatTable(ExamplesTable table)

### escape

    protected Object[] escape(PrintStreamOutput.Format format,
                              Object... args)

  Escapes args' string values according to format

  Parameters:
    `format` - the Format used by the PrintStream
    `args` - the array of args to escape
  Returns:
    The cloned and escaped array of args

### lookupPattern

    protected String lookupPattern(String key,
                                   String defaultPattern)

  Looks up the format pattern for the event output by key, conventionally equal to the method name. The pattern is used by the {#format(String,String,Object...)} method and by default is formatted using the `MessageFormat.format(String, Object...)` method. If no pattern is found for key or needs to be overridden, the default pattern should be returned.

  Parameters:
    `key` - the format pattern key
    `defaultPattern` - the default pattern if no pattern is
  Returns:
    The format patter for the given key

### reportFailureTrace

    public boolean reportFailureTrace()

### doReportFailureTrace

    public PrintStreamOutput doReportFailureTrace(boolean reportFailureTrace)

### compressFailureTrace

    public boolean compressFailureTrace()

### doCompressFailureTrace

    public PrintStreamOutput doCompressFailureTrace(boolean compressFailureTrace)

### overwritePattern

    protected void overwritePattern(String key,
                                    String pattern)

### print

    protected void print(String text)

  Prints text to output stream, replacing parameter start and end placeholders

  Parameters:
    `text` - the String to print

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2013. All Rights Reserved.