org.apache.flume.formatter.output
Class BucketPath

java.lang.Object
  extended by org.apache.flume.formatter.output.BucketPath

public class BucketPath
extends Object


Field Summary
static String TAG_REGEX
          These are useful to other classes which might want to search for tags in strings.
static Pattern tagPattern
           
 
Constructor Summary
BucketPath()
           
 
Method Summary
static boolean containsTag(String in)
          Returns true if in contains a substring matching TAG_REGEX (i.e.
static String escapeString(String in, Map<String,String> headers)
          Replace all substrings of form %{tagname} with get(tagname).toString() and all shorthand substrings of form %x with a special value.
static String escapeString(String in, Map<String,String> headers, boolean needRounding, int unit, int roundDown)
          A wrapper around escapeString(String, Map, TimeZone, boolean, int, int) with the timezone set to the default.
static String escapeString(String in, Map<String,String> headers, TimeZone timeZone, boolean needRounding, int unit, int roundDown)
          Replace all substrings of form %{tagname} with get(tagname).toString() and all shorthand substrings of form %x with a special value.
static String expandShorthand(char c)
           
static Map<String,String> getEscapeMapping(String in, Map<String,String> headers)
          Instead of replacing escape sequences in a string, this method returns a mapping of an attribute name to the value based on the escape sequence found in the argument string.
static Map<String,String> getEscapeMapping(String in, Map<String,String> headers, boolean needRounding, int unit, int roundDown)
           
static String replaceShorthand(char c, Map<String,String> headers)
          Hardcoded lookups for %x style escape replacement.
static String replaceShorthand(char c, Map<String,String> headers, boolean needRounding, int unit, int roundDown)
          A wrapper around replaceShorthand(char, Map, TimeZone, boolean, int, int) with the timezone set to the default.
static String replaceShorthand(char c, Map<String,String> headers, TimeZone timeZone, boolean needRounding, int unit, int roundDown)
          Hardcoded lookups for %x style escape replacement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG_REGEX

public static final String TAG_REGEX
These are useful to other classes which might want to search for tags in strings.

See Also:
Constant Field Values

tagPattern

public static final Pattern tagPattern
Constructor Detail

BucketPath

public BucketPath()
Method Detail

containsTag

public static boolean containsTag(String in)
Returns true if in contains a substring matching TAG_REGEX (i.e. of the form %{...} or %x.


expandShorthand

public static String expandShorthand(char c)

replaceShorthand

public static String replaceShorthand(char c,
                                      Map<String,String> headers)
Hardcoded lookups for %x style escape replacement. Add your own! All shorthands are Date format strings, currently. Returns the empty string if an escape is not recognized. Dates follow the same format as unix date, with a few exceptions.


replaceShorthand

public static String replaceShorthand(char c,
                                      Map<String,String> headers,
                                      boolean needRounding,
                                      int unit,
                                      int roundDown)
A wrapper around replaceShorthand(char, Map, TimeZone, boolean, int, int) with the timezone set to the default.


replaceShorthand

public static String replaceShorthand(char c,
                                      Map<String,String> headers,
                                      TimeZone timeZone,
                                      boolean needRounding,
                                      int unit,
                                      int roundDown)
Hardcoded lookups for %x style escape replacement. Add your own! All shorthands are Date format strings, currently. Returns the empty string if an escape is not recognized. Dates follow the same format as unix date, with a few exceptions.

Parameters:
c - - The character to replace.
headers - - Event headers
timeZone - - The timezone to use for formatting the timestamp
needRounding - - Should the timestamp be rounded down?
unit - - if needRounding is true, what unit to round down to. This must be one of the units specified by Calendar - HOUR, MINUTE or SECOND. Defaults to second, if none of these are present. Ignored if needRounding is false.
roundDown - - if needRounding is true, The time should be rounded to the largest multiple of this value, smaller than the time supplied, defaults to 1, if <= 0(rounds off to the second/minute/hour immediately lower than the timestamp supplied. Ignored if needRounding is false.
Returns:

escapeString

public static String escapeString(String in,
                                  Map<String,String> headers)
Replace all substrings of form %{tagname} with get(tagname).toString() and all shorthand substrings of form %x with a special value. Any unrecognized / not found tags will be replaced with the empty string. TODO(henry): we may want to consider taking this out of Event and into a more general class when we get more use cases for this pattern.


escapeString

public static String escapeString(String in,
                                  Map<String,String> headers,
                                  boolean needRounding,
                                  int unit,
                                  int roundDown)
A wrapper around escapeString(String, Map, TimeZone, boolean, int, int) with the timezone set to the default.


escapeString

public static String escapeString(String in,
                                  Map<String,String> headers,
                                  TimeZone timeZone,
                                  boolean needRounding,
                                  int unit,
                                  int roundDown)
Replace all substrings of form %{tagname} with get(tagname).toString() and all shorthand substrings of form %x with a special value. Any unrecognized / not found tags will be replaced with the empty string. TODO(henry): we may want to consider taking this out of Event and into a more general class when we get more use cases for this pattern.

Parameters:
needRounding - - Should the timestamp be rounded down?
unit - - if needRounding is true, what unit to round down to. This must be one of the units specified by Calendar - HOUR, MINUTE or SECOND. Defaults to second, if none of these are present. Ignored if needRounding is false.
roundDown - - if needRounding is true, The time should be rounded to the largest multiple of this value, smaller than the time supplied, defaults to 1, if <= 0(rounds off to the second/minute/hour immediately lower than the timestamp supplied. Ignored if needRounding is false.
Returns:
Escaped string.

getEscapeMapping

public static Map<String,String> getEscapeMapping(String in,
                                                  Map<String,String> headers)
Instead of replacing escape sequences in a string, this method returns a mapping of an attribute name to the value based on the escape sequence found in the argument string.


getEscapeMapping

public static Map<String,String> getEscapeMapping(String in,
                                                  Map<String,String> headers,
                                                  boolean needRounding,
                                                  int unit,
                                                  int roundDown)


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