Get or Create a Number from docID
Return -1 if failed
436353
private int getNumDoc(String docID) {
    if (goneContext != null ) {
      removeDoc(docID);
    }
    for (int i = 0; i < documents.size(); i++) {
      if (documents.get(i).getDocID().equals(docID)) {  //  document exist
        if(!testMode && documents.get(i).getXComponent() == null) {
          XComponent xComponent = OfficeTools.getCurrentComponent(xContext);
          if (xComponent == null) {
            MessageHandler.printToLogFile("Error: Document (ID: " + docID + ") has no XComponent -> Internal space will not be deleted when document disposes");
          } else {
            try {
              xComponent.addEventListener(xEventListener);
            } catch (Throwable t) {
              MessageHandler.printToLogFile("Error: Document (ID: " + docID + ") has no XComponent -> Internal space will not be deleted when document disposes");
              xComponent = null;
            }
            if(xComponent != null) {
              documents.get(i).setXComponent(xContext, xComponent);
              MessageHandler.printToLogFile("Fixed: XComponent set for Document (ID: " + docID + ")");
            }
          }
        }
        return i;
      }
    }
    //  Add new document
    XComponent xComponent = null;
    if (!testMode) {              //  xComponent == null for test cases 
      xComponent = OfficeTools.getCurrentComponent(xContext);
      if (xComponent == null) {
        MessageHandler.printToLogFile("Error: Document (ID: " + docID + ") has no XComponent -> Internal space will not be deleted when document disposes");
      } else {
        try {
          xComponent.addEventListener(xEventListener);
        } catch (Throwable t) {
          MessageHandler.printToLogFile("Error: Document (ID: " + docID + ") has no XComponent -> Internal space will not be deleted when document disposes");
          xComponent = null;
        }
      }
    }
    documents.add(new SingleDocument(xContext, config, docID, xComponent));
    setMenuTextForSwitchOff(xContext);
    if (debugMode) {
      MessageHandler.printToLogFile("Document " + docNum + " created; docID = " + docID);
    }
    return documents.size() - 1;
  }
407306
def _return_value(content, ns):
    
    doc = ElementTree.fromstring(content)
    query = './/{%(ns)s}%(item)s' % {'ns': ns, 'item': 'ReturnValue'}
    rv = doc.find(query)
    return int(rv.text)
1129957
def get_document(self, id):
        
        obj_list = self.document_list
        matches = [i for i in obj_list if str(i.id) == str(id)]
        if not matches:
            raise DoesNotExistError("The resource you've requested does not \
exist or is unavailable without the proper credentials.")
        return matches[0]
1018974
public Integer getNumberOfPositions(String field, int docId) {
    if (fieldReferences.containsKey(field)) {
      IndexDoc doc = getDoc(field, docId);
      if (doc != null) {
        return 1 + doc.maxPosition - doc.minPosition;
      }
    }
    return null;
  }
104992
def _getOLRootNumber(self):
        """"""
        if self.isClosed or self.isEncrypted:
            raise ValueError("operation illegal for closed / encrypted doc")

        return _fitz.Document__getOLRootNumber(self)
161823
def get_number(self, key):
        
        storage = self.storage

        logger.debug("NUMBER before => %s" % storage.get(key, '-'))
        try:
            logger.debug("*** consecutive number lock acquire ***")
            lock.acquire()
            try:
                counter = storage[key]
                storage[key] = counter + 1
            except KeyError:
                storage[key] = 1
        finally:
            logger.debug("*** consecutive number lock release ***")
            self.storage._p_changed = True
            lock.release()

        logger.debug("NUMBER after => %s" % storage.get(key, '-'))
        return storage[key]
76894
def get_param(xmldoc, name):
	
	params = getParamsByName(xmldoc, name)
	if len(params) != 1:
		raise ValueError("document must contain exactly one %s param" % StripParamName(name))
	return params[0]
333068
def _getFileNumber(self, filename):
        
        cur = self._connection.cursor()
        cur.execute('SELECT id FROM files WHERE name = ?', (filename,))
        row = cur.fetchone()
        if row is None:
            return None
        else:
            return row[0]
530681
def get_seq_number_from_id(id, id_template, prefix, **kw):
    
    separator = kw.get("separator", "-")
    postfix = id.replace(prefix, "").strip(separator)
    postfix_segments = postfix.split(separator)
    seq_number = 0
    possible_seq_nums = filter(lambda n: n.isalnum(), postfix_segments)
    if possible_seq_nums:
        seq_number = possible_seq_nums[-1]

    # Check if this id has to be expressed as an alphanumeric number
    seq_number = get_alpha_or_number(seq_number, id_template)
    seq_number = to_int(seq_number)
    return seq_number
22440
def _get_rev_num(self, rev=None):
		
		# first, determine the numeric ID
		cmd = ['identify', '--num']
		# workaround for #4
		cmd.extend(['--config', 'defaults.identify='])
		if rev:
			cmd.extend(['--rev', rev])
		res = self._invoke(*cmd)
		return res.strip()
822588
def get_number(self, num, table=None):
        """"""
        if table is None: table = self.main_table
        self.own_cursor.execute('SELECT * from "%s" LIMIT 1 OFFSET %i;' % (self.main_table, num))
        return self.own_cursor.fetchone()
363156
def get(self, **kwargs):
        
        # get the doc id
        id = None
        if "id" in kwargs:
            id = kwargs["id"]
            del kwargs["id"]
        elif "pk" in kwargs:
            id = kwargs["pk"]
            del kwargs["pk"]
        else:
            raise self.model.DoesNotExist("You must provide an id to find")

        # connect to es and retrieve the document
        es = connections.get_connection("default")

        doc_type = self.model.search_objects.mapping.doc_type
        index = self.model.search_objects.mapping.index
        try:
            doc = es.get(index=index, doc_type=doc_type, id=id, **kwargs)
        except NotFoundError:
            message = "Can't find a document for {}, using id {}".format(
                doc_type, id)
            raise self.model.DoesNotExist(message)

        # parse and return
        return self.from_es(doc)
454767
private int getErrorCode(Object error) {
        if (error instanceof Number) {
            return ((Number) error).intValue();
        } else if (error instanceof YokeException) {
            return ((YokeException) error).getErrorCode().intValue();
        } else if (error instanceof JsonObject) {
            return ((JsonObject) error).getInteger("errorCode", 500);
        } else if (error instanceof Map) {
            Integer tmp = (Integer) ((Map) error).get("errorCode");
            return tmp != null ? tmp : 500;
        } else {
            return 500;
        }
    }
1302346
def get_param(self, number):
        
        logger.debug("retreiving param number %s" % number)
        type_ = snap7.snap7types.param_types[number]
        value = type_()
        code = self.library.Par_GetParam(self.pointer, ctypes.c_int(number),
                                         ctypes.byref(value))
        check_error(code)
        return value.value
1006719
private function getNumberOfDocuments($documentKey)
    {
        $select = $this->solariumClient->createQuery(SolariumClient::QUERY_SELECT);
        $select->setQuery(sprintf('id:%s_*', $documentKey));

        $result = $this->solariumClient->select($select);

        return $result->getNumFound();
    }
52395
function(name, doc, fromMessage, res) {
            var id   = this.toId(doc._id, true);
            if (typeof id === 'undefined' || id === '') {
                return res.send(400, "invalid id.");
            }
            doc._id  = id;
            doc._time = new Date().getTime();

            var collection = new mongodb.Collection(this.db, name);
            collection.insert(
                doc,
                {safe:true},
                function(err, docs) {
                    if(err) {
                        res.send(400, err);
                    } else {
                        var doc = docs && docs.length > 0 ? docs[0] : null;
                        if (doc) {
                            var msg = {
                                method: 'create',
                                id: doc._id,
                                time: doc._time,
                                data: doc
                            };
                            rest.onSuccess(name, msg, fromMessage);
                            res.send(doc);
                        } else {
                            res.send(400, 'failed to create document.');
                        }
                    }
                }
            );
        }
330076
function scanDocuments(docs, id) {
            var i, len;
            len = docs.length;
            if (len === 1) {
                return !docs[0].document.getElementById(id);
            }
            if (len === 2) {
                return !!(docs[0].document.getElementById(id) &&
                          docs[1].document.getElementById(id));
            }
            i = -1;
            for ( ; ++i < len ; ) {
                if (docs[i].document.getElementById(id)) return false;
            }
            return true;
        }