Search subject scheme elements for a given key
@param root subject scheme element tree to search through
@param keyValue key to locate
@return element that matches the key, otherwise {@code null}
510844
private Element searchForKey(final Element root, final String keyValue) {
        if (root == null || keyValue == null) {
            return null;
        }
        final LinkedList<Element> queue = new LinkedList<>();
        queue.add(root);
        while (!queue.isEmpty()) {
            final Element node = queue.removeFirst();
            final NodeList children = node.getChildNodes();
            for (int i = 0; i < children.getLength(); i++) {
                if (children.item(i).getNodeType() == Node.ELEMENT_NODE) {
                    queue.add((Element)children.item(i));
                }
            }
            if (SUBJECTSCHEME_SUBJECTDEF.matches(node)) {
                final String key = node.getAttribute(ATTRIBUTE_NAME_KEYS);
                if (keyValue.equals(key)) {
                    return node;
                }
            }
        }
        return null;
    }
732240
public Elements getElementsByAttributeValue(String key, String value) {
        return Collector.collect(new Evaluator.AttributeWithValue(key, value), this);
    }
759068
final TreeMapEntry<K,V> getEntryUsingComparator(Object key) {
        @SuppressWarnings("unchecked")
            K k = (K) key;
        Comparator<? super K> cpr = comparator;
        if (cpr != null) {
            TreeMapEntry<K,V> p = root;
            while (p != null) {
                int cmp = cpr.compare(k, p.key);
                if (cmp < 0)
                    p = p.left;
                else if (cmp > 0)
                    p = p.right;
                else
                    return p;
            }
        }
        return null;
    }
748849
function(key, searchRoot) {
			// Search the DOM by element ID (assuming this is faster than traversing all nodes).
			var el, match;
			// TODO: use tree.keyMap if available
			// TODO: check opts.generateIds === true
			if (!searchRoot) {
				el = document.getElementById(this.options.idPrefix + key);
				if (el) {
					return el.ftnode ? el.ftnode : null;
				}
			}
			// Not found in the DOM, but still may be in an unrendered part of tree
			searchRoot = searchRoot || this.rootNode;
			match = null;
			searchRoot.visit(function(node) {
				if (node.key === key) {
					match = node;
					return false; // Stop iteration
				}
			}, true);
			return match;
		}
1367682
public void get(Object rootVal,
                  MatchSpaceKey msg,
                  EvalCache cache,
                  Object contextValue,
                  SearchResults result)
    throws MatchingException,BadMessageFormatMatchingException
  {
    if (tc.isEntryEnabled())
	    tc.entry(this,cclass, "get", new Object[]{rootVal,msg,cache,result});

    if (result instanceof CacheingSearchResults)
      ((CacheingSearchResults) result).setMatcher(vacantChild);
    vacantChild.get(null, msg, cache, contextValue, result);

    if (tc.isEntryEnabled())
	    tc.exit(this,cclass, "get");
  }
214747
private Element searchForKey(final Element root, final String key, final String tagName) {
        if (root == null || StringUtils.isEmptyString(key)) {
            return null;
        }
        final Queue<Element> queue = new LinkedList<>();
        queue.offer(root);

        while (!queue.isEmpty()) {
            final Element pe = queue.poll();
            final NodeList pchildrenList = pe.getChildNodes();
            for (int i = 0; i < pchildrenList.getLength(); i++) {
                final Node node = pchildrenList.item(i);
                if (node.getNodeType() == Node.ELEMENT_NODE) {
                    queue.offer((Element)node);
                }
            }
            String value = pe.getNodeName();
            if (StringUtils.isEmptyString(value)||
                    !value.equals(tagName)) {
                continue;
            }

            value = pe.getAttribute(ATTRIBUTE_NAME_NAME);
            if (StringUtils.isEmptyString(value)) {
                continue;
            }

            if (value.equals(key)) {
                return pe;
            }
        }
        return null;
    }
1163279
@Override
    public Object getValue(ELContext context, Object base, Object property) throws NullPointerException,
        PropertyNotFoundException, ELException {
        
        Iterator<?> pos;
        try {
            pos = seek(context, base, property);
        } catch(PropertyNotFoundException e) {
            pos = null;
        }
        return pos == null ? null : pos.next();
    }
425372
public static String lookupIfEmpty( final String value,
                                        final Map<String, String> props,
                                        final String key ) {
        return value != null ? value : props.get(key);
    }
93497
public static <E> void rootElement(WebElement root, E element) {
		if (element == null || root == null) return;
		if (element instanceof WebElement) return;
		
		for (Class<?> clazz = element.getClass(); !clazz.equals(Object.class);
				clazz = clazz.getSuperclass()) {
			
			if (Enhancer.isEnhanced(clazz)) continue;
			
			Field[] fields = clazz.getDeclaredFields();
			for (Field field : fields) {
				setRootElementField(root, element, field);
			}
		}
	}
643715
public List<String> getRoleNames(final Optional<Subject> subjectOption)
    {
        final List<String> roleNames = new ArrayList<String>();
        subjectOption.ifPresent(subject -> {
            final List<? extends Role> roles = subject.getRoles();
            if (roles != null)
            {
                for (Role role : roles)
                {
                    if (role != null)
                    {
                        roleNames.add(role.getName());
                    }
                }
            }
        });

        return roleNames;
    }
965220
public String optString(String key, String defaultValue) {
        Object object = this.opt(key);
        return NULL.equals(object) ? defaultValue : object.toString();
    }
943981
public BeanId find(EJSHome home, Serializable pkey, boolean isHome)
    {
        int hashValue = BeanId.computeHashValue(home.j2eeName, pkey, isHome);

        BeanId[] buckets = this.ivBuckets;
        BeanId element = buckets[(hashValue & 0x7FFFFFFF) % buckets.length];

        if (element == null || !element.equals(home, pkey, isHome))
        {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            {
                ++ivCacheFinds;
                Tr.debug(tc, "BeanId not found in BeanId Cache : " +
                             ivCacheHits + " / " + ivCacheFinds);
            }
            element = new BeanId(home, pkey, isHome);
        }
        else
        {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            {
                ++ivCacheFinds;
                ++ivCacheHits;
                Tr.debug(tc, "BeanId found in BeanId Cache : " +
                             ivCacheHits + " / " + ivCacheFinds);
            }
        }

        return element;
    }
680736
public T get(final int key) {
		int index = ((key & 0x7FFFFFFF) % elementKeys.length);

		long m = elementKeys[index];
		if (key == m) {
			return elementValues[index];
		}

		return null;
	}
620755
@SuppressWarnings("rawtypes")
    private Map.Entry getMapEntry(Node node) {
        Object value = null;
        String keyName = node.getLocalName();
        XmlMapEntry xmlMapEntry = this.mapSpecification.get(keyName);
        switch (node.getNodeType()) {
            case Node.ATTRIBUTE_NODE:
                value = node.getNodeValue();
                break;
            case Node.ELEMENT_NODE: {
                if (xmlMapEntry == null) {
                    value = new NodeArray(node.getChildNodes());
                } else {
                    XmlMapFacet valueFacet = xmlMapEntry.getValue();
                    switch (valueFacet.getType()) {
                        case ELEMENT:
                            value = keyName;
                            break;
                        case CONTENT: {
                            NodeList nodeList = node.getChildNodes();
                            if (nodeList.getLength() > 0) {
                                value = new NodeArray(nodeList);
                            }
                        }
                            break;
                        case ATTRIBUTE: {
                            NamedNodeMap attributes = node.getAttributes();
                            Node attribute = attributes.getNamedItem(valueFacet.getName());
                            if (attribute != null) {
                                value = attribute.getNodeValue();
                            }
                        }
                            break;
                        default:
                            throw new IllegalStateException();
                    }
                    XmlMapFacet keyFacet = xmlMapEntry.getKey();
                    switch (keyFacet.getType()) {
                        case ELEMENT:
                            break;
                        case CONTENT: {
                            NodeList nodeList = node.getChildNodes();
                            if (nodeList.getLength() > 0) {
                                keyName = getStringValue((Node) nodeList.item(0));
                            } else {
                                keyName = null;
                            }
                        }
                            break;
                        case ATTRIBUTE: {
                            NamedNodeMap attributes = node.getAttributes();
                            Node attribute = attributes.getNamedItem(keyFacet.getName());
                            if (attribute != null) {
                                keyName = attribute.getNodeValue();
                            } else {
                                keyName = null;
                            }
                            break;
                        }
                        default:
                            throw new IllegalStateException();
                    }
                }
            }
        }
        if (keyName == null) {
            return null;
        } else {
            final Object _key = keyName;
            final Object _value = value;
            return new Map.Entry() {

                @Override
                public Object getKey() {
                    return _key;
                }

                @Override
                public Object getValue() {
                    return _value;
                }

                @Override
                public Object setValue(Object object) {
                    return null;
                }

            };
        }
    }
1342558
final boolean match(final Subject subject,
                        final SICoreConnection coreConnection) {

        boolean subjectsMatch = (_subject == null) ? (subject == null)
                        : (_subject.equals(subject));
        boolean coreConnectionsMatch = (coreConnection == null)
                                       || coreConnection.isEquivalentTo(_coreConnection);

        return subjectsMatch && coreConnectionsMatch && isValid();

    }
258951
public AbstractSpecWithPrimaryKey<T> withPrimaryKey(KeyAttribute ... components) {
        if (components == null)
            this.keyComponents = null;
        else
            this.keyComponents = Arrays.asList(components);
        return this;
    }
1348984
public Object getValue(String key) {
        if (values == null) {
            return null;
        }
        return values.get(key);
    }