Extract a bean from a cursor.
499195
public <V> Function<Cursor, V> cursorToBean(Class<V> api)
  {
    return (FindDataVault<ID,T,V>) _valueBeans.get(api);
  }
942866
def cursor_for_object_in_connection(data, _object):
    '''
    
    '''
    if _object not in data:
        return None

    offset = data.index(_object)
    return offset_to_cursor(offset)
835446
@Override
    @SuppressWarnings("unchecked")
    public <T> T get(Contextual<T> contextual) {
        Bean bean = (Bean) contextual;
        // you can store the bean somewhere
        if (somewhere.containsKey(bean.getName())) {
            return (T) somewhere.get(bean.getName());
        } else {
            return null;
        }
    }
994573
public static void dumpCursor(Cursor cursor, PrintStream stream) {
        stream.println(">>>>> Dumping cursor " + cursor);
        if (cursor != null) {
            int startPos = cursor.getPosition();

            cursor.moveToPosition(-1);
            while (cursor.moveToNext()) {
                dumpCurrentRow(cursor, stream);
            }
            cursor.moveToPosition(startPos);
        }
        stream.println("<<<<<");
    }
119207
private SQLPPMapping extractPPMapping(Optional<SQLPPMapping> ppMapping) throws MappingException, SQLException {

        SQLPPMapping mapping;
	    if (!ppMapping.isPresent()) {
            it.unibz.inf.ontop.spec.mapping.PrefixManager prefixManager = specificationFactory.createPrefixManager(ImmutableMap.of());
            MappingMetadata mappingMetadata = specificationFactory.createMetadata(prefixManager,
					UriTemplateMatcher.create(Stream.empty(), termFactory));
            mapping = ppMappingFactory.createSQLPreProcessedMapping(ImmutableList.of(), mappingMetadata);
        }
        else
            mapping = ppMapping.get();

		currentMappingIndex = mapping.getTripleMaps().size() + 1;
		return bootstrapMappings(mapping);
	}
14456
public static Method getReadMethod(Object bean, String name) {
		return getReadMethods(bean).get(name);
	}
1038723
def restore(self, cursor):
    "  "

    if not isinstance(cursor, Cursor):
      raise TypeError('expected Cursor object', type(cursor))
    self.index, self.lineno, self.colno = cursor
112603
public static Object getBean(String name, Class requiredType) throws BeansException {
		return applicationContext.getBean(name, requiredType);
	}
1183361
def cursor(lcd, row, col):
    
    warnings.warn('The `cursor` context manager is deprecated', DeprecationWarning)
    lcd.cursor_pos = (row, col)
    yield
1015564
@Nullable
  private XTextCursor getCursor(XComponentContext xContext) {
    try {
      XTextDocument curDoc = getCurrentDocument(xContext);
      if (curDoc == null) {
        return null;
      }
      XText xText = curDoc.getText();
      if (xText == null) {
        return null;
      }
      else return xText.createTextCursor();
    } catch (Throwable t) {
      MessageHandler.printException(t);     // all Exceptions thrown by UnoRuntime.queryInterface are caught
      return null;           // Return null as method failed
    }
  }
62545
def select(self, cmd, *args, **kwargs):
        
        self.cursor.execute(cmd, *args, **kwargs)
        return self.cursor.fetchall()
246614
public static void dumpCurrentRow(Cursor cursor, PrintStream stream) {
        String[] cols = cursor.getColumnNames();
        stream.println("" + cursor.getPosition() + " {");
        int length = cols.length;
        for (int i = 0; i< length; i++) {
            String value;
            try {
                value = cursor.getString(i);
            } catch (SQLiteException e) {
                // assume that if the getString threw this exception then the column is not
                // representable by a string, e.g. it is a BLOB.
                value = "<unprintable>";
            }
            stream.println("   " + cols[i] + '=' + value);
        }
        stream.println("}");
    }
821475
@Nullable
  private XTextViewCursor getViewCursor(XComponentContext xContext) {
    try {
      XComponent xCurrentComponent = OfficeTools.getCurrentComponent(xContext);
      if (xCurrentComponent == null) {
        return null;
      }
      XModel xModel = UnoRuntime.queryInterface(XModel.class, xCurrentComponent);
      if (xModel == null) {
        return null;
      }
      XController xController = xModel.getCurrentController();
      if (xController == null) {
        return null;
      }
      XTextViewCursorSupplier xViewCursorSupplier =
          UnoRuntime.queryInterface(XTextViewCursorSupplier.class, xController);
      if (xViewCursorSupplier == null) {
        return null;
      }
      return xViewCursorSupplier.getViewCursor();
    } catch (Throwable t) {
      MessageHandler.printException(t);     // all Exceptions thrown by UnoRuntime.queryInterface are caught
      return null;           // Return null as method failed
    }
  }
97883
@Override
    @SuppressWarnings("unchecked")
    public P get(Bean bean) {
        return (P) getter.get(bean);
    }
54804
def execute_sql(self, sql):
        """"""
        cursor = self.get_cursor()
        cursor.execute(sql)
        return cursor
1017886
private <T> BindingInject<T> findBean(Key<T> key)
  {
    for (InjectProvider provider : _providerList) {
      BindingInject<T> bean = (BindingInject) provider.lookup(key.rawClass());

      if (bean != null) {
        return bean;
      }
    }

    return null;
  }
19777
def find_value_at_cursor(ast_tree, filename, line, col, root_env=gcl.default_env):
  """"""
  q = gcl.SourceQuery(filename, line, col)
  rootpath = ast_tree.find_tokens(q)
  rootpath = path_until(rootpath, is_thunk)

  if len(rootpath) <= 1:
    # Just the file tuple itself, or some non-thunk element at the top level
    return None

  tup = inflate_context_tuple(rootpath, root_env)
  try:
    if isinstance(rootpath[-1], ast.Inherit):
      # Special case handling of 'Inherit' nodes, show the value that's being
      # inherited.
      return tup[rootpath[-1].name]
    return rootpath[-1].eval(tup.env(tup))
  except gcl.EvaluationError as e:
    return e