cdm/src/main/java/ucar/ma2/ArrayChar.java
public void setString(Index ima, String val) {
    int rank = getRank();
    if (rank == 0)
      throw new IllegalArgumentException("ArrayChar.setString rank must not be 0");
    int arrayLen = indexCalc.getShape(rank - 1);
    int strLen = Math.min(val.length(), arrayLen);

    int count = 0;
    for (int k = 0; k < strLen; k++) {
      ima.setDim(rank - 1, k);
      setChar(ima, val.charAt(k));
      count++;
    }
    char c = 0;
    for (int k = count; k < arrayLen; k++) {
      ima.setDim(rank - 1, k);
      setChar(ima, c);
    }
  }
public void setString(Index ima, String val) {
    int rank = getRank();
    if (rank == 0)
      throw new IllegalArgumentException("ArrayChar.setString rank must not be 0");
    int arrayLen = indexCalc.getShape(rank - 1);
    int strLen = Math.min(val.length(), arrayLen);

    int count = 0;
    for (int k = 0; k < strLen; k++) {
      ima.setDim(rank - 1, k);
      setChar(ima, val.charAt(k));
      count++;
    }
    char c = 0;
    for (int k = count; k < arrayLen; k++) {
      ima.setDim(rank - 1, k);
      setChar(ima, c);
    }
  }
public void setString ( Index ima , String val ) { int rank = getRank ( ) ; if ( rank == 0 ) throw new IllegalArgumentException ( "ArrayChar.setString rank must not be 0" ) ; int arrayLen = indexCalc . getShape ( rank - 1 ) ; int strLen = Math . min ( val . length ( ) , arrayLen ) ; int count = 0 ; for ( int k = 0 ; k < strLen ; k ++ ) { ima . setDim ( rank - 1 , k ) ; setChar ( ima , val . charAt ( k ) ) ; count ++ ; } char c = 0 ; for ( int k = count ; k < arrayLen ; k ++ ) { ima . setDim ( rank - 1 , k ) ; setChar ( ima , c ) ; } }
Set the ArrayChar values from the characters in the String. Rank must be 1 or greater.
If String longer than ArrayChar, ignore extra chars; if shorter, fill with 0.
If rank 1, set entire ArrayChar, ignoring ima.
If rank > 1, treat the ArrayChar like an array of Strings of rank-1, and set the
row indexed by ima. For example, rank 3:
<p><code>
String[][] val;
ArrayChar ca;
Index ima = ca.getIndex();
int rank0 = ca.getShape()[0];
int rank1 = ca.getShape()[1];
<p/>
for (int i=0; i<rank0; i++)
for (int j=0; j<rank1; j++) {
ima.set(i,j);
ca.setString(ima, val[i][j]);
}
</code>

@param ima the Index of where in the Array to start.
@param val set to this value
Set the ArrayChar values from the characters in the String . Rank must be 1 or greater . If String longer than ArrayChar ignore extra chars ; if shorter fill with 0 . If rank 1 set entire ArrayChar ignoring ima . If rank > 1 treat the ArrayChar like an array of Strings of rank - 1 and set the row indexed by ima . For example rank 3 : <p > <code > String [] [] val ; ArrayChar ca ; Index ima = ca . getIndex () ; int rank0 = ca . getShape () [ 0 ] ; int rank1 = ca . getShape () [ 1 ] ; <p / > for ( int i = 0 ; i<rank0 ; i ++ ) for ( int j = 0 ; j<rank1 ; j ++ ) { ima . set ( i j ) ; ca . setString ( ima val [ i ] [ j ] ) ; } < / code >