private Map<String, String> getCSElementAttributes(ICS ics, String resourceName) {
    final StatementParam param = stmt.newParam();
    param.setString(0, resourceName);

    Map<String, String> rowMap = new HashMap<String, String>();
    IList i = ics.SQL(stmt, param, true);
    if (ics.GetErrno() != -101) {
      i.moveTo(0);
      try {
        rowMap.put("url", i.getValue("url"));
        rowMap.put("resdetails1", i.getValue("resdetails1"));
        rowMap.put("resdetails2", i.getValue("resdetails2"));
      } catch (NoSuchFieldException e) {
        throw new RuntimeException(
            "NoSuchFieldException returned "
                + ics.GetErrno()
                + " and errstr: "
                + " for "
                + stmt.toString());
      }
      ics.ClearErrno();
    } else if (ics.GetErrno() != 0) {
      throw new RuntimeException(
          "ics.SQL returned " + ics.GetErrno() + " and errstr: " + " for " + stmt.toString());
    }
    return rowMap;
  }
Exemplo n.º 2
0
 /**
  * Reads an IList with collumns <tt>assettype</tt> and <tt>assetid</tt> and creates a Collection
  * of AssetId objects.
  *
  * @param result
  * @return Collection of AssetIds, never null.
  */
 public static Collection<AssetId> toAssetIdCollection(IList result) {
   if (result == null || !result.hasData()) return Collections.emptyList();
   final List<AssetId> list = new LinkedList<AssetId>();
   for (IList row : new IterableIListWrapper(result)) {
     AssetId id;
     try {
       id = AssetIdUtils.createAssetId(row.getValue("assettype"), row.getValue("assetid"));
       list.add(id);
     } catch (NoSuchFieldException e) {
       throw new RuntimeException(e.getMessage());
     }
   }
   return list;
 }
Exemplo n.º 3
0
 /**
  * Return a string value for a column. Wraps the possible checked exception NoSuchFieldException
  * with an IllegalArgumentException
  *
  * @param list IList to interrogate
  * @param colname name of column to return
  * @return string value
  * @throws IllegalArgumentException if the column name is not found
  */
 public static String getStringValue(IList list, String colname) {
   try {
     return list.getValue(colname);
   } catch (NoSuchFieldException e) {
     throw new IllegalArgumentException("No such field: " + colname, e);
   }
 }
Exemplo n.º 4
0
 /**
  * Return a long value for a column. Wraps the possible checked exception NoSuchFieldException
  * with an IllegalArgumentException
  *
  * @param list IList to interrogate
  * @param colname name of column to return
  * @return long value
  * @throws IllegalArgumentException if the column name is not found
  * @throws NumberFormatException if the column being queried does not contain a long.
  */
 public static long getLongValue(IList list, String colname) {
   try {
     String s = list.getValue(colname);
     return Long.valueOf(s);
   } catch (NoSuchFieldException e) {
     throw new IllegalArgumentException("No such field: " + colname, e);
   }
 }