public class Utility
extends java.lang.Object
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Modifier and Type | Field and Description |
---|---|
private static java.util.Map<java.lang.String,java.text.SimpleDateFormat> |
formats
Map used for storing date formats for formattedDate() methods
|
private static org.apache.log4j.Logger |
LOGGER
Logger
|
Modifier | Constructor and Description |
---|---|
private |
Utility()
Utility class, no instances should be created
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
characterInsert(java.lang.String saData,
java.lang.String saInsert,
int iaMinSectionLength,
int iaMaxSectionLength,
java.lang.String saBreakCharacters)
Ensure that a given character is inserted at intervals along a String.
|
static java.lang.String |
formattedDate(java.util.Date date)
Formats the System date to appear as MM/dd/yyyy HH:mm:ss.SSS
|
static java.lang.String |
formattedDate(java.util.Date date,
java.lang.String formatString)
Formats the System date in the order determined by the formatString
|
static java.lang.String |
formattedNumber(long number,
java.lang.String format)
Formats a number using the supplied format template
|
static java.lang.Object[] |
getLongestValues(javax.swing.table.TableModel model)
Gets longest values, one for each column
|
static void |
initColumnSizes(javax.swing.JTable table,
javax.swing.table.TableModel model)
This method picks good column sizes.
|
static java.lang.String |
replace(java.lang.String aString,
java.lang.String aOldSubString,
java.lang.String aNewSubString)
Replaces the specified substring with another in the first (whole) string.
|
static java.lang.String |
replace(java.lang.String saString,
java.lang.String saOldSubString,
java.lang.String saNewSubString,
int iaStartIndex,
boolean replaceAll)
Replaces the specified substring with another in the first (whole)
string starting at iaStartIndex.
|
static java.lang.String[] |
splitWithQuotes(java.lang.String data,
java.lang.String splitPattern)
Split a string at a pattern, but be sensitive to quoted sections of the
string.
|
private static final org.apache.log4j.Logger LOGGER
private static java.util.Map<java.lang.String,java.text.SimpleDateFormat> formats
public static java.lang.String replace(java.lang.String aString, java.lang.String aOldSubString, java.lang.String aNewSubString)
aString
- The whole string.aOldSubString
- The substrinng to be replaced.aNewSubString
- The new substring to replace the old one.public static java.lang.String replace(java.lang.String saString, java.lang.String saOldSubString, java.lang.String saNewSubString, int iaStartIndex, boolean replaceAll)
saString
- The whole string.saOldSubString
- The substring to be replaced.saNewSubString
- The new substring to replace the old one.iaStartIndex
- The index at which to start the process of 'search
and replace'.replaceAll
- Whether to replace all matches or only the firstpublic static void initColumnSizes(javax.swing.JTable table, javax.swing.table.TableModel model)
table
- The table contains the columns for comparisionmodel
- This is the Default Table Model of the Jtablepublic static java.lang.Object[] getLongestValues(javax.swing.table.TableModel model)
model
- The DefaultTable modelpublic static java.lang.String formattedDate(java.util.Date date)
date
- The system date that needs to be formattedpublic static java.lang.String formattedDate(java.util.Date date, java.lang.String formatString)
date
- The System DateformatString
- The desired format for writing out the datepublic static java.lang.String formattedNumber(long number, java.lang.String format)
number
- The number to formatformat
- The format templatepublic static final java.lang.String characterInsert(java.lang.String saData, java.lang.String saInsert, int iaMinSectionLength, int iaMaxSectionLength, java.lang.String saBreakCharacters)
saData
- The string to have characters inserted intosaInsert
- The String to insert into the data stringiaMinSectionLength
- The minumum number of characters in the data
string, that must occur between inserted stringsiaMaxSectionLength
- The maximum number of characters to allow
in the data string between inserted stringssaBreakCharacters
- The characters that signal a possible insertion
point in the data stringpublic static java.lang.String[] splitWithQuotes(java.lang.String data, java.lang.String splitPattern)
data
- String The string to be split into separate stringssplitPattern
- String The pattern used to split the string