FileDocCategorySizeDatePackage
FieldPort.javaAPI DocAndroid 5.1 API2937Thu Mar 12 22:22:30 GMT 2015android.filterfw.core

FieldPort

public class FieldPort extends InputPort
hide

Fields Summary
protected Field
mField
protected boolean
mHasFrame
protected boolean
mValueWaiting
protected Object
mValue
Constructors Summary
public FieldPort(Filter filter, String name, Field field, boolean hasDefault)


             
        super(filter, name);
        mField = field;
        mHasFrame = hasDefault;
    
Methods Summary
public synchronized booleanacceptsFrame()

        return !mValueWaiting;
    
public voidclear()

    
public java.lang.ObjectgetTarget()

        try {
            return mField.get(mFilter);
        } catch (IllegalAccessException e) {
            return null;
        }
    
public synchronized booleanhasFrame()

        return mHasFrame;
    
public synchronized FramepullFrame()

        throw new RuntimeException("Cannot pull frame on " + this + "!");
    
public voidpushFrame(Frame frame)

        setFieldFrame(frame, false);
    
protected synchronized voidsetFieldFrame(Frame frame, boolean isAssignment)

        assertPortIsOpen();
        checkFrameType(frame, isAssignment);

        // Store the object value
        Object value = frame.getObjectValue();
        if ((value == null && mValue != null) || !value.equals(mValue)) {
            mValue = value;
            mValueWaiting = true;
        }

        // Since a frame was set, mark this port as having a frame to pull
        mHasFrame = true;
    
public voidsetFrame(Frame frame)

        setFieldFrame(frame, true);
    
public java.lang.StringtoString()

        return "field " + super.toString();
    
public synchronized voidtransfer(FilterContext context)

        if (mValueWaiting) {
            try {
                mField.set(mFilter, mValue);
            } catch (IllegalAccessException e) {
                throw new RuntimeException(
                    "Access to field '" + mField.getName() + "' was denied!");
            }
            mValueWaiting = false;
            if (context != null) {
                mFilter.notifyFieldPortValueUpdated(mName, context);
            }
        }