< prev index next >

src/java.desktop/share/classes/javax/swing/text/html/parser/Parser.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -76,16 +76,16 @@
  * @author Sunita Mani
  */
 public
 class Parser implements DTDConstants {
 
-    private char text[] = new char[1024];
+    private char[] text = new char[1024];
     private int textpos = 0;
     private TagElement last;
     private boolean space;
 
-    private char str[] = new char[128];
+    private char[] str = new char[128];
     private int strpos = 0;
 
     /**
      * The dtd.
      */

@@ -271,30 +271,30 @@
     /**
      * Called when PCDATA is encountered.
      *
      * @param text  the section text
      */
-    protected void handleText(char text[]) {
+    protected void handleText(char[] text) {
     }
 
     /**
      * Called when an HTML title tag is encountered.
      *
      * @param text  the title text
      */
-    protected void handleTitle(char text[]) {
+    protected void handleTitle(char[] text) {
         // default behavior is to call handleText. Subclasses
         // can override if necessary.
         handleText(text);
     }
 
     /**
      * Called when an HTML comment is encountered.
      *
      * @param text  the comment being handled
      */
-    protected void handleComment(char text[]) {
+    protected void handleComment(char[] text) {
     }
 
     /**
      * Called when the content terminates without closing the HTML comment.
      */

@@ -384,11 +384,11 @@
         }
         if (space) {
             if (!ignoreSpace) {
                 // enlarge buffer if needed
                 if (textpos + 1 > text.length) {
-                    char newtext[] = new char[text.length + 200];
+                    char[] newtext = new char[text.length + 200];
                     System.arraycopy(text, 0, newtext, 0, text.length);
                     text = newtext;
                 }
 
                 // output pending space

@@ -397,11 +397,11 @@
                     ignoreSpace = true;
                 }
             }
             space = false;
         }
-        char newtext[] = new char[textpos];
+        char[] newtext = new char[textpos];
         System.arraycopy(text, 0, newtext, 0, textpos);
         // Handles cases of bad html where the title tag
         // was getting lost when we did error recovery.
         if (tag.getElement().getName().equals("title")) {
             handleTitle(newtext);

@@ -835,36 +835,36 @@
     /**
      * Add a char to the string buffer.
      */
     void addString(int c) {
         if (strpos  == str.length) {
-            char newstr[] = new char[str.length + 128];
+            char[] newstr = new char[str.length + 128];
             System.arraycopy(str, 0, newstr, 0, str.length);
             str = newstr;
         }
         str[strpos++] = (char)c;
     }
 
     /**
      * Get the string that's been accumulated.
      */
     String getString(int pos) {
-        char newStr[] = new char[strpos - pos];
+        char[] newStr = new char[strpos - pos];
         System.arraycopy(str, pos, newStr, 0, strpos - pos);
         strpos = pos;
         return new String(newStr);
     }
 
     char[] getChars(int pos) {
-        char newStr[] = new char[strpos - pos];
+        char[] newStr = new char[strpos - pos];
         System.arraycopy(str, pos, newStr, 0, strpos - pos);
         strpos = pos;
         return newStr;
     }
 
     char[] getChars(int pos, int endPos) {
-        char newStr[] = new char[endPos - pos];
+        char[] newStr = new char[endPos - pos];
         System.arraycopy(str, pos, newStr, 0, endPos - pos);
         // REMIND: it's not clear whether this version should set strpos or not
         // strpos = pos;
         return newStr;
     }

@@ -1032,22 +1032,22 @@
 
                     case ';':
                         ch = readCh();
                         break;
                 }
-                char data[] = mapNumericReference(n);
+                char[] data = mapNumericReference(n);
                 return data;
             }
             addString('#');
             if (!parseIdentifier(false)) {
                 error("ident.expected");
                 strpos = pos;
-                char data[] = {'&', '#'};
+                char[] data = {'&', '#'};
                 return data;
             }
         } else if (!parseIdentifier(false)) {
-            char data[] = {'&'};
+            char[] data = {'&'};
             return data;
         }
 
         boolean semicolon = false;
 

@@ -1093,11 +1093,11 @@
                 return new char[0];
             }
             /* given that there is not a match restore the entity reference */
             String str = "&" + nm + (semicolon ? ";" : "");
 
-            char b[] = new char[str.length()];
+            char[] b = new char[str.length()];
             str.getChars(0, b.length, b, 0);
             return b;
         }
         return ent.getData();
     }

@@ -1249,13 +1249,13 @@
                     }
                 }
                 break;
 
               case '&':
-                char data[] = parseEntityReference();
+                char[] data = parseEntityReference();
                 if (textpos + data.length > text.length) {
-                    char newtext[] = new char[Math.max(textpos + data.length + 128, text.length * 2)];
+                    char[] newtext = new char[Math.max(textpos + data.length + 128, text.length * 2)];
                     System.arraycopy(text, 0, newtext, 0, text.length);
                     text = newtext;
                 }
                 System.arraycopy(data, 0, text, textpos, data.length);
                 textpos += data.length;

@@ -1283,11 +1283,11 @@
                 break;
             }
 
             // output character
             if (textpos == text.length) {
-                char newtext[] = new char[text.length + 128];
+                char[] newtext = new char[text.length + 128];
                 System.arraycopy(text, 0, newtext, 0, text.length);
                 text = newtext;
             }
             text[textpos++] = (char)c;
         }

@@ -1393,11 +1393,11 @@
                 if (strict && delim < 0) {
                     ch = readCh();
                     break;
                 }
 
-                char data[] = parseEntityReference();
+                char[] data = parseEntityReference();
                 for (int i = 0 ; i < data.length ; i++) {
                     c = data[i];
                     addString((lower && (c >= 'A') && (c <= 'Z')) ? 'a' + c - 'A' : c);
                 }
                 continue;

@@ -1504,11 +1504,11 @@
                                 attvalue = att.getValue();
                             }
                         }
                     }
                 } else {
-                    char str[] = {(char)ch};
+                    char[] str = {(char)ch};
                     error("invalid.tagchar", new String(str), elem.getName());
                     ch = readCh();
                     continue;
                 }
             } else if (!strict && (attributes.isEmpty()) && (ch == '=')) {

@@ -1524,11 +1524,11 @@
                 skipSpace();
                 attvalue = parseAttributeValue(true);
                 error("attvalerr");
                 return;
             } else {
-                char str[] = {(char)ch};
+                char[] str = {(char)ch};
                 error("invalid.tagchar", new String(str), elem.getName());
                 if (!strict) {
                     ch = readCh();
                     continue;
                 } else {

@@ -1672,11 +1672,11 @@
                             }
                             // send over any text you might see
                             // before parsing and sending the
                             // comment
                             if (textpos != 0) {
-                                char newtext[] = new char[textpos];
+                                char[] newtext = new char[textpos];
                                 System.arraycopy(text, 0, newtext, 0, textpos);
                                 handleText(newtext);
                                 lastBlockStartPos = currentBlockStartPos;
                                 textpos = 0;
                             }

@@ -2222,13 +2222,13 @@
                         }
                         if (last.breaksFlow()) {
                             space = false;
                         }
                     }
-                    char data[] = parseEntityReference();
+                    char[] data = parseEntityReference();
                     if (textpos + data.length + 1 > text.length) {
-                        char newtext[] = new char[Math.max(textpos + data.length + 128, text.length * 2)];
+                        char[] newtext = new char[Math.max(textpos + data.length + 128, text.length * 2)];
                         System.arraycopy(text, 0, newtext, 0, text.length);
                         text = newtext;
                     }
                     if (space) {
                         space = false;

@@ -2304,11 +2304,11 @@
                 }
             }
 
             // enlarge buffer if needed
             if (textpos + 2 > text.length) {
-                char newtext[] = new char[text.length + 128];
+                char[] newtext = new char[text.length + 128];
                 System.arraycopy(text, 0, newtext, 0, text.length);
                 text = newtext;
             }
 
             // output pending space

@@ -2410,11 +2410,11 @@
      * NOTE: If the current encoding is bogus, and we read too much
      * (past the content-type) we may suffer a MalformedInputException. For
      * this reason the initial size is 1 and when the body is encountered the
      * size is adjusted to 256.
      */
-    private char buf[] = new char[1];
+    private char[] buf = new char[1];
     private int pos;
     private int len;
     /*
         tracks position relative to the beginning of the
         document.
< prev index next >