Internalizes a <code>Document</code>. The registered database
listeners will <b>not</b> be notified during this method.
@param document the document to internalize
182317
private void internalizeDocument(Document document) throws ParseException {
    init();

    // temporarily remove the database listeners
    List<IDatabaseListener> tmpListeners = new ArrayList<>(listeners);
    listeners.clear();

    Hashtable<String, String> keyMap = new Hashtable<>();

    try {
      Element rootElement = document.getRootElement();
      List<Attribute> rootAttrs = rootElement.getAttributes();

      // extract the master language and put all other root element
      // attributes aside
      for (Attribute attribute : rootAttrs) {
        if (MASTER_LANGUAGE_ATTRIBUTE_NAME.equals(attribute.getName())) {
          masterLanguage = attribute.getValue();
        } else {
          additionalRootAttrs.add(attribute);
        }
      }

      // store additional namespaces. the xsi namespace is used for the attribute xsi:noSchemaNamespaceLocation
      for (Object namespace : rootElement.getAdditionalNamespaces()) {
        // The list is not type save, therefore a cast is done
        if (namespace instanceof Namespace) {
          additionalNamespaces.add((Namespace) namespace);
        } else {
          throw new RuntimeException("Namespace List contains Objects that are not of type Namespace");
        }
      }

      if (masterLanguage == null) {
        // since we cannot determine the line numbers in this methods
        // we pass 0 to occuring ParseExceptions
        throw new ParseException("Master language missing.", 0);
      }

      List<Element> textList = rootElement.getChildren(TEXT_ELEMENT_NAME);

      // the validation in here is kind of unnecessary when the xsd is used for validation.
      // however the xsd validation was added later and it cant hurt to doublecheck some things, there might be cases
      // where the xsd cannot be used
      for (Element textElement : textList) {
        String key = textElement.getAttributeValue(KEY_ATTRIBUTE_NAME);
        if (key == null) {
          throw new ParseException("No key found for text.",
              ((LineNumberElement) textElement).getStartLine());
        }

        if (keyMap.containsKey(key)) {
          parseWarnings.add(new ParseWarning("Duplicate key: " + key,
              ((LineNumberElement) textElement).getStartLine()));
        } else {
          keyMap.put(key, "");
        }

        String context = textElement.getChildText(CONTEXT_ELEMENT_NAME);
        if (context == null) {
          throw new ParseException("No context found for key \"" + key + "\".",
              ((LineNumberElement) textElement).getStartLine());
        }

        ITextNode textNode = new XMLTextNode(key, context);
        addTextNode(textNode);

        List<Element> valueList = textElement.getChildren(VALUE_ELEMENT_NAME);
        for (Element valueElement : valueList) {
          String language = valueElement.getAttributeValue(LANGUAGE_ATTRIBUTE_NAME);
          if (language == null) {
            throw new ParseException("No language found for value of key \"" + key + "\".",
                ((LineNumberElement) valueElement).getStartLine());
          }
          String statusName = valueElement.getAttributeValue(STATUS_ATTRIBUTE_NAME);
          Status status = Status.valueOf(statusName);
          if (status == null) {
            throw new ParseException("Invalid status for key \"" + key + "\": " + statusName,
                ((LineNumberElement) valueElement).getStartLine());
          }
          String value = valueElement.getText();
          textNode.addValueNode(new XMLValueNode(language, status, value));
        }
      }
    } finally {
      listeners.addAll(tmpListeners);
    }
  }
905580
private function invalidateDocumentStructure($document)
    {
        if (!$this->cacheManager) {
            return;
        }

        $structureBridge = $this->structureManager->wrapStructure(
            $this->documentInspector->getMetadata($document)->getAlias(),
            $this->documentInspector->getStructureMetadata($document)
        );
        $structureBridge->setDocument($document);

        $this->cacheManager->invalidateTag($document->getUuid());
    }
909699
public void validate(final Node document) throws SchemaValidationException
	{
		try
		{
			final Validator validator = schema.newValidator();

			validator.validate(new DOMSource(document));
		}
		catch (SAXException | IOException e)
		{
			throw new SchemaValidationException(e.getMessage(), e);
		}
	}
1311381
public static void parse(DocListener document, String file) {
        XmlParser p = new XmlParser();
        p.go(document, file);
    }
482540
public void indexDocument(EntityMetadata metadata, Document document)
    {
        if (log.isDebugEnabled())
        {
            log.debug("Indexing document: {} for in file system using Lucene", document);
        }

        IndexWriter w = getIndexWriter();
        try
        {
            w.addDocument(document);
        }
        catch (Exception e)
        {
            log.error("Error while indexing document {} into Lucene, Caused by:{} ", document, e);
            throw new LuceneIndexingException("Error while indexing document " + document + " into Lucene.", e);
        }
    }
305663
void remove_document(Document doc)
    {
        for (Document<K> document : documents_)
        {
            if (document.equals(doc))
            {
                remove_document(doc);
                return;
            }
        }
    }
818448
@NonNull
    public ListenerToken addDocumentChangeListener(
        @NonNull String id,
        @NonNull DocumentChangeListener listener) {
        return addDocumentChangeListener(id, null, listener);
    }
772350
public void processDocument(BufferedReader document) throws IOException {
        int docIndex = documentCounter.getAndIncrement();

        Iterator<String> documentTokens = 
            IteratorFactory.tokenizeOrdered(document);

        // As we read in the document, generate a compressed version of it,
        // which we will use during the process space method to recompute all of
        // the word vectors' semantics
        ByteArrayOutputStream compressedDocument = 
            new ByteArrayOutputStream(4096);
        DataOutputStream dos = new DataOutputStream(compressedDocument);
        int tokens = 0; // count how many are in this document
        int unfilteredTokens = 0; // how many tokens remained after filtering

        IntegerVector docVector = createVector();
        docToVector.put(docIndex, docVector);

        while (documentTokens.hasNext()) {
            tokens++;
            String focusWord = documentTokens.next();

            // If we are filtering the semantic vectors, check whether this word
            // should have its semantics calculated.  In addition, if there is a
            // filter and it would have excluded the word, do not keep its
            // semantics around
            boolean calculateSemantics =
                semanticFilter.isEmpty() || semanticFilter.contains(focusWord)
                && !focusWord.equals(IteratorFactory.EMPTY_TOKEN);

	    // If the filter does not accept this word, skip the semantic
	    // processing, continue with the next word
            if (!calculateSemantics) {
                // Do not write out any removed tokens to save space
		continue;
	    }

            // Update the occurrences of this token
            unfilteredTokens++;
            add(docVector, getTermIndexVector(focusWord));

            // Update the compress version of the document with the token.
            //
            // NOTE: this call to termToIndex *must* come after the
            // getTermIndexVector() call, which is responsible for adding this
            // mapping if it doesn't already exist.
	    int focusIndex = termToIndex.get(focusWord);

            // write the term index into the compressed for the document for
            // later corpus reprocessing
            dos.writeInt(focusIndex);
        }

        document.close();
        
        dos.close();
        byte[] docAsBytes = compressedDocument.toByteArray();

        // Once the document is finished, write the compressed contents to the
        // corpus stream
        synchronized(compressedDocumentsWriter) {
            // Write how many terms were in this document after filtering
            compressedDocumentsWriter.writeInt(unfilteredTokens);
            compressedDocumentsWriter.write(docAsBytes, 0, docAsBytes.length);
        }
    }
173484
public static void addListener(Document doc, Element root) {
    Element listener = doc.createElement("listener");
    Element listenerClass = doc.createElement("listener-class");
    listener.appendChild(listenerClass);
    listenerClass.appendChild(doc
        .createTextNode("org.apache.shiro.web.env.EnvironmentLoaderListener"));

    addRelativeTo(root, listener, "listener", true);
  }
375213
protected void processClass(ClassDoc doc) {
        defaultProcess(doc, true);
        for ( MemberDoc member : doc.fields() ) {
            processMember(member);
        }
        for ( MemberDoc member : doc.constructors() ) {
            processMember(member);
        }
        for ( MemberDoc member : doc.methods() ) {
            processMember(member);
        }
        if ( doc instanceof AnnotationTypeDoc ) {
            for ( MemberDoc member : ((AnnotationTypeDoc)doc).elements() ) {
                processMember(member);
            }
        }
    }
1265593
public function removeAllTranslations($document, NodeInterface $node, ClassMetadata $metadata)
    {
        foreach ($metadata->translatableFields as $field) {
            $mapping = $metadata->mappings[$field];
            $node->setProperty($mapping['property'], null);
        }
    }
1089032
private void compact(Document doc, QueryAdapter queryAdapter) {
		if (queryAdapter != null && queryAdapter.getCompactMode()) {
			if (doc.getIncluded() != null) {
				compact(doc.getIncluded());
			}
			if (doc.getData().isPresent()) {
				if (doc.isMultiple()) {
					compact(doc.getCollectionData().get());
				} else {
					compact(doc.getSingleData().get());
				}
			}
		}
	}
401432
public void setDocumentation(String doc) {
		if (Strings.isEmpty(doc)) {
			getSarlAnnotationType().eAdapters().removeIf(new Predicate<Adapter>() {
				public boolean test(Adapter adapter) {
					return adapter.isAdapterForType(DocumentationAdapter.class);
				}
			});
		} else {
			DocumentationAdapter adapter = (DocumentationAdapter) EcoreUtil.getExistingAdapter(
					getSarlAnnotationType(), DocumentationAdapter.class);
			if (adapter == null) {
				adapter = new DocumentationAdapter();
				getSarlAnnotationType().eAdapters().add(adapter);
			}
			adapter.setDocumentation(doc);
		}
	}
603150
public void processDocument(BufferedReader document) throws IOException {
        Queue<String> prevWords = new ArrayDeque<String>(windowSize);
        Queue<String> nextWords = new ArrayDeque<String>(windowSize);

        Iterator<String> documentTokens = 
            IteratorFactory.tokenizeOrdered(document);

        String focusWord = null;

        // Prefetch the first windowSize words.  As soon as a word enters the
        // nextWords buffer increase its occurrence count.
        for (int i = 0; i < windowSize && documentTokens.hasNext(); ++i) 
            nextWords.offer(documentTokens.next());        
        
        while (!nextWords.isEmpty()) {
            
            focusWord = nextWords.remove();

            // shift over the window to the next word
            if (documentTokens.hasNext()) {
                String windowEdge = documentTokens.next(); 
                nextWords.offer(windowEdge);
            }    
                
            // Don't bother calculating the semantics for empty tokens
            // (i.e. words that were filtered out)
            if (!focusWord.equals(IteratorFactory.EMPTY_TOKEN)) {
                SemanticVector focusMeaning = getSemanticVector(focusWord);

                // Sum up the index vector for all the surrounding words.  If
                // permutations are enabled, permute the index vector based on
                // its relative position to the focus word.
                int permutations = -(prevWords.size());        
                for (String word : prevWords) {
                    // Skip the addition of any words that are excluded from the
                    // filter set.  Note that by doing the exclusion here, we
                    // ensure that the token stream maintains its existing
                    // ordering, which is necessary when permutations are taken
                    // into account.
                    if (word.equals(IteratorFactory.EMPTY_TOKEN)) {
                        ++permutations;
                        continue;
                    }
                    
                    TernaryVector iv = wordToIndexVector.get(word);
                    if (usePermutations) {
                        iv = permutationFunc.permute(iv, permutations);
                        ++permutations;
                    }
                            
                    updateSemantics(focusMeaning, word, iv);
                }
                
                // Repeat for the words in the forward window.
                permutations = 1;
                for (String word : nextWords) {
                    // Skip the addition of any words that are excluded from the
                    // filter set.  Note that by doing the exclusion here, we
                    // ensure that the token stream maintains its existing
                    // ordering, which is necessary when permutations are taken
                    // into account.
                    if (word.equals(IteratorFactory.EMPTY_TOKEN)) {
                        ++permutations;
                        continue;
                    }
                    
                    TernaryVector iv = wordToIndexVector.get(word);
                    if (usePermutations) {
                        iv = permutationFunc.permute(iv, permutations);
                        ++permutations;
                    }
                    
                    updateSemantics(focusMeaning, word, iv);
                }
            }

            // Last put this focus word in the prev words and shift off the
            // front of the previous word window if it now contains more words
            // than the maximum window size
            prevWords.offer(focusWord);

            // Increment the frequency count for the word now that it has been
            // seen and processed.
            Integer count = wordToOccurrences.get(focusWord);
            wordToOccurrences.put(focusWord, (count == null) ? 1 : count + 1);

            if (prevWords.size() > windowSize) {
                prevWords.remove();
            }
        }    

        document.close();
    }
658793
private void addToBuffer(String document) {
        if (timerMDC == null) {
            timerMDC = MDC.get("name");
        }

        int length = document.length();
        // If this is the first document in the buffer, record its age
        bufferYoungest = new Date().getTime();
        if (docBuffer.isEmpty()) {
            bufferOldest = new Date().getTime();
            log.debug("=== New buffer starting: {}", bufferOldest);
        }
        // Add to the buffer
        docBuffer.add(document);
        bufferSize += length;
        // Check if submission is required
        checkBuffer();
    }
198851
public void parse(Document document) {
        responsePayLoad = document.getDocumentElement();
        status = responsePayLoad.getAttribute("stat");
        if ("ok".equals(status)) {
            Element photoIdElement = (Element) responsePayLoad.getElementsByTagName("photoid").item(0);
            if (photoIdElement != null) {
                photoId = ((Text) photoIdElement.getFirstChild()).getData();
            } else {
                photoId = null;
            }
            Element ticketIdElement = (Element) responsePayLoad.getElementsByTagName("ticketid").item(0);
            if (ticketIdElement != null) {
                ticketId = ((Text) ticketIdElement.getFirstChild()).getData();
            } else {
                ticketId = null;
            }
        } else {
            Element errElement = (Element) responsePayLoad.getElementsByTagName("err").item(0);
            errorCode = errElement.getAttribute("code");
            errorMessage = errElement.getAttribute("msg");
        }
    }
149921
public void setInnerDocumentation(String doc) {
		if (Strings.isEmpty(doc)) {
			getXBlockExpression().eAdapters().removeIf(new Predicate<Adapter>() {
				public boolean test(Adapter adapter) {
					return adapter.isAdapterForType(InnerBlockDocumentationAdapter.class);
				}
			});
		} else {
			InnerBlockDocumentationAdapter adapter = (InnerBlockDocumentationAdapter) EcoreUtil.getExistingAdapter(
					getXBlockExpression(), InnerBlockDocumentationAdapter.class);
			if (adapter == null) {
				adapter = new InnerBlockDocumentationAdapter();
				getXBlockExpression().eAdapters().add(adapter);
			}
			adapter.setDocumentation(doc);
		}
	}