com.healthmarketscience.common.util
Class StringAppendableExt

java.lang.Object
  extended by com.healthmarketscience.common.util.AppendableExt
      extended by com.healthmarketscience.common.util.StringAppendableExt
All Implemented Interfaces:
Appendable

public class StringAppendableExt
extends AppendableExt

Simple extension of AppendableExt that swallows IOExceptions under the assumption that it will generally be used with Appendables which do not actually throw any IOExceptions (i.e. StringBuilder). Default constructors will use a StringBuilder for the underlying Appendable.

In the event that an underlying Appendable is used which does actually thrown IOExceptions, they will be trapped, and at any time the last IOException can be obtained using getIOException().

This class is not thread-safe.


Constructor Summary
StringAppendableExt()
          Initialize a new StringAppendableExt based on a StringBuilder.
StringAppendableExt(Appendable app)
          Initialize a new StringAppendableExt based on the given Appendable.
StringAppendableExt(Appendable app, Object context)
          Initialize a new StringAppendableExt based on the given Appendable and context.
StringAppendableExt(int capacity)
          Initialize a new StringAppendableExt based on a StringBuilder, with a specified initial capacity.
StringAppendableExt(int size, Object context)
          Initialize a new StringAppendableExt based on a StringBuilder, with a specified initial capacity and given context.
 
Method Summary
 StringAppendableExt append(Appendee a)
          Will call the appendTo() method on the given object.
 StringAppendableExt append(char c)
           
 StringAppendableExt append(CharSequence s)
          
 StringAppendableExt append(CharSequence s, int start, int end)
          
 StringAppendableExt append(Iterable<?> iable, Object delimiter)
          Will iterate the given Iterable and append each object separated by the given delimiter.
 StringAppendableExt append(Object o)
          Will call append(String.valueOf(o)) with the given object (unless the object is an Appendee or CharSequence in which case it will be passed to the appropriate method).
 IOException getIOException()
          Get the last IOException thrown by an append call, or null if no IOException was caught.
 
Methods inherited from class com.healthmarketscience.common.util.AppendableExt
getAppendable, getContext, setContext, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringAppendableExt

public StringAppendableExt()
Initialize a new StringAppendableExt based on a StringBuilder.


StringAppendableExt

public StringAppendableExt(int capacity)
Initialize a new StringAppendableExt based on a StringBuilder, with a specified initial capacity.

Parameters:
capacity - the initial capacity for the StringBuilder.

StringAppendableExt

public StringAppendableExt(int size,
                           Object context)
Initialize a new StringAppendableExt based on a StringBuilder, with a specified initial capacity and given context.

Parameters:
size - the initial capacity for the StringBuilder.
context - initial append context

StringAppendableExt

public StringAppendableExt(Appendable app)
Initialize a new StringAppendableExt based on the given Appendable.

Parameters:
app - initial underlying Appendable

StringAppendableExt

public StringAppendableExt(Appendable app,
                           Object context)
Initialize a new StringAppendableExt based on the given Appendable and context.

Parameters:
app - initial underlying Appendable
context - initial append context
Method Detail

append

public StringAppendableExt append(char c)
Specified by:
append in interface Appendable
Overrides:
append in class AppendableExt

append

public StringAppendableExt append(CharSequence s)
Description copied from class: AppendableExt

Note that if the given CharSequence is also an Appendee, it will be handled as an Appendee instead.

Specified by:
append in interface Appendable
Overrides:
append in class AppendableExt

append

public StringAppendableExt append(CharSequence s,
                                  int start,
                                  int end)
Description copied from class: AppendableExt

Note that if the given CharSequence is also an Appendee, it will be handled as an Appendee instead (but the range will still be respected).

Specified by:
append in interface Appendable
Overrides:
append in class AppendableExt

append

public StringAppendableExt append(Appendee a)
Description copied from class: AppendableExt
Will call the appendTo() method on the given object.

Overrides:
append in class AppendableExt
Parameters:
a - object to append to this AppendableExt
Returns:
this AppendableExt object

append

public StringAppendableExt append(Object o)
Description copied from class: AppendableExt
Will call append(String.valueOf(o)) with the given object (unless the object is an Appendee or CharSequence in which case it will be passed to the appropriate method).

Overrides:
append in class AppendableExt
Parameters:
o - object to append to this AppendableExt
Returns:
this AppendableExt object

append

public StringAppendableExt append(Iterable<?> iable,
                                  Object delimiter)
Description copied from class: AppendableExt
Will iterate the given Iterable and append each object separated by the given delimiter.

Overrides:
append in class AppendableExt
Parameters:
iable - an Iterable object
delimiter - delimiter to append between each object in the iable
Returns:
this AppendableExt object

getIOException

public IOException getIOException()
Get the last IOException thrown by an append call, or null if no IOException was caught.

Returns:
the last IOException thrown by an append call, or null if no IOException was caught.


Copyright © 2006-2016 Health Market Science. All Rights Reserved.