Revision: 3750
http://vexi.svn.sourceforge.net/vexi/?rev=3750&view=rev
Author: mkpg2
Date: 2009-11-09 02:01:22 +0000 (Mon, 09 Nov 2009)
Log Message:
-----------
Cleanup. Rely on inlining.
Modified Paths:
--------------
trunk/core/org.ibex.util/src/org/ibex/util/XML.java
Modified: trunk/core/org.ibex.util/src/org/ibex/util/XML.java
===================================================================
--- trunk/core/org.ibex.util/src/org/ibex/util/XML.java 2009-11-09 01:35:53 UTC
(rev 3749)
+++ trunk/core/org.ibex.util/src/org/ibex/util/XML.java 2009-11-09 02:01:22 UTC
(rev 3750)
@@ -206,6 +206,18 @@
e.clear(); synchronized (elements) { elements.add(e); }
}
+ private void incCol(){
+ col++; off++; len--;
+ }
+
+ private void incCol(int n){
+ col+=n; off+=n; len-=n;
+ }
+ // For entities. Inc col by one, but others by the length of the entity in
the txt.
+ private void incColEnt(int n){
+ off+=n; len-=n;
+ col++;
+ }
/** Reads in a tag. Expects <tt>buf[off] == '<'</tt>. */
private void readTag() throws IOException, Exn {
@@ -222,24 +234,24 @@
int namelen = 0;
- col++; off++; len--;
+ incCol();
if (!buffer(1)) throw new EOFException("Unexpected EOF processing
element tag");
// work out what we can from the beginning of the tag
char s = buf[off];
if (s == '!') {
// definitions here don't necessarily conform to xml spec (as DTDs
not yet implemented)
- col++; off++; len--;
+ incCol();
if (!buffer(4)) throw new EOFException("Unexpected EOF processing
<! element");
boolean bad = false;
switch (buf[off]) {
case '-':
if (buf[off+1] != '-') { bad = true; break; }
- col += 2; off += 2; len -= 2;
+ incCol(2);
// Comment '<!--' ((Char - '-') | ('-' (Char -
'-')))* '-->'
readChars(false, "-->", false);
- col += 3; off += 3; len -= 3;
+ incCol(3);
break;
// we don't care about the following definitions
@@ -250,11 +262,11 @@
|| buf[off+4] != 'I' || buf[off+5] != 'S' ||
buf[off+6] != 'T') {
bad = true; break;
}
- col += 7; off += 7; len -= 7;
+ incCol(7);
// ATTLIST '<!ATTLIST' (Char* - '>') '>'
readChars(false, ">", true);
- col++; off++; len--;
+ incCol();
break;
case 'D':
if (!buffer(7)
@@ -262,11 +274,11 @@
|| buf[off+4] != 'Y' || buf[off+5] != 'P' ||
buf[off+6] != 'E') {
bad = true; break;
}
- col += 7; off += 7; len -= 7;
+ incCol(7);
// DTD '<!DOCTYPE' (Char* - '>') '>'
- readChars(false, ">", true);
- col++; off++; len--;
+ readChars(false, ">", true);
+ incCol(1);
break;
case 'E':
if (!buffer(7)) {
@@ -274,15 +286,14 @@
} else if (buf[off+1] == 'L' && buf[off+2] == 'E' &&
buf[off+3] == 'M'
&& buf[off+4] == 'E' && buf[off+5] == 'N' &&
buf[off+6] == 'T') {
// ELEMENT '<!ELEMENT' (Char* - '>') '>'
- readChars(false, ">", true);
- col++; off++; len--;
+ readChars(false, ">", true);
+ incCol();
} else if (buf[off+1] == 'N' && buf[off+2] == 'T' &&
buf[off+3] == 'I'
&& buf[off+4] == 'T' && buf[off+5] == 'Y') {
// ENTITY '<!ENTITY' (Char* - '>') '>'
readChars(false, ">", true);
- col++; off++; len--;
-
+ incCol();
} else {
bad = true;
}
@@ -294,11 +305,10 @@
|| buf[off+5] != 'I' || buf[off+6] != 'O' ||
buf[off+7] != 'N') {
bad = true; break;
}
- col += 8; off += 8; len -= 8;
+ incCol(8);
// NOTATION '<!NOTATION' (Char* - '>') '>'
readChars(false, ">", true);
- col++; off++; len--;
-
+ incCol();
break;
case '[':
if (!buffer(7)
@@ -308,11 +318,11 @@
// Conditional '<![' (Char* - (Char* ']]>' Char*))
']]>'
readChars(false, "]]>", false);
} else {
- col += 7; off += 7; len -=7;
+ incCol(7);
// CDATA '<![CDATA[' (Char* - (Char* ']]>'
Char*)) ']]>'
readChars(true, "]]>", false);
}
- col += 3; off += 3; len -= 3;
+ incCol(3);
break;
default: bad = true;
}
@@ -321,31 +331,31 @@
} else if (s == '?') {
// PI (Ignored) '<?' (Char* - (Char* '?>' Char*)) '?>'
- col++; off++; len--;
+ incCol();
readChars(false, "?>", true);
if (!buffer(2)) throw new EOFException("Unexpected EOF at end of
Processing Instruction");
- col += 2; off += 2; len -= 2;
+ incCol(2);
} /*else if (s == '[') {
if (!buffer(7)
|| buf[off+1] != 'C' || buf[off+2] != 'D' || buf[off+3] !=
'A'
|| buf[off+4] != 'T' || buf[off+5] != 'A' || buf[off+6] !=
'[') {
- col++; off--; len++;
+ incCol();
// Conditional '<![' (Char* - (Char* ']]>' Char*)) ']]>'
readChars(false, "]]>", false);
} else {
- col += 7; off += 7; len -=7;
+ incCol(7);
// CDATA '<![CDATA[' (Char* - (Char* ']]>' Char*))
']]>'
readChars(true, "]]>", false);
}
- col += 3; off += 3; len -= 3;
+ incCol(3);
} */else {
if (s == '/') {
// End Tag '</' Name S? '>'
starttag = false;
endtag = true;
- col++; off++; len--;
+ incCol();
if (!buffer(1)) throw new EOFException("Unexpected EOF
processing end tag");
s = buf[off];
}
@@ -377,7 +387,7 @@
// we have marked out the name region, so turn it into a string
and move on
String qName = new String(buf, off, namelen);
- col += namelen; off += namelen; len -= namelen;
+ incCol(namelen);
if (starttag) {
// create the in-memory element representation of this beast
@@ -427,11 +437,11 @@
if (!buffer(1)) throw new EOFException("Unexpected EOF before end
of tag");
if (buf[off] == '/') {
endtag = true;
- off++; len--; col++;
+ incCol();
}
if (!buffer(1)) throw new EOFException("Unexpected EOF before end
of endtag");
if (buf[off] == '>') {
- off++; len--; col++;
+ incCol();
} else {
throw new Exn("missing '>' character from element
'"+qName+"'", Exn.MARKUP, getLine(), getCol());
}
@@ -475,17 +485,17 @@
// determine prefix and key name
if (prefix > 0) {
p = new String(buf, off, prefix-1);
- col += prefix; off += prefix; len -= prefix; ref -= prefix;
+ incCol(prefix); ref -= prefix;
}
n = new String(buf, off, ref);
- col += ref; off += ref; len -= ref;
+ incCol(ref);
// find name/value divider ('=')
readWhitespace();
if (!buffer(1)) throw new EOFException("Unexpected EOF before
attribute '=' divider");
if (buf[off] != '=') throw new Exn("attribute name not followed by '='
sign", Exn.MARKUP, getLine(), getCol());
- col++; off++; len--;
+ incCol();
readWhitespace();
if (!buffer(1)) throw new EOFException("Unexpected EOF after attribute
'=' divider");
@@ -496,7 +506,7 @@
} else {
throw new Exn("attribute '"+n+"' must have attribute wrapped in '
or \"", Exn.MARKUP, getLine(), getCol());
}
- col++; off++; len--;
+ incCol();
StringBuffer sb = new StringBuffer();
// find the attribute value
@@ -518,10 +528,10 @@
}
v = sb.toString();
- col += ref; off += ref; len -= ref;
+ incCol(ref);
// remove end wrapper character
- col++; off++; len--;
+ incCol();
// process attribute
if (p != null && p.equals("xmlns")) {
@@ -569,7 +579,7 @@
int d = Character.digit(buf[off], radix);
if (d == -1) {
if (buf[off] != ';') throw new Exn("illegal characters
in entity reference", Exn.WFC, getLine(), getCol());
- off++; len--; col++;
+ incCol();
break findchar;
}
c = (c * radix) + d;
@@ -581,31 +591,31 @@
return singlechar;
case 'a':
if (buffer(4) && buf[off+1] == 'm' && buf[off+2] == 'p' &&
buf[off+3] == ';') {
- off += 4; len -= 4; col++;
+ incColEnt(4);
return single_amp;
} else if (buffer(5) && buf[off+1] == 'p' && buf[off+2] == 'o'
&& buf[off+3] == 's' && buf[off+4] == ';') {
- off += 5; len -= 5; col++;
+ incColEnt(5);
return single_apos;
}
break;
case 'g':
if (buffer(3) && buf[off+1] == 't' && buf[off+2] == ';') {
- off += 3; len -= 3; col++;
+ incColEnt(3);
return single_gt; // >
}
break;
case 'l':
if (buffer(3) && buf[off+1] == 't' && buf[off+2] == ';') {
- off += 3; len -= 3; col++;
+ incColEnt(3);
return single_lt; // <
}
break;
case 'q':
if (buffer(5) && buf[off+1] == 'u' && buf[off+2] == 'o' &&
buf[off+3] == 't' && buf[off+4] == ';') {
- off += 5; len -= 5; col++;
+ incColEnt(5);
return single_quot; // "
}
break;
@@ -666,7 +676,7 @@
}
if (p && ref > 0) characters(buf, off, ref);
- off += ref; len -= ref; col += ref;
+ incCol(ref);
}
if(!p) skippedlines(line - startline);
@@ -740,7 +750,7 @@
if (ref > 0) {
if (p) characters(buf, off, ref);
- off += ref; len -= ref; col += ref;
+ incCol(ref);
}
if (readWhite) {
@@ -789,7 +799,7 @@
if (ref > 0) {
whitespace(buf, off, ref);
- off += ref; len -= ref; col += ref;
+ incCol(ref);
}
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn