<p>Locate and return the nearest enclosing {@link UIComponentTag}
if any; otherwise, return <code>null</code>.</p>

@param context <code>PageContext</code> for the current page
439355
public static UIComponentTag getParentUIComponentTag(PageContext context) {

        UIComponentClassicTagBase result =
             getParentUIComponentClassicTagBase(context);
        if (!(result instanceof UIComponentTag)) {
            return new UIComponentTagAdapter(result);
        }
        return ((UIComponentTag) result);

    }
1283461
protected final void closeContext(GenerationContext context) {
		boolean runPostElements = false;
		GenerationContext selectedContext = null;
		synchronized (this) {
			final Iterator<GenerationContext> iterator = this.bufferedContexes.iterator();
			while (selectedContext == null && iterator.hasNext()) {
				final GenerationContext candidate = iterator.next();
				if (Objects.equal(candidate.getTypeIdentifier(), context.getTypeIdentifier())) {
					runPostElements = candidate.getParentContext() == null;
					selectedContext = candidate;
				}
			}
		}
		if (selectedContext == null) {
			throw new IllegalStateException("Not same contexts when closing"); //$NON-NLS-1$
		}
		if (runPostElements) {
			for (final Runnable handler : selectedContext.getPostFinalizationElements()) {
				handler.run();
			}
		}
		synchronized (this) {
			final Iterator<GenerationContext> iterator = this.bufferedContexes.iterator();
			while (iterator.hasNext()) {
				final GenerationContext candidate = iterator.next();
				if (selectedContext == candidate) {
					candidate.setParentContext(null);
					iterator.remove();
					return;
				}
			}
		}
	}
346252
protected InputContainerElements scan(final UIComponent component, InputContainerElements elements,
            final FacesContext context) {
        if (elements == null) {
            elements = new InputContainerElements();
        }

        // NOTE we need to walk the tree ignoring rendered attribute because it's condition
        // could be based on what we discover
        if ((elements.getLabel() == null) && (component instanceof HtmlOutputLabel)) {
            elements.setLabel((HtmlOutputLabel) component);
        } else if (component instanceof EditableValueHolder) {
            elements.registerInput((EditableValueHolder) component, getDefaultValidator(context), context);
        } else if (component instanceof UIMessage) {
            elements.registerMessage((UIMessage) component);
        }
        // may need to walk smarter to ensure "element of least suprise"
        for (UIComponent child : component.getChildren()) {
            scan(child, elements, context);
        }

        return elements;
    }
1326040
private String getContextInfo(CmsContainerPageElementPanel element) {

        CmsContainerPageContainer container;
        if (m_handler.m_controller.isGroupcontainerEditing()) {
            container = (CmsContainerPageContainer)((CmsContainerPageElementPanel)element.getParentTarget()).getParentTarget();
        } else {
            container = (CmsContainerPageContainer)element.getParentTarget();
        }
        JSONObject result = new JSONObject();
        putString(result, CmsCntPageData.JSONKEY_ELEMENT_ID, element.getId());
        CmsUUID detailId = m_handler.m_controller.getData().getDetailId();
        if (detailId != null) {
            putString(result, CmsCntPageData.JSONKEY_DETAIL_ELEMENT_ID, "" + detailId);
        }
        putString(result, CmsCntPageData.JSONKEY_NAME, "" + container.getContainerId());
        putString(result, CmsCntPageData.JSONKEY_TYPE, "" + container.getContainerType());
        result.put(CmsCntPageData.JSONKEY_WIDTH, new JSONNumber(container.getConfiguredWidth()));
        result.put(CmsCntPageData.JSONKEY_DETAILVIEW, JSONBoolean.getInstance(container.isDetailView()));
        result.put(CmsCntPageData.JSONKEY_DETAILONLY, JSONBoolean.getInstance(container.isDetailOnly()));
        result.put(CmsCntPageData.JSONKEY_MAXELEMENTS, new JSONNumber(1));
        JSONObject presets = new JSONObject();
        Map<String, String> presetsMap = container.getSettingPresets();
        for (Map.Entry<String, String> entry : presetsMap.entrySet()) {
            presets.put(entry.getKey(), new JSONString(entry.getValue()));
        }
        result.put(CmsCntPageData.JSONKEY_PRESETS, presets);
        return result.toString();
    }
859252
protected PageContext getPageContext()
    {
        JspContext ctxt = getJspContext();
        if (ctxt instanceof PageContext)
            return (PageContext) ctxt;

        // assert the page context and log an error in production
        assert(false) : "The JspContext was not a PageContext";
        logger.error("The JspContext was not a PageContext");
        return null;
    }
315293
public com.google.api.Context getContext() {
    return context_ == null ? com.google.api.Context.getDefaultInstance() : context_;
  }
1244137
@Benchmark
  @BenchmarkMode(Mode.AverageTime)
  @OutputTimeUnit(TimeUnit.NANOSECONDS)
  public TagContext getCurrentTagContext(Data data) {
    return data.tagger.getCurrentTagContext();
  }
1150058
protected ELContext getELContext() {
	FacesContext fc = getFacesContext();
	ELContext result = null;
	if (null != fc) {
	    result = fc.getELContext();
	}
	return result;
    }
301799
@SuppressWarnings("unchecked")
    private static ISecurityContext getCasContext(ISecurityContext context) {
        if (context instanceof ICasSecurityContext) {
            return context;
        }
        Enumeration contextEnum = context.getSubContexts();
        while (contextEnum.hasMoreElements()) {
            ISecurityContext subContext = (ISecurityContext) contextEnum.nextElement();
            if (subContext instanceof ICasSecurityContext) {
                return subContext;
            }
        }
        return null;
    }
544510
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WPanel panel = (WPanel) component;
		XmlStringBuilder xml = renderContext.getWriter();
		GridLayout layout = (GridLayout) panel.getLayout();
		Size hgap = layout.getHorizontalGap();
		String hgapString = hgap == null ? null : hgap.toString();
		Size vgap = layout.getVerticalGap();
		String vgapString = vgap == null ? null : vgap.toString();
		int rows = layout.getRows();
		int cols = layout.getCols();

		xml.appendTagOpen("ui:gridlayout");

		xml.appendAttribute("rows", rows > 0 ? String.valueOf(rows) : "0");
		xml.appendAttribute("cols", cols > 0 ? String.valueOf(cols) : "0");
		xml.appendOptionalAttribute("hgap", hgapString);
		xml.appendOptionalAttribute("vgap", vgapString);

		xml.appendClose();

		int size = panel.getChildCount();

		for (int i = 0; i < size; i++) {
			xml.appendTag("ui:cell");
			WComponent child = panel.getChildAt(i);
			child.paint(renderContext);
			xml.appendEndTag("ui:cell");
		}

		xml.appendEndTag("ui:gridlayout");
	}
1001683
protected XComponentContext getLocalContext() throws BootstrapException, Exception {

        XComponentContext xLocalContext = Bootstrap.createInitialComponentContext(null);
        if (xLocalContext == null) {
            throw new BootstrapException("no local component context!");
        }
        return xLocalContext;
    }
1330920
@Override
    public void beforeDoTag(JspContext context, JspFragment fragment) {
        Map<String, String> customMap = ConfigReader.getConfig().getCustomMap();

        if (customMap == null) {
            throw new RuntimeException("사용가능한 custom tag 설정이 없습니다.\naxu4j.xml 설정파일에서 <customs> 내용을 확인하세요.");
        }

        tagBody = customMap.get(getCustomid());
        doBody  = TagUtils.toString(fragment);

        if (tagBody == null) {
            throw new RuntimeException(String.format("사용가능한 custom tag 설정이 없습니다.\naxu4j.xml 설정파일에서 <custom id=\"%s\"> 내용을 확인하세요.", getCustomid()));
        }

    }
851175
@SuppressWarnings("unchecked")
    public <T> T get(final Contextual<T> component) {
        assertActive();
        return (T) getComponentInstanceMap().get(component);
    }
270373
@Trivial
    @Activate
    protected void activate(ComponentContext context) {
        Dictionary<String, ?> props = context.getProperties();
        final boolean trace = TraceComponent.isAnyTracingEnabled();
        if (trace && tc.isEntryEnabled())
            Tr.entry(this, tc, "activate", props);

        String contextSvcName = (String) props.get(JNDI_NAME);
        if (contextSvcName == null)
            contextSvcName = (String) props.get(CONFIG_ID);

        lock.writeLock().lock();
        try {
            componentContext = context;
            properties = props;
            name = contextSvcName;
        } finally {
            lock.writeLock().unlock();
        }

        if (trace && tc.isEntryEnabled())
            Tr.exit(this, tc, "activate");
    }
38529
protected static <T extends Annotation> T getAnnotationFromContext(InvocationContext context, Class<T> clazz) {
        T result = context.getMethod().getAnnotation(clazz);
        return result != null ? result : context.getTarget().getClass().getAnnotation(clazz);
    }
1305451
protected void closeStartTag() throws SAXException
    {
            try
            {

            // finish processing attributes, time to fire off the start element event
            if (m_tracer != null)
                super.fireStartElem(m_elemContext.m_elementName);  
            
            int nAttrs = m_attributes.getLength();   
            if (nAttrs>0)
            {
                processAttributes(m_writer, nAttrs);
                // clear attributes object for re-use with next element
                m_attributes.clear();
            }

            m_writer.write('>');

            /* At this point we have the prefix mappings now, so
             * lets determine if the current element is specified in the cdata-
             * section-elements list.
             */
            if (m_CdataElems != null) // if there are any cdata sections
                m_elemContext.m_isCdataSection = isCdataSection();
            if (m_doIndent)
            {
                m_isprevtext = false;
                m_preserves.push(m_ispreserve);
            }
            
            }
            catch(IOException e)
            {
                throw new SAXException(e);
            }
    }
771829
public static UIContext getContextForComponent(final WComponent component) {
		// Start with the current Context
		UIContext result = UIContextHolder.getCurrent();
		// Go through the contexts until we find the component
		while (result instanceof SubUIContext && !((SubUIContext) result).isInContext(component)) {
			result = ((SubUIContext) result).getBacking();
		}
		return result;
	}