logahawk.formatters
Class ArrayArgFormatter

java.lang.Object
  extended by logahawk.formatters.AbstractArgumentFormatter
      extended by logahawk.formatters.CollectionArgFormatter
          extended by logahawk.formatters.ArrayArgFormatter
All Implemented Interfaces:
ArgumentFormatter

@Immutable
public class ArrayArgFormatter
extends CollectionArgFormatter

Formats arrays of objects using a wrapped CollectionArgFormatter. Arrays are not truly Iterable, so this wrapper class "unpacks" the array and passes the objects to the CollectionArgFormatter. This will only handle arrays that are 4 dimensions or less.


Field Summary
protected  CollectionArgFormatter collectionArgFormatter
          Used to format the objects after unpacking
 
Fields inherited from class logahawk.formatters.AbstractArgumentFormatter
indentor
 
Constructor Summary
ArrayArgFormatter()
          Uses a MultiLineCollectionArgFormatter for collectionArgFormatter.
ArrayArgFormatter(CollectionArgFormatter collectionArgFormatter)
           
 
Method Summary
 boolean canFormat(Object obj)
          Formats anything that implements Iterable.
 String format(Object obj, Collection<ArgumentFormatter> formatters, int indentLevel)
          This converts the object into a String that represent the object.
protected  void unpackDoubleDimensionArray(Object obj, List<Object> list, Collection<ArgumentFormatter> formatters, int indentLevel, Character arrayType)
          Double-dimension arrays are fairly common in 2D application.s
protected  void unpackQuadDimensionArray(Object obj, List<Object> list, Collection<ArgumentFormatter> formatters, int indentLevel, Character arrayType)
          Four dimensions is common for programs that use quaternions.
protected  void unpackSingleDimensionArray(Object obj, List<Object> list, Collection<ArgumentFormatter> formatters, int indentLevel, Character arrayType)
           
protected  void unpackTripleDimensionArray(Object obj, List<Object> list, Collection<ArgumentFormatter> formatters, int indentLevel, Character arrayType)
          Triple-dimension arrays are often used for Vectors and 3-dimensional matricies
 
Methods inherited from class logahawk.formatters.AbstractArgumentFormatter
findFormatter, getChildObjectFormat, getIndentor, setIndentor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

collectionArgFormatter

protected final CollectionArgFormatter collectionArgFormatter
Used to format the objects after unpacking

Constructor Detail

ArrayArgFormatter

public ArrayArgFormatter()
Uses a MultiLineCollectionArgFormatter for collectionArgFormatter.


ArrayArgFormatter

public ArrayArgFormatter(CollectionArgFormatter collectionArgFormatter)
Method Detail

canFormat

public boolean canFormat(Object obj)
Description copied from class: CollectionArgFormatter
Formats anything that implements Iterable.

Specified by:
canFormat in interface ArgumentFormatter
Overrides:
canFormat in class CollectionArgFormatter

format

public String format(Object obj,
                     Collection<ArgumentFormatter> formatters,
                     int indentLevel)
Description copied from interface: ArgumentFormatter
This converts the object into a String that represent the object. The String may contain line breaks, but should not include a trailing line break. The first line of the result should NOT include any indentation, that should be handled by the calling class. If the object is complex and contains other objects, this ArgumentFormatter may use the provided list of ArgumentFormatter objects to find a more appropriate formatter. To make things look nice, the "indentLevel" is provided. The indent level should always be incremented by one when calling downward into other ArgumentFormatters.


unpackDoubleDimensionArray

protected void unpackDoubleDimensionArray(Object obj,
                                          List<Object> list,
                                          Collection<ArgumentFormatter> formatters,
                                          int indentLevel,
                                          Character arrayType)
Double-dimension arrays are fairly common in 2D application.s


unpackQuadDimensionArray

protected void unpackQuadDimensionArray(Object obj,
                                        List<Object> list,
                                        Collection<ArgumentFormatter> formatters,
                                        int indentLevel,
                                        Character arrayType)
Four dimensions is common for programs that use quaternions.


unpackSingleDimensionArray

protected void unpackSingleDimensionArray(Object obj,
                                          List<Object> list,
                                          Collection<ArgumentFormatter> formatters,
                                          int indentLevel,
                                          Character arrayType)

unpackTripleDimensionArray

protected void unpackTripleDimensionArray(Object obj,
                                          List<Object> list,
                                          Collection<ArgumentFormatter> formatters,
                                          int indentLevel,
                                          Character arrayType)
Triple-dimension arrays are often used for Vectors and 3-dimensional matricies