Framework Professional Edition Package


com.prosyst.util.pcommands
Class PCommandsUtils

java.lang.Object
  extended by com.prosyst.util.pcommands.PCommandsUtils

public class PCommandsUtils
extends java.lang.Object

This class provides utility methods for formatting plain text messages.

Author:
Maria Ivanova, Daniel Janev

Method Summary
static void fillColumn(java.io.PrintStream stream, int full, java.lang.String message)
          This method fills the last column of a text table according to the full line posotion and the message to print.
static void fillColumn(java.io.PrintStream stream, int full, java.lang.String message, int offset)
           
static java.lang.String[] makeArray(java.util.Enumeration e, int size)
          Creates an array of String from the elements in the enumeration.
static void printChars(java.io.PrintStream ps, char ch, int count, boolean nl)
           
static void printDictionary(java.util.Dictionary d, java.io.PrintStream stream, boolean toSort, int leftColumnNum, boolean leftLCAlign, int rightColumnNum, boolean leftRCAlign)
          Prints a dictionary in two columns, so that the keys are on the left column and the values on the right.
static int printSpaces(java.io.PrintStream stream, int columnSpaces, int stringSpaces)
          The method is used to align a string in a column.
static void quickSort(java.lang.String[] a, int begin, int length, boolean ignoreCase)
          Sorts the specified array using the quick sort algorithm.
static java.lang.String[] sort(java.util.Enumeration enumeration, int size, boolean ignoreCase, boolean backSort)
          Sorts the specified java.util.Enumeration according to the specified enumeration size, ignore case flag and back sort flag.
static void sort(java.lang.String[] array, boolean ignoreCase, boolean backSort)
          Sorts the specified java.lang.String array according to the ignore case flag and back sort flag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

printDictionary

public static void printDictionary(java.util.Dictionary d,
                                   java.io.PrintStream stream,
                                   boolean toSort,
                                   int leftColumnNum,
                                   boolean leftLCAlign,
                                   int rightColumnNum,
                                   boolean leftRCAlign)
Prints a dictionary in two columns, so that the keys are on the left column and the values on the right.

Parameters:
d - data to be printed
stream - to print data to
toSort - to sort the keys
leftColumnNum - number of symbols in the left column
leftLCAlign - left align of the left column
rightColumnNum - number of symbols in the right column
leftRCAlign - left align of the right column

makeArray

public static java.lang.String[] makeArray(java.util.Enumeration e,
                                           int size)
Creates an array of String from the elements in the enumeration. The objects in the enumeration are expected to be strings, so they are type-casted to String.

Parameters:
e - Enumeration of strings
size - length of the array to return
Returns:
an array of size elements

printSpaces

public static int printSpaces(java.io.PrintStream stream,
                              int columnSpaces,
                              int stringSpaces)
The method is used to align a string in a column. It prints the subtraction of column symbols and string symbols. If stringSpaces are more than columnSpaces, then a single space is written.

Parameters:
stream - to print data to
columnSpaces - number of symbols of a cloumn
stringSpaces - number of symbols of a string

fillColumn

public static void fillColumn(java.io.PrintStream stream,
                              int full,
                              java.lang.String message)
This method fills the last column of a text table according to the full line posotion and the message to print. If the message is longer than the available space, it will be printed in lines.

Parameters:
stream - the stream where the message will be printed.
full - the full line spaces.
message - the message which will fill the column of the text table.

fillColumn

public static void fillColumn(java.io.PrintStream stream,
                              int full,
                              java.lang.String message,
                              int offset)

sort

public static void sort(java.lang.String[] array,
                        boolean ignoreCase,
                        boolean backSort)
Sorts the specified java.lang.String array according to the ignore case flag and back sort flag.

Parameters:
array - the array which wil be sorted.
ignoreCase - specifies neither the sorting will be done case sensitive or case insensitive.
backSort - specifies either the greates element will be the first element of the returned array or will be the last.

quickSort

public static void quickSort(java.lang.String[] a,
                             int begin,
                             int length,
                             boolean ignoreCase)
Sorts the specified array using the quick sort algorithm.

Parameters:
a - the array for sorting.
begin - the begin index.
length - the length of the elements which will be sorted.
ignoreCase - if this flag is true then the elements comparison will be case insensitive.

sort

public static java.lang.String[] sort(java.util.Enumeration enumeration,
                                      int size,
                                      boolean ignoreCase,
                                      boolean backSort)
Sorts the specified java.util.Enumeration according to the specified enumeration size, ignore case flag and back sort flag.

Parameters:
enum - java.util.Enumeration wick should be sorted. Its elements must be instances of java.lang.String and the enumeration's size shoulb be equals or greater than the specified size.
size - the size of the sorted array which will be returned.
ignoreCase - specifies neither the sorting will be done case sensitive or case insensitive.
backSort - specifies either the greates element will be the first element of the returned array or will be the last.
Returns:
sorted array according to the specified parameters.

printChars

public static void printChars(java.io.PrintStream ps,
                              char ch,
                              int count,
                              boolean nl)
Parameters:
ps -
ch -
count -
nl -

Framework Professional Edition Package


Copyright © 1999-2007 ProSyst Software GmbH. All Rights Reserved