org.apache.hadoop.hbase.util
Class Strings

java.lang.Object
  extended by org.apache.hadoop.hbase.util.Strings

@InterfaceAudience.Private
public class Strings
extends Object

Utility for Strings.


Field Summary
static String DEFAULT_KEYVALUE_SEPARATOR
           
static String DEFAULT_SEPARATOR
           
 
Constructor Summary
Strings()
           
 
Method Summary
static StringBuilder appendKeyValue(StringBuilder sb, String key, Object value)
          Append to a StringBuilder a key/value.
static StringBuilder appendKeyValue(StringBuilder sb, String key, Object value, String separator, String keyValueSeparator)
          Append to a StringBuilder a key/value.
static String domainNamePointerToHostName(String dnPtr)
          Given a PTR string generated via reverse DNS lookup, return everything except the trailing period.
static boolean isEmpty(String input)
          Null-safe length check.
static String join(CharSequence separator, Iterable<?> strings)
          Concatenates strings, using a separator.
static String padFront(String input, char padding, int length)
          Push the input string to the right by appending a character before it, usually a space.
static String repeat(char c, int reapeatFor)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SEPARATOR

public static final String DEFAULT_SEPARATOR
See Also:
Constant Field Values

DEFAULT_KEYVALUE_SEPARATOR

public static final String DEFAULT_KEYVALUE_SEPARATOR
See Also:
Constant Field Values
Constructor Detail

Strings

public Strings()
Method Detail

appendKeyValue

public static StringBuilder appendKeyValue(StringBuilder sb,
                                           String key,
                                           Object value)
Append to a StringBuilder a key/value. Uses default separators.

Parameters:
sb - StringBuilder to use
key - Key to append.
value - Value to append.
Returns:
Passed sb populated with key/value.

appendKeyValue

public static StringBuilder appendKeyValue(StringBuilder sb,
                                           String key,
                                           Object value,
                                           String separator,
                                           String keyValueSeparator)
Append to a StringBuilder a key/value. Uses default separators.

Parameters:
sb - StringBuilder to use
key - Key to append.
value - Value to append.
separator - Value to use between key and value.
keyValueSeparator - Value to use between key/value sets.
Returns:
Passed sb populated with key/value.

domainNamePointerToHostName

public static String domainNamePointerToHostName(String dnPtr)
Given a PTR string generated via reverse DNS lookup, return everything except the trailing period. Example for host.example.com., return host.example.com

Parameters:
dnPtr - a domain name pointer (PTR) string.
Returns:
Sanitized hostname with last period stripped off.

isEmpty

public static boolean isEmpty(String input)
Null-safe length check.

Parameters:
input -
Returns:
true if null or length==0

padFront

public static String padFront(String input,
                              char padding,
                              int length)
Push the input string to the right by appending a character before it, usually a space.

Parameters:
input - the string to pad
padding - the character to repeat to the left of the input string
length - the desired total length including the padding
Returns:
padding characters + input

repeat

public static String repeat(char c,
                            int reapeatFor)
Parameters:
c - repeat this character
reapeatFor - the length of the output String
Returns:
c, repeated repeatFor times

join

public static String join(CharSequence separator,
                          Iterable<?> strings)
Concatenates strings, using a separator.

Parameters:
separator - Separator to join with.
strings - Strings to join.


Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.