You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by er...@locus.apache.org on 2000/09/26 01:27:42 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/framework XMLString.java
ericye 00/09/25 16:27:40
Modified: java/src/org/apache/xerces/framework Tag: xerces_j_2
XMLString.java
Log:
flesh out the methods.
Revision Changes Path
No revision
No revision
1.1.2.6 +40 -4 xml-xerces/java/src/org/apache/xerces/framework/Attic/XMLString.java
Index: XMLString.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/framework/Attic/XMLString.java,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- XMLString.java 2000/09/11 21:56:13 1.1.2.5
+++ XMLString.java 2000/09/25 23:27:37 1.1.2.6
@@ -59,7 +59,8 @@
/**
* @author Stubs generated by DesignDoc on Mon Sep 11 11:10:57 PDT 2000
- * @version $Id: XMLString.java,v 1.1.2.5 2000/09/11 21:56:13 andyc Exp $
+ * @author Eric Ye
+ * @version $Id: XMLString.java,v 1.1.2.6 2000/09/25 23:27:37 ericye Exp $
*/
public class XMLString {
@@ -94,6 +95,7 @@
* @param length
*/
public XMLString(char[] ch, int offset, int length) {
+ setValues(ch, offset, length);
}
//
@@ -108,12 +110,18 @@
* @param length
*/
public void setValues(char[] ch, int offset, int length) {
+ this.ch = ch;
+ this.offset = offset;
+ this.length = offset;
} // setValues
/**
* clear
*/
public void clear() {
+ this.ch = null;
+ this.offset = -1;
+ this.length = 0;
} // clear
/**
@@ -126,7 +134,19 @@
* @return
*/
public boolean equals(char[] ch, int offset, int length) {
- return false;
+ if (ch == null) {
+ return false;
+ }
+ if (this.length != length) {
+ return false;
+ }
+
+ for (int i=0; i<length; i++) {
+ if (this.ch[this.offset+i] != ch[offset+i] ) {
+ return false;
+ }
+ }
+ return true;
} // equals
/**
@@ -137,7 +157,23 @@
* @return
*/
public boolean equals(String s) {
- return false;
+ if (s == null) {
+ return false;
+ }
+ if ( length != s.length() ) {
+ return false;
+ }
+
+ // is this faster than call s.toCharArray first and compare the
+ // two arrays directly, which will possibly involve creating a
+ // new char array object.
+ for (int i=0; i<length; i++) {
+ if (ch[offset+i] != s.charAt(i)) {
+ return false;
+ }
+ }
+
+ return true;
} // equals
/**
@@ -146,7 +182,7 @@
* @return
*/
public String toString() {
- return null;
+ return new String(ch, offset, length);
} // toString
} // class XMLString