[cvs]
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc
HTMLUtil.java
JCorporate Ltd
jcorp at jcorp2.servlets.net
Tue Jun 22 18:17:05 PDT 2004
Update of /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc
In directory jcorp2.servlets.net:/tmp/cvs-serv22608/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc
Modified Files:
HTMLUtil.java
Log Message:
prevent instantiation of solitaire; initialize RAM array only upon usage
Index: HTMLUtil.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/HTMLUtil.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** HTMLUtil.java 3 Jun 2003 06:12:15 -0000 1.2
--- HTMLUtil.java 23 Jun 2004 01:17:02 -0000 1.3
***************
*** 3,25 ****
import java.util.Arrays;
-
/**
- */
-
- /*
- * HtmlUtil.java
- *
* Copyright 1999, 2002, 2002 Yves Henri AMAIZO.
* amy_amaizo at compuserve.com
- */
-
- /**
* This class convert a text in an HTML text format with symbolic code (&xxxx;),
* it also convert a given HTML text format which contain symbolic code to text.
*
- * @version $Revision$ $Date$
* @author Yves Henri AMAIZO
*/
public class HTMLUtil {
/**
* Method text2html: Convert a text to an HTML format.
--- 3,21 ----
import java.util.Arrays;
/**
* Copyright 1999, 2002, 2002 Yves Henri AMAIZO.
* amy_amaizo at compuserve.com
* This class convert a text in an HTML text format with symbolic code (&xxxx;),
* it also convert a given HTML text format which contain symbolic code to text.
*
* @author Yves Henri AMAIZO
*/
public class HTMLUtil {
+
+ /**
+ * prevent instantiation
+ */
+ private HTMLUtil() {};
+
/**
* Method text2html: Convert a text to an HTML format.
***************
*** 59,62 ****
--- 55,59 ----
return text;
StringBuffer t = new StringBuffer(text.length());
+ initSortedArray();
for (int i = 0; i < text.length(); i++) {
char c = text.charAt(i);
***************
*** 72,75 ****
--- 69,73 ----
code += text.charAt(i);
} while (text.charAt(i) != ';');
+
int index = Arrays.binarySearch(sortedSymbolicCode,
new NumericSymbolicCode(code, 0));
***************
*** 88,91 ****
--- 86,103 ----
/**
+ * Initialization and sorting of the 'sortedSymbolicCode'
+ */
+ private static void initSortedArray() {
+ if ( sortedSymbolicCode == null ) {
+ sortedSymbolicCode = new NumericSymbolicCode[symbolicCode.length];
+
+ for (int i = 0; i < symbolicCode.length; i++) {
+ sortedSymbolicCode[i] = new NumericSymbolicCode(symbolicCode[i], i);
+ }
+ Arrays.sort(sortedSymbolicCode);
+ }
+ }
+
+ /**
* Array of symbolic code order by numeric code ! <br>
* The symbolic codes and their position correspond to the ISO 8859-1 set
***************
*** 246,251 ****
* This array is the reciprocal from the 'symbolicCode' array.
*/
! private static NumericSymbolicCode[] sortedSymbolicCode =
! new NumericSymbolicCode[symbolicCode.length];
/**
--- 258,262 ----
* This array is the reciprocal from the 'symbolicCode' array.
*/
! private static NumericSymbolicCode[] sortedSymbolicCode = null;
/**
***************
*** 280,291 ****
}
- /**
- * Initialization and sorting of the 'sortedSymbolicCode'
- */
- static {
- for (int i = 0; i < symbolicCode.length; i++) {
- sortedSymbolicCode[i] = new NumericSymbolicCode(symbolicCode[i], i);
- }
- Arrays.sort(sortedSymbolicCode);
- }
}
--- 291,293 ----
More information about the cvs
mailing list