Methods Summary |
---|
public static java.lang.String[] | add(java.lang.String[] x, java.lang.String sep, java.lang.String[] y)
String[] result = new String[x.length];
for ( int i = 0; i < x.length; i++ ) {
result[i] = x[i] + sep + y[i];
}
return result;
|
public static boolean | booleanValue(java.lang.String tfString)
String trimmed = tfString.trim().toLowerCase();
return trimmed.equals( "true" ) || trimmed.equals( "t" );
|
private static java.lang.String | cleanAlias(java.lang.String alias)Clean the generated alias by removing any non-alpha characters from the
beginning.
char[] chars = alias.toCharArray();
// short cut check...
if ( !Character.isLetter( chars[0] ) ) {
for ( int i = 1; i < chars.length; i++ ) {
// as soon as we encounter our first letter, return the substring
// from that position
if ( Character.isLetter( chars[i] ) ) {
return alias.substring( i );
}
}
}
return alias;
|
public static int | countUnquoted(java.lang.String string, char character)
if ( '\'" == character ) {
throw new IllegalArgumentException( "Unquoted count of quotes is invalid" );
}
if (string == null)
return 0;
// Impl note: takes advantage of the fact that an escpaed single quote
// embedded within a quote-block can really be handled as two seperate
// quote-blocks for the purposes of this method...
int count = 0;
int stringLength = string.length();
boolean inQuote = false;
for ( int indx = 0; indx < stringLength; indx++ ) {
char c = string.charAt( indx );
if ( inQuote ) {
if ( '\'" == c ) {
inQuote = false;
}
}
else if ( '\'" == c ) {
inQuote = true;
}
else if ( c == character ) {
count++;
}
}
return count;
|
public static int | firstIndexOfChar(java.lang.String sqlString, java.lang.String string, int startindex)
int matchAt = -1;
for ( int i = 0; i < string.length(); i++ ) {
int curMatch = sqlString.indexOf( string.charAt( i ), startindex );
if ( curMatch >= 0 ) {
if ( matchAt == -1 ) { // first time we find match!
matchAt = curMatch;
}
else {
matchAt = Math.min( matchAt, curMatch );
}
}
}
return matchAt;
|
public static java.lang.String | generateAlias(java.lang.String description)
return generateAliasRoot(description) + '_";
|
public static java.lang.String | generateAlias(java.lang.String description, int unique)Generate a nice alias for the given class name or collection role
name and unique integer. Subclasses of Loader do not have
to use aliases of this form.
return generateAliasRoot(description) +
Integer.toString(unique) +
'_";
|
private static java.lang.String | generateAliasRoot(java.lang.String description)Generates a root alias by truncating the "root name" defined by
the incoming decription and removing/modifying any non-valid
alias characters.
String result = truncate( unqualifyEntityName(description), ALIAS_TRUNCATE_LENGTH )
.toLowerCase()
.replace( '/", '_" ) // entityNames may now include slashes for the representations
.replace( '$", '_" ); //classname may be an inner class
result = cleanAlias( result );
if ( Character.isDigit( result.charAt(result.length()-1) ) ) {
return result + "x"; //ick!
}
else {
return result;
}
|
public static boolean | isEmpty(java.lang.String string)
return string == null || string.length() == 0;
|
public static boolean | isNotEmpty(java.lang.String string)
return string != null && string.length() > 0;
|
public static java.lang.String | join(java.lang.String seperator, java.lang.String[] strings)
int length = strings.length;
if ( length == 0 ) return "";
StringBuffer buf = new StringBuffer( length * strings[0].length() )
.append( strings[0] );
for ( int i = 1; i < length; i++ ) {
buf.append( seperator ).append( strings[i] );
}
return buf.toString();
|
public static java.lang.String | join(java.lang.String seperator, java.util.Iterator objects)
StringBuffer buf = new StringBuffer();
if ( objects.hasNext() ) buf.append( objects.next() );
while ( objects.hasNext() ) {
buf.append( seperator ).append( objects.next() );
}
return buf.toString();
|
public static int | lastIndexOfLetter(java.lang.String string)
for ( int i=0; i<string.length(); i++ ) {
char character = string.charAt(i);
if ( !Character.isLetter(character) /*&& !('_'==character)*/ ) return i-1;
}
return string.length()-1;
|
public static int[] | locateUnquoted(java.lang.String string, char character)
if ( '\'" == character ) {
throw new IllegalArgumentException( "Unquoted count of quotes is invalid" );
}
if (string == null) {
return new int[0];
}
ArrayList locations = new ArrayList( 20 );
// Impl note: takes advantage of the fact that an escpaed single quote
// embedded within a quote-block can really be handled as two seperate
// quote-blocks for the purposes of this method...
int stringLength = string.length();
boolean inQuote = false;
for ( int indx = 0; indx < stringLength; indx++ ) {
char c = string.charAt( indx );
if ( inQuote ) {
if ( '\'" == c ) {
inQuote = false;
}
}
else if ( '\'" == c ) {
inQuote = true;
}
else if ( c == character ) {
locations.add( new Integer( indx ) );
}
}
return ArrayHelper.toIntArray( locations );
|
public static java.lang.String | moveAndToBeginning(java.lang.String filter)
if ( filter.trim().length()>0 ){
filter += " and ";
if ( filter.startsWith(" and ") ) filter = filter.substring(4);
}
return filter;
|
public static java.lang.String[] | multiply(java.lang.String string, java.util.Iterator placeholders, java.util.Iterator replacements)
String[] result = new String[]{string};
while ( placeholders.hasNext() ) {
result = multiply( result, ( String ) placeholders.next(), ( String[] ) replacements.next() );
}
return result;
|
private static java.lang.String[] | multiply(java.lang.String[] strings, java.lang.String placeholder, java.lang.String[] replacements)
String[] results = new String[replacements.length * strings.length];
int n = 0;
for ( int i = 0; i < replacements.length; i++ ) {
for ( int j = 0; j < strings.length; j++ ) {
results[n++] = replaceOnce( strings[j], placeholder, replacements[i] );
}
}
return results;
|
public static java.lang.String | qualifier(java.lang.String qualifiedName)
int loc = qualifiedName.lastIndexOf(".");
return ( loc < 0 ) ? "" : qualifiedName.substring( 0, loc );
|
public static java.lang.String | qualify(java.lang.String prefix, java.lang.String name)
if ( name == null || prefix == null ) {
throw new NullPointerException();
}
return new StringBuffer( prefix.length() + name.length() + 1 )
.append(prefix)
.append('.")
.append(name)
.toString();
|
public static java.lang.String[] | qualify(java.lang.String prefix, java.lang.String[] names)
if ( prefix == null ) return names;
int len = names.length;
String[] qualified = new String[len];
for ( int i = 0; i < len; i++ ) {
qualified[i] = qualify( prefix, names[i] );
}
return qualified;
|
public static java.lang.String | repeat(java.lang.String string, int times)
StringBuffer buf = new StringBuffer( string.length() * times );
for ( int i = 0; i < times; i++ ) buf.append( string );
return buf.toString();
|
public static java.lang.String | replace(java.lang.String template, java.lang.String placeholder, java.lang.String replacement)
return replace( template, placeholder, replacement, false );
|
public static java.lang.String[] | replace(java.lang.String[] templates, java.lang.String placeholder, java.lang.String replacement)
String[] result = new String[templates.length];
for ( int i =0; i<templates.length; i++ ) {
result[i] = replace( templates[i], placeholder, replacement );;
}
return result;
|
public static java.lang.String | replace(java.lang.String template, java.lang.String placeholder, java.lang.String replacement, boolean wholeWords)
int loc = template == null ? -1 : template.indexOf( placeholder );
if ( loc < 0 ) {
return template;
}
else {
final boolean actuallyReplace = !wholeWords ||
loc + placeholder.length() == template.length() ||
!Character.isJavaIdentifierPart( template.charAt( loc + placeholder.length() ) );
String actualReplacement = actuallyReplace ? replacement : placeholder;
return new StringBuffer( template.substring( 0, loc ) )
.append( actualReplacement )
.append( replace( template.substring( loc + placeholder.length() ),
placeholder,
replacement,
wholeWords ) ).toString();
}
|
public static java.lang.String | replaceOnce(java.lang.String template, java.lang.String placeholder, java.lang.String replacement)
int loc = template == null ? -1 : template.indexOf( placeholder );
if ( loc < 0 ) {
return template;
}
else {
return new StringBuffer( template.substring( 0, loc ) )
.append( replacement )
.append( template.substring( loc + placeholder.length() ) )
.toString();
}
|
public static java.lang.String | root(java.lang.String qualifiedName)
int loc = qualifiedName.indexOf( "." );
return ( loc < 0 ) ? qualifiedName : qualifiedName.substring( 0, loc );
|
public static java.lang.String[] | split(java.lang.String seperators, java.lang.String list)
return split( seperators, list, false );
|
public static java.lang.String[] | split(java.lang.String seperators, java.lang.String list, boolean include)
StringTokenizer tokens = new StringTokenizer( list, seperators, include );
String[] result = new String[ tokens.countTokens() ];
int i = 0;
while ( tokens.hasMoreTokens() ) {
result[i++] = tokens.nextToken();
}
return result;
|
public static java.lang.String[] | suffix(java.lang.String[] columns, java.lang.String suffix)
if ( suffix == null ) return columns;
String[] qualified = new String[columns.length];
for ( int i = 0; i < columns.length; i++ ) {
qualified[i] = suffix( columns[i], suffix );
}
return qualified;
|
private static java.lang.String | suffix(java.lang.String name, java.lang.String suffix)
return ( suffix == null ) ? name : name + suffix;
|
public static java.lang.String | toLowerCase(java.lang.String str)
return str==null ? null : str.toLowerCase();
|
public static java.lang.String | toString(java.lang.Object[] array)
int len = array.length;
if ( len == 0 ) return "";
StringBuffer buf = new StringBuffer( len * 12 );
for ( int i = 0; i < len - 1; i++ ) {
buf.append( array[i] ).append(", ");
}
return buf.append( array[len - 1] ).toString();
|
public static java.lang.String | toUpperCase(java.lang.String str)
return str==null ? null : str.toUpperCase();
|
public static java.lang.String | truncate(java.lang.String string, int length)
if ( string.length() <= length ) {
return string;
}
else {
return string.substring( 0, length );
}
|
public static java.lang.String | unqualify(java.lang.String qualifiedName)
int loc = qualifiedName.lastIndexOf(".");
return ( loc < 0 ) ? qualifiedName : qualifiedName.substring( qualifiedName.lastIndexOf(".") + 1 );
|
public static java.lang.String | unqualifyEntityName(java.lang.String entityName)
String result = unqualify(entityName);
int slashPos = result.indexOf( '/" );
if ( slashPos > 0 ) {
result = result.substring( 0, slashPos - 1 );
}
return result;
|
public static java.lang.String | unroot(java.lang.String qualifiedName)
int loc = qualifiedName.indexOf( "." );
return ( loc < 0 ) ? qualifiedName : qualifiedName.substring( loc+1, qualifiedName.length() );
|