< entity
*/
public static final String LESS_THAN_ENTITY = "<";
/**
* Escaped > entity
*/
public static final String GREATER_THAN_ENTITY = ">";
/**
* Escaped & entity
*/
public static final String AMPERSAND_ENTITY = "&";
/**
* Escaped ' entity
*/
public static final String APOSTROPHE_ENTITY = "'";
/**
* Escaped " entity
*/
public static final String QUOTE_ENTITY = """;
private static final String DATE_PATTERN = "yyyy-MM-dd";
/**
* Formatter used by the getDateFormatted method.
*/
private static final ThreadSafeDateFormat DATE_FORMAT = new ThreadSafeDateFormat( DATE_PATTERN );
private static final String TIME_PATTERN = "HH:mm:ss";
/**
* Formatter used by the getTimeFormatted method.
*/
private static final ThreadSafeDateFormat TIME_FORMAT = new ThreadSafeDateFormat( TIME_PATTERN );
/**
* Formatter used to parse date/timestamp.
*/
private static final ThreadSafeDateFormat TIMESTAMP_FORMAT_1 = new ThreadSafeDateFormat( "yyyy/MM/dd HH:mm:ss" );
private static final ThreadSafeDateFormat TIMESTAMP_FORMAT_2 = new ThreadSafeDateFormat( "yyyy-MM-dd HH:mm:ss" );
private static final ThreadSafeDateFormat TIMESTAMP_FORMAT_3 = new ThreadSafeDateFormat( "yyyy/MM/dd HH:mm:ss z" );
private static final ThreadSafeDateFormat TIMESTAMP_FORMAT_4 = new ThreadSafeDateFormat( "yyyy-MM-dd HH:mm:ss z" );
/**
* Date the changes were committed
*/
private Date date;
/**
* User who made changes
*/
private String author;
/**
* comment provided at commit time
*/
private String comment = "";
/**
* List of ChangeFile
*/
private List]]> from comments (replace it with ] ] >).
*
* @param message The message to modify
* @return a clean string
*/
private String removeCDataEnd( String message )
{
// check for invalid sequence ]]>
int endCdata;
while ( message != null && ( endCdata = message.indexOf( "]]>" ) ) > -1 )
{
message = message.substring( 0, endCdata ) + "] ] >" + message.substring( endCdata + 3, message.length() );
}
return message;
}
/**
* Escape the toString of the given object.
* For use in an attribute value.
* swiped from jakarta-commons/betwixt -- XMLUtils.java
*
* @param value escape value.toString()
* @return text with characters restricted (for use in attributes) escaped
*/
public static String escapeValue( Object value )
{
StringBuilder buffer = new StringBuilder( value.toString() );
for ( int i = 0, size = buffer.length(); i < size; i++ )
{
switch ( buffer.charAt( i ) )
{
case'<':
buffer.replace( i, i + 1, LESS_THAN_ENTITY );
size += 3;
i += 3;
break;
case'>':
buffer.replace( i, i + 1, GREATER_THAN_ENTITY );
size += 3;
i += 3;
break;
case'&':
buffer.replace( i, i + 1, AMPERSAND_ENTITY );
size += 4;
i += 4;
break;
case'\'':
buffer.replace( i, i + 1, APOSTROPHE_ENTITY );
size += 5;
i += 5;
break;
case'\"':
buffer.replace( i, i + 1, QUOTE_ENTITY );
size += 5;
i += 5;
break;
default:
}
}
return buffer.toString();
}
}