Ejemplo n.º 1
0
 public List makeRow(String pDataString) {
   ArrayList row;
   if (mFormat != null) {
     // we have a format
     row = new ArrayList(mFormat.getNumFields());
     dbgMsg("makeRow(" + pDataString + "," + mFormat + ")");
     int[] groups = mFormat.getNumFieldsArray();
     dbgMsg(
         "Groups of the format: "
             + StringUtils.collectionToString(ConversionUtils.asList(groups), " "));
     dbgMsg("Row(" + pDataString + "," + mFormat + ")");
     String[] tokens = StringUtils.split(pDataString, columnSeparatorRegex, groups);
     dbgMsg("Tokens: " + StringUtils.arrayToString(tokens, "\n"));
     for (int i = 0; i < tokens.length; i++) {
       row.add(mFormat.makeFieldRep(i, tokens[i]));
     }
   } else {
     // we do not have a format
     String[] tokens = pDataString.split(columnSeparatorRegex);
     // note: -1 indicates that the number of fields is not fixed!
     if (mNumFields != -1 && tokens.length != mNumFields) {
       throw new RuntimeException(
           "Cannot make row: numFieds = " + mNumFields + " != numTokens = " + tokens.length);
     } else {
       row = new ArrayList(Arrays.asList(tokens));
     }
   }
   return row;
 }
Ejemplo n.º 2
0
 /** No enforced row format */
 public ArrayListRowFactory(RowFormat pFormat) {
   mNumFields = pFormat.getNumFields();
   mFormat = pFormat;
 }