[Jspro-cvs] jsPro string.js,1.21,1.22
Brought to you by:
wigleys
|
From: <wi...@us...> - 2003-09-23 14:48:19
|
Update of /cvsroot/jspro/jsPro
In directory sc8-pr-cvs1:/tmp/cvs-serv28119
Modified Files:
string.js
Log Message:
fixed up String.cat() to optionally include newline characters
Index: string.js
===================================================================
RCS file: /cvsroot/jspro/jsPro/string.js,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** string.js 22 Sep 2003 06:28:47 -0000 1.21
--- string.js 23 Sep 2003 14:48:15 -0000 1.22
***************
*** 74,90 ****
/**
* Concatenate the string representation of the specified value to the end of
! * this string.
*
* @summary concatenate
* @author Stuart Wigley
* @author Randolph Fielding
! * @version 1.1, 09/20/03
* @interface <code>String.cat(vValue)</code>
* @param vValue the value to be concatenated to the end of this string
* @return a concatenated string
* @return <code>null</code> if an exception is encountered
* @throws IllegalArgumentException
*/
! String.prototype.cat = function(vValue) {
try {
--- 74,95 ----
/**
* Concatenate the string representation of the specified value to the end of
! * this string. If <code>iNewLine</code> is specified insert a newline
! * character between the two strings.
*
* @summary concatenate
* @author Stuart Wigley
* @author Randolph Fielding
! * @version 1.2, 09/23/03
* @interface <code>String.cat(vValue)</code>
+ * @interface <code>String.cat(vValue, iNewLine)</code>
* @param vValue the value to be concatenated to the end of this string
+ * @param iNewLine an integer representing the newline character to be
+ * used. (HTML: 0; XHTML: 1; WINDOWS: 2; UNIX: 3; MAC: 4)
+ * (optional)
* @return a concatenated string
* @return <code>null</code> if an exception is encountered
* @throws IllegalArgumentException
*/
! String.prototype.cat = function() {
try {
***************
*** 92,101 ****
var vError = null;
var iNumArguments = arguments.length;
! if (iNumArguments != 1) {
! throw vError = new IllegalArgumentException('String.cat', 1, iNumArguments);
}
! var sCatString = this + vValue.toString();
}
catch (vError) {
--- 97,128 ----
var vError = null;
var iNumArguments = arguments.length;
+ var vValue = '';
+ var iNewLine = -1;
! if (iNumArguments == 1) {
! vValue = arguments[0];
! } else if (iNumArguments == 2) {
! vValue = arguments[0];
! iNewLine = arguments[1];
! } else {
! throw vError = new IllegalArgumentException('String.cat', '1 or 2', iNumArguments);
}
! if ((typeof iNewLine != 'number') || (iNewLine.toString().indexOf('.') != -1)) {
! throw vError = new TypeMismatchException('String.cat', 'integer', typeof iNewLine);
! }
!
! var sNewLine = '';
!
! switch (iNewLine) {
! case 0 : sNewLine = '<BR>'; break;
! case 1 : sNewLine = '<br />'; break;
! case 2 : sNewLine = '\r\n'; break;
! case 3 : sNewLine = '\n'; break;
! case 4 : sNewLine = '\r'; break;
! default : break;
! }
!
! var sCatString = this + sNewLine + vValue.toString();
}
catch (vError) {
|