/** * Defers to <code>processAttributes</code> by default. * * @param attributes * attributes of the trait being processed. Subclasses can modify this Map to * modify the attributes * @param metawidget * the parent Metawidget. Never null. May be useful to help processing * @param toInspect * the Object being inspected. May be useful to help processing * @param type * the type being inspected. May be useful to help processing * @param names * the names being inspected. May be useful to help processing */ protected void processTrait( Map<String, String> attributes, M metawidget ) { processAttributes( attributes, metawidget ); }
@Override public Element processInspectionResultAsDom( Element inspectionResult, M metawidget, Object toInspect, String type, String... names ) { try { LOCAL_CONTEXT.set( createContext( metawidget ) ); return super.processInspectionResultAsDom( inspectionResult, metawidget, toInspect, type, names ); } finally { LOCAL_CONTEXT.remove(); } }
public Element processInspectionResultAsDom( Element inspectionResult, M metawidget, Object toInspect, String type, String... names ) { Element entity = XmlUtils.getFirstChildElement( inspectionResult ); // Sanity check String elementName = entity.getNodeName(); if ( !ENTITY.equals( elementName ) ) { throw InspectionResultProcessorException.newException( "Top-level element name should be " + ENTITY + ", not " + elementName ); } Map<String, String> attributes = XmlUtils.getAttributesAsMap( entity ); processEntity( attributes, metawidget, toInspect, type, names ); XmlUtils.setMapAsAttributes( entity, attributes ); processTraits( entity, metawidget, toInspect, type, names ); return inspectionResult; }
processTrait( attributes, metawidget ); XmlUtils.setMapAsAttributes( trait, attributes ); processTraits( trait, metawidget, toInspect, type, ArrayUtils.add( names, attributes.get( NAME ) ) );
@Override protected void processEntity( Map<String, String> attributes, UIMetawidget metawidget, Object toInspect, String type, String... names ) { FacesContext context = FacesContext.getCurrentInstance(); if ( context == null ) { throw InspectionResultProcessorException.newException( "FacesContext not available to FacesInspectionResultProcessor" ); } Map<String, Object> requestMap = null; try { if ( mInjectThis != null ) { requestMap = context.getExternalContext().getRequestMap(); requestMap.put( UNDERSCORE_THIS_ATTRIBUTE, mInjectThis.traverse( toInspect, type, true, names ).getValue() ); } super.processEntity( attributes, metawidget, toInspect, type, names ); } finally { // UNDERSCORE_THIS_ATTRIBUTE should not be available outside of our particular // evaluation if ( requestMap != null ) { requestMap.remove( UNDERSCORE_THIS_ATTRIBUTE ); } } }
@Override protected void processTraits( Element entity, UIMetawidget metawidget, Object toInspect, String type, String... names ) { FacesContext context = FacesContext.getCurrentInstance(); if ( context == null ) { throw InspectionResultProcessorException.newException( "FacesContext not available to FacesInspectionResultProcessor" ); } Map<String, Object> requestMap = null; try { if ( mInjectThis != null ) { requestMap = context.getExternalContext().getRequestMap(); requestMap.put( UNDERSCORE_THIS_ATTRIBUTE, mInjectThis.traverse( toInspect, type, false, names ).getValue() ); } super.processTraits( entity, metawidget, toInspect, type, names ); } finally { // UNDERSCORE_THIS_ATTRIBUTE should not be available outside of our particular // evaluation if ( requestMap != null ) { requestMap.remove( UNDERSCORE_THIS_ATTRIBUTE ); } } }
public Element processInspectionResultAsDom( Element inspectionResult, M metawidget, Object toInspect, String type, String... names ) { Element entity = XmlUtils.getFirstChildElement( inspectionResult ); // Sanity check String elementName = entity.getNodeName(); if ( !ENTITY.equals( elementName ) ) { throw InspectionResultProcessorException.newException( "Top-level element name should be " + ENTITY + ", not " + elementName ); } Map<String, String> attributes = XmlUtils.getAttributesAsMap( entity ); processEntity( attributes, metawidget, toInspect, type, names ); XmlUtils.setMapAsAttributes( entity, attributes ); processTraits( entity, metawidget, toInspect, type, names ); return inspectionResult; }
processTrait( attributes, metawidget ); XmlUtils.setMapAsAttributes( trait, attributes ); processTraits( trait, metawidget, toInspect, type, ArrayUtils.add( names, attributes.get( NAME ) ) );
@Override protected void processEntity( Map<String, String> attributes, UIMetawidget metawidget, Object toInspect, String type, String... names ) { FacesContext context = FacesContext.getCurrentInstance(); if ( context == null ) { throw InspectionResultProcessorException.newException( "FacesContext not available to FacesInspectionResultProcessor" ); } Map<String, Object> requestMap = null; try { if ( mInjectThis != null ) { requestMap = context.getExternalContext().getRequestMap(); requestMap.put( UNDERSCORE_THIS_ATTRIBUTE, mInjectThis.traverse( toInspect, type, true, names ).getValue() ); } super.processEntity( attributes, metawidget, toInspect, type, names ); } finally { // UNDERSCORE_THIS_ATTRIBUTE should not be available outside of our particular // evaluation if ( requestMap != null ) { requestMap.remove( UNDERSCORE_THIS_ATTRIBUTE ); } } }
@Override protected void processTraits( Element entity, UIMetawidget metawidget, Object toInspect, String type, String... names ) { FacesContext context = FacesContext.getCurrentInstance(); if ( context == null ) { throw InspectionResultProcessorException.newException( "FacesContext not available to FacesInspectionResultProcessor" ); } Map<String, Object> requestMap = null; try { if ( mInjectThis != null ) { requestMap = context.getExternalContext().getRequestMap(); requestMap.put( UNDERSCORE_THIS_ATTRIBUTE, mInjectThis.traverse( toInspect, type, false, names ).getValue() ); } super.processTraits( entity, metawidget, toInspect, type, names ); } finally { // UNDERSCORE_THIS_ATTRIBUTE should not be available outside of our particular // evaluation if ( requestMap != null ) { requestMap.remove( UNDERSCORE_THIS_ATTRIBUTE ); } } }
@Override protected void processEntity( Map<String, String> attributes, M metawidget, Object toInspect, String type, String... names ) { JexlContext context = LOCAL_CONTEXT.get(); try { context.set( THIS_ATTRIBUTE, mInjectThis.traverse( toInspect, type, true, names ).getValue() ); super.processEntity( attributes, metawidget, toInspect, type, names ); } finally { // THIS_ATTRIBUTE should not be available outside of our particular evaluation context.set( THIS_ATTRIBUTE, null ); } }
@Override protected void processTraits( Element entity, M metawidget, Object toInspect, String type, String... names ) { JexlContext context = LOCAL_CONTEXT.get(); try { context.set( THIS_ATTRIBUTE, mInjectThis.traverse( toInspect, type, false, names ).getValue() ); super.processTraits( entity, metawidget, toInspect, type, names ); } finally { // THIS_ATTRIBUTE should not be available outside of our particular evaluation context.set( THIS_ATTRIBUTE, null ); } }
/** * Defers to <code>processAttributes</code> by default. * * @param attributes * attributes of the entity being processed. Subclasses can modify this Map to * modify the attributes * @param metawidget * the parent Metawidget. Never null. May be useful to help processing * @param toInspect * the Object being inspected. May be useful to help processing * @param type * the type being inspected. May be useful to help processing * @param names * the names being inspected. May be useful to help processing */ protected void processEntity( Map<String, String> attributes, M metawidget, Object toInspect, String type, String... names ) { processAttributes( attributes, metawidget ); }
/** * Process the given inspection result in context of the given Metawidget. * <p> * This method is marked <code>final</code> because most Metawidget implementations will call * <code>processInspectionResultAsDom</code> directly instead. So subclasses need to override * <code>processInspectionResultAsDom</code>, not <code>processInspectionResult</code>. */ public final String processInspectionResult( String inspectionResult, M metawidget, Object toInspect, String type, String... names ) { Document document = XmlUtils.documentFromString( inspectionResult ); Element inspectionResultRoot = document.getDocumentElement(); Element newInspectionResultRoot = processInspectionResultAsDom( inspectionResultRoot, metawidget, toInspect, type, names ); return XmlUtils.documentToString( newInspectionResultRoot.getOwnerDocument(), false ); }
/** * Defers to <code>processAttributes</code> by default. * * @param attributes * attributes of the trait being processed. Subclasses can modify this Map to * modify the attributes * @param metawidget * the parent Metawidget. Never null. May be useful to help processing * @param toInspect * the Object being inspected. May be useful to help processing * @param type * the type being inspected. May be useful to help processing * @param names * the names being inspected. May be useful to help processing */ protected void processTrait( Map<String, String> attributes, M metawidget ) { processAttributes( attributes, metawidget ); }
/** * Process the given inspection result in context of the given Metawidget. * <p> * This method is marked <code>final</code> because most Metawidget implementations will call * <code>processInspectionResultAsDom</code> directly instead. So subclasses need to override * <code>processInspectionResultAsDom</code>, not <code>processInspectionResult</code>. */ public final String processInspectionResult( String inspectionResult, M metawidget, Object toInspect, String type, String... names ) { Document document = XmlUtils.documentFromString( inspectionResult ); Element inspectionResultRoot = document.getDocumentElement(); Element newInspectionResultRoot = processInspectionResultAsDom( inspectionResultRoot, metawidget, toInspect, type, names ); return XmlUtils.documentToString( newInspectionResultRoot.getOwnerDocument(), false ); }
/** * Defers to <code>processAttributes</code> by default. * * @param attributes * attributes of the entity being processed. Subclasses can modify this Map to * modify the attributes * @param metawidget * the parent Metawidget. Never null. May be useful to help processing * @param toInspect * the Object being inspected. May be useful to help processing * @param type * the type being inspected. May be useful to help processing * @param names * the names being inspected. May be useful to help processing */ protected void processEntity( Map<String, String> attributes, M metawidget, Object toInspect, String type, String... names ) { processAttributes( attributes, metawidget ); }