static public String toString(StructureData sdata) throws IOException { CharArrayWriter carray = new CharArrayWriter(1000); PrintWriter pw = new PrintWriter(carray); for (StructureMembers.Member m : sdata.getMembers()) { Array memData = sdata.getArray(m); if (memData instanceof ArrayChar) pw.print(((ArrayChar) memData).getString()); else printArray(memData, pw); pw.print(','); } return carray.toString(); }
static public String toString(StructureData sdata) throws IOException { CharArrayWriter carray = new CharArrayWriter(1000); PrintWriter pw = new PrintWriter(carray); for (StructureMembers.Member m : sdata.getMembers()) { Array memData = sdata.getArray(m); if (memData instanceof ArrayChar) pw.print(((ArrayChar) memData).getString()); else printArray(memData, pw); pw.print(','); } return carray.toString(); }
/** * Create a String out of this rank two ArrayChar object. * This treats the ArrayChar as a 1D array of Strings. * If there is a null (0) value in the ArrayChar array, the String will end there. * The null is not returned as part of the String. * * @param index index into 1D String array, must be < getShape(0). * @return String value * @throws IllegalArgumentException if rank != 2 */ public String getString(int index) { Index ima = getIndex(); return getString(ima.set(index)); }
/** * Create a String out of this rank two ArrayChar object. * This treats the ArrayChar as a 1D array of Strings. * If there is a null (0) value in the ArrayChar array, the String will end there. * The null is not returned as part of the String. * * @param index index into 1D String array, must be < getShape(0). * @return String value * @throws IllegalArgumentException if rank != 2 */ public String getString(int index) { Index ima = getIndex(); return getString(ima.set(index)); }
/** * Create a String out of this rank two ArrayChar object. * This treats the ArrayChar as a 1D array of Strings. * If there is a null (0) value in the ArrayChar array, the String will end there. * The null is not returned as part of the String. * * @param index index into 1D String array, must be < getShape(0). * @return String value * @throws IllegalArgumentException if rank != 2 */ public String getString(int index) { Index ima = getIndex(); return getString(ima.set(index)); }
/** * Get the value as a String for a scalar Variable. May also be one-dimensional of length 1. * May also be one-dimensional of type CHAR, which wil be turned into a scalar String. * * @throws IOException if theres an IO Error * @throws UnsupportedOperationException if not a scalar or one-dimensional. * @throws ClassCastException if data type not DataType.STRING or DataType.CHAR. */ public String readScalarString() throws IOException { Array data = getScalarData(); if (dataType == DataType.STRING) return (String) data.getObject(Index.scalarIndexImmutable); else if (dataType == DataType.CHAR) { ArrayChar dataC = (ArrayChar) data; return dataC.getString(); } else throw new IllegalArgumentException("readScalarString not STRING or CHAR " + getFullName()); }
public void testString() { System.out.println("testString: testString"); // read for (i=0; i<m; i++) { ima.set0(i); String val = A.getString( ima); assert( val.equals("aaa")); } }
/** * Get the value as a String for a scalar Variable. May also be one-dimensional of length 1. * May also be one-dimensional of type CHAR, which wil be turned into a scalar String. * * @throws IOException if theres an IO Error * @throws UnsupportedOperationException if not a scalar or one-dimensional. * @throws ClassCastException if data type not DataType.STRING or DataType.CHAR. */ public String readScalarString() throws IOException { Array data = getScalarData(); if (dataType == DataType.STRING) return (String) data.getObject(Index.scalarIndexImmutable); else if (dataType == DataType.CHAR) { ArrayChar dataC = (ArrayChar) data; return dataC.getString(); } else throw new IllegalArgumentException("readScalarString not STRING or CHAR " + getFullName()); }
/** * Get the value as a String for a scalar Variable. May also be one-dimensional of length 1. * May also be one-dimensional of type CHAR, which wil be turned into a scalar String. * * @throws IOException if theres an IO Error * @throws UnsupportedOperationException if not a scalar or one-dimensional. * @throws ClassCastException if data type not DataType.STRING or DataType.CHAR. */ public String readScalarString() throws IOException { Array data = getScalarData(); if (dataType == DataType.STRING) return (String) data.getObject(Index.scalarIndexImmutable); else if (dataType == DataType.CHAR) { ArrayChar dataC = (ArrayChar) data; return dataC.getString(); } else throw new IllegalArgumentException("readScalarString not STRING or CHAR " + getFullName()); }
public String getScalarString(int recnum, StructureMembers.Member m) { if (m.getDataType() == DataType.CHAR) { ArrayChar data = (ArrayChar) m.getDataArray(); return data.getString( recnum); } if (m.getDataType() == DataType.STRING) { ArrayObject data = (ArrayObject) m.getDataArray(); return (String) data.getObject( recnum); } throw new IllegalArgumentException("Type is " + m.getDataType() + ", must be String or char"); }
public String getScalarString(int recnum, StructureMembers.Member m) { if (m.getDataType() == DataType.CHAR) { ArrayChar data = (ArrayChar) m.getDataArray(); return data.getString( recnum); } if (m.getDataType() == DataType.STRING) { ArrayObject data = (ArrayObject) m.getDataArray(); return (String) data.getObject( recnum); } throw new IllegalArgumentException("Type is " + m.getDataType() + ", must be String or char"); }
public String getScalarString(int recnum, StructureMembers.Member m) { if (m.getDataType() == DataType.CHAR) { ArrayChar data = (ArrayChar) m.getDataArray(); return data.getString( recnum); } if (m.getDataType() == DataType.STRING) { ArrayObject data = (ArrayObject) m.getDataArray(); return (String) data.getObject( recnum); } throw new IllegalArgumentException("Type is " + m.getDataType() + ", must be String or char"); }
/** * Get member data of type String or char. * * @param recnum get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize(); * @param m get data from this StructureMembers.Member. Must be of type String or char. * @return scalar String value */ public String getScalarString(int recnum, StructureMembers.Member m) { if (m.getDataType() == DataType.CHAR) { ArrayChar data = (ArrayChar) m.getDataArray(); return data.getString(recnum); } if (m.getDataType() == DataType.STRING) { Array data = m.getDataArray(); return (String) data.getObject(recnum); } throw new IllegalArgumentException("Type is " + m.getDataType() + ", must be String or char"); }
/** * Get member data of type String or char. * * @param recnum get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize(); * @param m get data from this StructureMembers.Member. Must be of type String or char. * @return scalar String value */ public String getScalarString(int recnum, StructureMembers.Member m) { if (m.getDataType() == DataType.CHAR) { ArrayChar data = (ArrayChar) m.getDataArray(); return data.getString(recnum); } if (m.getDataType() == DataType.STRING) { Array data = m.getDataArray(); return (String) data.getObject(recnum); } throw new IllegalArgumentException("Type is " + m.getDataType() + ", must be String or char"); }
/** * Get member data of type String or char. * * @param recnum get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize(); * @param m get data from this StructureMembers.Member. Must be of type String or char. * @return scalar String value */ public String getScalarString(int recnum, StructureMembers.Member m) { if (m.getDataType() == DataType.CHAR) { ArrayChar data = (ArrayChar) m.getDataArray(); return data.getString(recnum); } if (m.getDataType() == DataType.STRING) { Array data = m.getDataArray(); return (String) data.getObject(recnum); } throw new IllegalArgumentException("Type is " + m.getDataType() + ", must be String or char"); }
public String[] getJavaArrayString(int recnum, StructureMembers.Member m) { int n = m.getSize(); String[] result = new String[n]; if (m.getDataType() == DataType.CHAR) { ArrayChar data = (ArrayChar) m.getDataArray(); for (int i=0; i<n; i++) result[i] = data.getString( recnum * n + i); return result; } else if (m.getDataType() == DataType.STRING) { Array data = m.getDataArray(); for (int i=0; i<n; i++) result[i] = (String) data.getObject( recnum * n + i); return result; } throw new IllegalArgumentException("Type is " + m.getDataType() + ", must be String or char"); }
public String[] getJavaArrayString(int recnum, StructureMembers.Member m) { int n = m.getSize(); String[] result = new String[n]; if (m.getDataType() == DataType.CHAR) { ArrayChar data = (ArrayChar) m.getDataArray(); for (int i=0; i<n; i++) result[i] = data.getString( recnum * n + i); return result; } else if (m.getDataType() == DataType.STRING) { Array data = m.getDataArray(); for (int i=0; i<n; i++) result[i] = (String) data.getObject( recnum * n + i); return result; } throw new IllegalArgumentException("Type is " + m.getDataType() + ", must be String or char"); }
public String[] getJavaArrayString(int recnum, StructureMembers.Member m) { int n = m.getSize(); String[] result = new String[n]; if (m.getDataType() == DataType.CHAR) { ArrayChar data = (ArrayChar) m.getDataArray(); for (int i=0; i<n; i++) result[i] = data.getString( recnum * n + i); return result; } else if (m.getDataType() == DataType.STRING) { Array data = m.getDataArray(); for (int i=0; i<n; i++) result[i] = (String) data.getObject( recnum * n + i); return result; } throw new IllegalArgumentException("Type is " + m.getDataType() + ", must be String or char"); }
public void testStringPutGet() { System.out.println("testString: testStringPutGet"); // write ima.set0(0); A.setString(ima, "hey"); ima.set0(1); A.setString(ima, "there"); ima.set0(2); A.setString(ima, "yo"); ima.set0(3); A.setString(ima, "I"); // read ima.set0(0); assert(A.getString(ima).equals("hey")); ima.set0(1); assert(A.getString(ima).equals("the")); ima.set0(2); assert(A.getString(ima).equals("yo")); ima.set0(3); assert(A.getString(ima).equals("I")); }