Package adams.core

Class Shortening


  • public class Shortening
    extends Object
    Helper class for shortening operations.
    Version:
    $Revision$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • Shortening

        public Shortening()
    • Method Detail

      • shortenStart

        public static String shortenStart​(String s,
                                          int max)
        Shortens the string in the middle (inserting "..") if longer than specified number of characters.
        Parameters:
        s - the string to (potentially) shorten
        max - the maximum number of chars
        Returns:
        the processed string
      • shortenMiddle

        public static String shortenMiddle​(String s,
                                           int max)
        Shortens the string in the middle (inserting "..") if longer than specified number of characters.
        Parameters:
        s - the string to (potentially) shorten
        max - the maximum number of chars
        Returns:
        the processed string
      • shortenEnd

        public static String shortenEnd​(String s,
                                        int max)
        Shortens a string (and appends "...") if longer than the allowed maximum number of characters.
        Parameters:
        s - the string to process
        max - the maximum number of characters.
        Returns:
        the processed string
      • shorten

        public static String shorten​(String s,
                                     int max,
                                     ShorteningType type)
        Shortens a string if longer than the maximum.
        Parameters:
        s - the string to process
        max - the maximum number of characters
        type - the type of shortening
        Returns:
        the processed string