1 /*
2 * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
345 str = Double.toString(doubleValue());
346 } else {
347 str = "<unknown scalar value>";
348 }
349 } else { // vector
350 if (dataType == BasicType.getTBoolean()) {
351 boolean[] res = booleanArrayValue();
352 StringBuffer buf = new StringBuffer();
353 buf.append('[');
354 for (int i = 0; i < res.length; i++) {
355 buf.append(Boolean.toString(res[i]));
356 buf.append(", ");
357 }
358 buf.append(']');
359 str = buf.toString();
360 } else if (dataType == BasicType.getTChar()) {
361 // char[] is returned as a String
362 str = new String(charArrayValue());
363 } else if (dataType == BasicType.getTByte()) {
364 // byte[] is returned as a String
365 try {
366 str = new String(byteArrayValue(), "US-ASCII");
367 } catch (java.io.UnsupportedEncodingException e) {
368 str = "can't decode string : " + e.getMessage();
369 }
370 } else if (dataType == BasicType.getTShort()) {
371 short[] res = shortArrayValue();
372 StringBuffer buf = new StringBuffer();
373 buf.append('[');
374 for (int i = 0; i < res.length; i++) {
375 buf.append(Short.toString(res[i]));
376 buf.append(", ");
377 }
378 buf.append(']');
379 str = buf.toString();
380 } else if (dataType == BasicType.getTInt()) {
381 int[] res = intArrayValue();
382 StringBuffer buf = new StringBuffer();
383 buf.append('[');
384 for (int i = 0; i < res.length; i++) {
385 buf.append(Integer.toString(res[i]));
386 buf.append(", ");
387 }
388 buf.append(']');
389 str = buf.toString();
|
1 /*
2 * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
345 str = Double.toString(doubleValue());
346 } else {
347 str = "<unknown scalar value>";
348 }
349 } else { // vector
350 if (dataType == BasicType.getTBoolean()) {
351 boolean[] res = booleanArrayValue();
352 StringBuffer buf = new StringBuffer();
353 buf.append('[');
354 for (int i = 0; i < res.length; i++) {
355 buf.append(Boolean.toString(res[i]));
356 buf.append(", ");
357 }
358 buf.append(']');
359 str = buf.toString();
360 } else if (dataType == BasicType.getTChar()) {
361 // char[] is returned as a String
362 str = new String(charArrayValue());
363 } else if (dataType == BasicType.getTByte()) {
364 // byte[] is returned as a String
365 str = CStringUtilities.getString(addr.addOffsetTo(dataOffset()));
366 } else if (dataType == BasicType.getTShort()) {
367 short[] res = shortArrayValue();
368 StringBuffer buf = new StringBuffer();
369 buf.append('[');
370 for (int i = 0; i < res.length; i++) {
371 buf.append(Short.toString(res[i]));
372 buf.append(", ");
373 }
374 buf.append(']');
375 str = buf.toString();
376 } else if (dataType == BasicType.getTInt()) {
377 int[] res = intArrayValue();
378 StringBuffer buf = new StringBuffer();
379 buf.append('[');
380 for (int i = 0; i < res.length; i++) {
381 buf.append(Integer.toString(res[i]));
382 buf.append(", ");
383 }
384 buf.append(']');
385 str = buf.toString();
|