jklustor-overlap-0.0.2-20140619012940 (ChemAxon)


com.chemaxon.calculations.util
Class CharLayout

Object
  extended by com.chemaxon.calculations.util.CharLayout

@Beta
public final class CharLayout
extends Object

Simple utilities for character based multiline layouts.

Author:
Gabor Imre

Nested Class Summary
static class CharLayout.HA
          Possible horizontal alignments.
 
Method Summary
static List<String> align(List<String> text, CharLayout.HA ha)
          Align lines.
static List<String> join(CharLayout.HA ha, String sep, List<String>... cols)
          Join an arbitrary set of multiliners.
static List<String> join(List<String> col1, CharLayout.HA ha1, String sep, List<String> col2, CharLayout.HA ha2)
          Join two set of multiliners.
static String pad(String s, int l, CharLayout.HA ha)
          Align String to the given length.
static List<String> prefix(String prefix, List<String> text)
          Prefix lines.
static List<String> split(String s)
          Split to lines.
static String toString(List<String> s)
          Collapse into a multiline String.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

split

public static List<String> split(String s)
Split to lines.

Parameters:
s - A possibly multiline String
Returns:
Lines

toString

public static String toString(List<String> s)
Collapse into a multiline String.

Parameters:
s - Lines
Returns:
Single multiline String representation

pad

public static String pad(String s,
                         int l,
                         CharLayout.HA ha)
Align String to the given length.

Parameters:
s - A one line String. Note that the presence of '\n' characters are not checked.
l - Character count to pad to
ha - Alignment
Returns:
Aligned string with given length
Throws:
IllegalArgumentException - when the string is longer than the specified padded length

align

public static List<String> align(List<String> text,
                                 CharLayout.HA ha)
Align lines.

This method applies #pad(java.lang.String, int, com.chemaxon.descriptors.CharLayout.HA) to all lines, setting length to the length of the longest line.

Parameters:
text - Lines
ha - Desired alignemnt
Returns:
Aligned lines with equal line length

prefix

public static List<String> prefix(String prefix,
                                  List<String> text)
Prefix lines.

Parameters:
prefix - Prefix to use
text - Lines
Returns:
Prefixed lines

join

public static List<String> join(CharLayout.HA ha,
                                String sep,
                                List<String>... cols)
Join an arbitrary set of multiliners.

Parameters:
ha - Horizontal alignment for all of the columns
sep - Sparation between all columns
cols - Columns
Returns:
Joimed columns

join

public static List<String> join(List<String> col1,
                                CharLayout.HA ha1,
                                String sep,
                                List<String> col2,
                                CharLayout.HA ha2)
Join two set of multiliners.

Parameters:
col1 - First column
ha1 - Alignemnt of first column
sep - Separator between columns
col2 - Second column
ha2 - Alignment of the second column
Returns:
Lines with equal length

jklustor-overlap-0.0.2-20140619012940 (ChemAxon)