Resolve entity references
428878
@Override
  public void forEachBatched(Fetch fetch, Consumer<List<Entity>> consumer, int batchSize) {
    delegate()
        .forEachBatched(
            fetch,
            entities -> {
              List<Entity> resolvedEntities =
                  resolveEntityReferences(entities.stream(), fetch).collect(Collectors.toList());
              consumer.accept(resolvedEntities);
            },
            batchSize);
  }
401225
def resolve_ref(cls, domain, env, fromdocname, builder, typ, target, node,
                    contnode):
        
        targets = domain.data['targets'].get(cls.ref_type, {})
        try:
            todocname, targetname = targets[target]
        except KeyError:
            env.warn(fromdocname, "Missing BB reference: bb:%s:%s" % (cls.ref_type, target),
                     node.line)
            return None

        return make_refnode(builder, fromdocname,
                            todocname, targetname,
                            contnode, target)
142588
def handle_entityref(self, entity):
        '''
            
        '''
        inTag = self._inTag
        if len(inTag) > 0:
            inTag[-1].appendText('&%s;' %(entity,))
        else:
            raise MultipleRootNodeException()
219717
def handle_entityref(self, name):
        """"""
        char_code = html_entities.name2codepoint.get(name, None)
        if char_code is not None:
            try:
                self.result += unichr(char_code).encode("utf-8")
            except:
                return
1321315
def resolve_self_references(self, rules):
        """"""
        with suppress(KeyError):
            rule = rules.pop('$self')
            rules[self.app_name] = rule
        return rules
175656
def resolve_any_xref(self, env, fromdocname, builder, target,
                         node, contnode):
        
        prefix = node.get('dn:prefix')
        results = []

        match = self.find_obj(env, prefix, target, None, 1)
        if match is not None:
            (name, obj) = match
            results.append(('dn:' + self.role_for_objtype(obj[1]),
                            make_refnode(builder, fromdocname, obj[0], name, contnode,
                                         name)))
        return results
745693
public final void entityReference(String name)
        throws org.xml.sax.SAXException
    {
        try
        {

        final java.io.Writer writer = m_writer;
        writer.write('&');
        writer.write(name);
        writer.write(';');
        
        } catch(IOException e)
        {
            throw new SAXException(e);
        }
    }
356347
@Override
    public InputSource resolveEntity(String publicId, String systemId) {
        logger.debug("CMLResolver: resolving ", publicId, ", ", systemId);
        systemId = systemId.toLowerCase();
        if ((systemId.indexOf("cml-1999-05-15.dtd") != -1) || (systemId.indexOf("cml.dtd") != -1)
                || (systemId.indexOf("cml1_0.dtd") != -1)) {
            logger.info("File has CML 1.0 DTD");
            return getCMLType("cml1_0.dtd");
        } else if ((systemId.indexOf("cml-2001-04-06.dtd") != -1) || (systemId.indexOf("cml1_0_1.dtd") != -1)
                || (systemId.indexOf("cml_1_0_1.dtd") != -1)) {
            logger.info("File has CML 1.0.1 DTD");
            return getCMLType("cml1_0_1.dtd");
        } else {
            logger.warn("Could not resolve systemID: ", systemId);
            return null;
        }
    }
779522
private void resolveCurrentclassFieldDependencies(final Object reference) {
        for (final FieldInjectionPoint injectionPoint : fieldInjectionPoints) {
            final Object injection = beanManager.getInjectableReference(injectionPoint);
            final Field field = injectionPoint.getAnnotated().getJavaMember();

            try {
                final Field declaredField = proxyClass.getDeclaredField(field.getName());

                if (declaredField.isAnnotationPresent(Inject.class)) {
                    try {
                        declaredField.set(reference, injection);
                    } catch (final Exception e) {
                        throw new RuntimeException(e);
                    }
                }
            } catch (final NoSuchFieldException ex) {
                try {
                    field.set(reference, injection);
                } catch (final Exception e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
310967
def unfold_references_helper(entity, array_of_refs, organization)
      ref = array_of_refs.shift
      field = entity[ref]

      # Unfold the id
      if array_of_refs.empty? && field
        return entity.delete(ref) if field.is_a?(String) # ~retro-compatibility to ease transition aroud Connec! idmaps rework. Should be removed eventually.

        id_hash = field.find { |id| id[:provider] == organization.oauth_provider && id[:realm] == organization.oauth_uid }
        if id_hash
          entity[ref] = id_hash['id']
        elsif field.find { |id| id[:provider] == 'connec' } # Should always be true as ids will always contain a connec id
          # We may enqueue a fetch on the endpoint of the missing association, followed by a re-fetch on this one.
          # However it's expected to be an edge case, so for now we rely on the fact that the webhooks should be relativly in order.
          # Worst case it'll be done on following sync
          entity.delete(ref)
          return nil
        end
        true

      # Follow embedment path
      else
        return true if field.blank?

        case field
        when Array
          bool = true
          field.each do |f|
            bool &= unfold_references_helper(f, array_of_refs.dup, organization)
          end
          bool
        when Hash
          unfold_references_helper(entity[ref], array_of_refs, organization)
        end
      end
    end
1243269
public void entityReference(String name) throws org.xml.sax.SAXException
    {

        flushPending();

        startEntity(name);
        endEntity(name);

        if (m_tracer != null)
		    fireEntityReference(name);
    }
640186
def _resolve(self):
        """"""
        self.__is_resolved = True
        if self.is_complex:
            type = self.nested if self.nested else self
            type.__reference = self.module.lookup(type.name)
732578
function resolveRef( ref, lookupPath ) {
      const parts = ref.split( ':', 2 );
      const path = parts.pop();
      const scheme = parts[ 0 ] || 'default';

      return lookup[ scheme ]( path, lookupPath );
   }
697766
@Override
    public InputSource resolveEntity(String publicId, String systemId) {
	for (int i = 0; i < Constants.DTDS_FLD.length; i++) {
	    if (publicId.equals(Constants.DTDS_FLD[i])) {
		return new InputSource(getClass().getResourceAsStream(DTD_1_0));
	    }
	}
	return null;
    }
1357452
function resolveResolution (
  ref,
  resolver,
  bootedServices
) {
  const refParts = ref.split(':')
  return resolver(refParts, bootedServices)
}
578400
public static String resolve(String normalized)
   {
      StringBuilder builder = new StringBuilder();
      int end = normalized.length();
      int pos = normalized.indexOf('&');
      int last = 0;

      // No references
      if (pos == -1)
         return normalized;

      while (pos != -1)
      {
         String sub = normalized.subSequence(last, pos).toString();
         builder.append(sub);
         
         int peek = pos + 1;
         if (peek == end)
            throw MESSAGES.entityResolutionInvalidEntityReference(normalized);

         if (normalized.charAt(peek) == '#')
            pos = resolveCharRef(normalized, pos, builder);
         else
            pos = resolveEntityRef(normalized, pos, builder);

         last = pos;
         pos = normalized.indexOf('&', pos);
      }

      if (last < end)
      {
         String sub = normalized.subSequence(last, end).toString();
         builder.append(sub);
      }

      return builder.toString();
   }
324200
def resolve_all_references(obj, browsed: [], cache: {})
            return obj if browsed.include?(obj)
            browsed.push(obj)

            if obj.is_a?(ObjectStream)
                obj.each do |subobj|
                    resolve_all_references(subobj, browsed: browsed, cache: cache)
                end
            end

            if obj.is_a?(Stream)
                resolve_all_references(obj.dictionary, browsed: browsed, cache: cache)
            end

            if obj.is_a?(CompoundObject)
                obj.update_values! do |subobj|
                    if subobj.is_a?(Reference)
                        subobj = (cache[subobj] ||= subobj.solve.copy)
                        subobj.no = subobj.generation = 0
                        subobj.parent = obj
                    end

                    resolve_all_references(subobj, browsed: browsed, cache: cache)
                end
            end

            obj
        end