You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/02/16 07:29:45 UTC
svn commit: r508318 -
/incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/DataObjectXMLStreamReader.java
Author: rfeng
Date: Thu Feb 15 22:29:44 2007
New Revision: 508318
URL: http://svn.apache.org/viewvc?view=rev&rev=508318
Log:
Fix the getTextLength()
Modified:
incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/DataObjectXMLStreamReader.java
Modified: incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/DataObjectXMLStreamReader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/DataObjectXMLStreamReader.java?view=diff&rev=508318&r1=508317&r2=508318
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/DataObjectXMLStreamReader.java (original)
+++ incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/DataObjectXMLStreamReader.java Thu Feb 15 22:29:44 2007
@@ -680,19 +680,33 @@
if (state == DELEGATED_STATE) {
return childReader.getTextCharacters();
} else if (state == TEXT_STATE) {
- return properties[currentPropertyIndex - 1].getValue() == null ? new char[0] : ((String) properties[currentPropertyIndex - 1].getValue())
- .toCharArray();
+ return getTextData();
} else {
throw new IllegalStateException();
}
}
+ private char[] getTextData() {
+ return properties[currentPropertyIndex - 1].getValue() == null ? new char[0] : ((String) properties[currentPropertyIndex - 1].getValue())
+ .toCharArray();
+ }
+
+ private int copy(int sourceStart, char[] target, int targetStart, int length) {
+ char[] source = getTextData();
+ if (sourceStart > source.length)
+ throw new IndexOutOfBoundsException("source start > source length");
+ int sourceLen = source.length - sourceStart;
+ if (length > sourceLen)
+ length = sourceLen;
+ System.arraycopy(source, sourceStart, target, targetStart, length);
+ return sourceLen;
+ }
+
public int getTextCharacters(int i, char[] chars, int i1, int i2) throws XMLStreamException {
if (state == DELEGATED_STATE) {
return childReader.getTextCharacters(i, chars, i1, i2);
} else if (state == TEXT_STATE) {
- // todo - implement this
- return 0;
+ return copy(i, chars, i1, i2);
} else {
throw new IllegalStateException();
}
@@ -712,7 +726,7 @@
if (state == DELEGATED_STATE) {
return childReader.getTextLength();
} else if (state == TEXT_STATE) {
- return 0;// assume text always starts at 0
+ return getTextData().length;
} else {
throw new IllegalStateException();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org