[Jspro-cvs] jsPro string.js,1.22,1.23
Brought to you by:
wigleys
|
From: <gat...@us...> - 2003-09-25 05:04:35
|
Update of /cvsroot/jspro/jsPro
In directory sc8-pr-cvs1:/tmp/cvs-serv20728
Modified Files:
string.js
Log Message:
QA: String.cat() for consistency, new error type, and somewhat different logic due to the circumstances in which the document type variable effects the way in which error cases must be tested; this method can now reuse the jsProConstants.DOCTYPE_????? constants, and the updated comments for this method support this reuse
Index: string.js
===================================================================
RCS file: /cvsroot/jspro/jsPro/string.js,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** string.js 23 Sep 2003 14:48:15 -0000 1.22
--- string.js 25 Sep 2003 05:03:01 -0000 1.23
***************
*** 74,89 ****
/**
* 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
--- 74,92 ----
/**
* Concatenate the string representation of the specified value to the end of
! * this string. An end-of-line terminator specific to a certain document type
! * will be inserted between the string and the specified value if a document
! * type is specified.
*
* @summary concatenate
* @author Stuart Wigley
* @author Randolph Fielding
! * @version 1.3, 09/25/03
* @interface <code>String.cat(vValue)</code>
! * @interface <code>String.cat(vValue, iDocType)</code>
* @param vValue the value to be concatenated to the end of this string
! * @param iDocType an integer representing the document type that the
! * end-of-line terminator between the string and
! * <code>vValue</code> conforms to (HTML: 0; XHTML: 1;
! * Windows text: 2; UNIX text: 3; Macintosh text: 4)
* (optional)
* @return a concatenated string
***************
*** 91,95 ****
* @throws IllegalArgumentException
*/
! String.prototype.cat = function() {
try {
--- 94,98 ----
* @throws IllegalArgumentException
*/
! String.prototype.cat = function(vValue) {
try {
***************
*** 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) {
--- 100,130 ----
var vError = null;
var iNumArguments = arguments.length;
! var iDocType = null;
! if ((iNumArguments < 1) || (iNumArguments > 2)) {
throw vError = new IllegalArgumentException('String.cat', '1 or 2', iNumArguments);
+ } else if (iNumArguments == 2) {
+ iDocType = arguments[1];
}
! var sEolTerminator = '';
! if (iDocType) {
! if ((typeof iDocType != 'number') || (iDocType.toString().indexOf('.') != -1)) {
! throw vError = new TypeMismatchException('String.cat', 'integer', typeof iDocType);
! }
! if ((iDocType != 0) && (iDocType != 1) && (iDocType != 2) && (iDocType != 3) && (iDocType != 4)) {
! throw vError = new IllegalValueException('String.cat', 'iDocType', '0, 1, 2, 3 or 4', iDocType);
! }
! switch (iDocType) {
! case 0 : sEolTerminator = '<BR>'; break;
! case 1 : sEolTerminator = '<br />'; break;
! case 2 : sEolTerminator = '\r\n'; break;
! case 3 : sEolTerminator = '\n'; break;
! case 4 : sEolTerminator = '\r'; break;
! }
}
! var sCatString = this + sEolTerminator + vValue.toString();
}
catch (vError) {
|