[ http://issues.apache.org/jira/browse/WSCOMMONS-123?page=all ]
Bernhard Roider updated WSCOMMONS-123:
--------------------------------------
Attachment: OMTextImpl_diff.txt
Base64_diff.txt
Hi Eran,
sorry but i meant that you want the hole patched files.
-- Bernhard
> Improvements for OMTextImpl Methods getText(..) and getTextAsQName(..)
> ----------------------------------------------------------------------
>
> Key: WSCOMMONS-123
> URL: http://issues.apache.org/jira/browse/WSCOMMONS-123
> Project: WS-Commons
> Issue Type: Improvement
> Components: AXIOM
> Environment: all
> Reporter: Bernhard Roider
> Priority: Minor
> Attachments: Base64.java, Base64_diff.txt, OMTextImpl.java,
> OMTextImpl_diff.txt
>
>
> The following impovements should result in less memory usage and more speed.
> //File OMTextImpl
> // create a new private Methode
> private String getTextFromInputStream() throws Exception {
> InputStream inStream = this.getInputStream();
>
> if (inStream.available() <= 0) {
> return EMPTY_STRING;
> }
>
> StringBuffer text = new StringBuffer();
> byte[] data = new byte[1023];
>
> do {
> int len;
> while ((len = inStream.read(data)) > 0) {
> Base64.encode(data, 0, len, text);
> }
> } while (inStream.available() > 0);
> return text.toString();
> }
> // modify methods getText(..) and getTextAsQName(..)
> // modified method
> public QName getTextAsQName() throws OMException {
> if (textNS != null) {
> String prefix = textNS.getPrefix();
> String name = textNS.getNamespaceURI();
> if (prefix == null || "".equals(prefix)) {
> return new QName(name, getTextFromProperPlace());
> } else {
> return new QName(textNS.getNamespaceURI(),
> getTextFromProperPlace(), prefix);
> }
> } else if (this.value != null || charArray != null) {
> return new QName(getTextFromProperPlace());
> } else {
> try {
> return new QName(getTextFromInputStream());
> } catch (Exception e) {
> throw new OMException(e);
> }
> }
> }
> // modified method
> public String getText() throws OMException {
> if (textNS != null) {
> return getTextString();
> } else if (charArray != null || this.value != null) {
> return getTextFromProperPlace();
> } else {
> try {
> return getTextFromInputStream();
> } catch (Exception e) {
> throw new OMException(e);
> }
> }
> }
> // create new static method in org.apache.axiom.om.util.Base64
> public static void encode(byte[] data, int off, int len, StringBuffer buffer)
> {
> if (len <= 0) {
> return;
> }
>
> char[] out = new char[4];
> int rindex = off;
> int rest = len - off;
> while (rest >= 3) {
> int i = ((data[rindex] & 0xff) << 16)
> + ((data[rindex + 1] & 0xff) << 8)
> + (data[rindex + 2] & 0xff);
> out[0] = S_BASE64CHAR[i >> 18];
> out[1] = S_BASE64CHAR[(i >> 12) & 0x3f];
> out[2] = S_BASE64CHAR[(i >> 6) & 0x3f];
> out[3] = S_BASE64CHAR[i & 0x3f];
> buffer.append(out);
> rindex += 3;
> rest -= 3;
> }
> if (rest == 1) {
> int i = data[rindex] & 0xff;
> out[0] = S_BASE64CHAR[i >> 2];
> out[1] = S_BASE64CHAR[(i << 4) & 0x3f];
> out[2] = S_BASE64PAD;
> out[3] = S_BASE64PAD;
> buffer.append(out);
> } else if (rest == 2) {
> int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
> out[0] = S_BASE64CHAR[i >> 10];
> out[1] = S_BASE64CHAR[(i >> 4) & 0x3f];
> out[2] = S_BASE64CHAR[(i << 2) & 0x3f];
> out[3] = S_BASE64PAD;
> buffer.append(out);
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]