Class PofExtractor<T,​E>

    • Constructor Detail

      • PofExtractor

        public PofExtractor()
        Default constructor (necessary for the PortableObject interface).
      • PofExtractor

        public PofExtractor​(Class<E> clz,
                            int iProp)
        Constructs a PofExtractor based on a property index.

        This constructor is equivalent to:

           PofExtractor extractor =
               new PofExtractor(clz, new SimplePofPath(iProp), VALUE);
         

        Parameters:
        clz - the required class of the extracted value or null if the class is to be inferred from the serialized state
        iProp - property index
      • PofExtractor

        public PofExtractor​(Class<E> clz,
                            int iProp,
                            String sNameCanon)
        Constructs a PofExtractor based on a property index while providing the property's canonical name. Providing an appropriate canonical name enables equivalence with other ValueExtractor instances with same canonical name. See ValueExtractor.equals(Object) and ValueExtractor.getCanonicalName().
        Parameters:
        clz - the required class of the extracted value or null if the class is to be inferred from the serialized state
        iProp - property index
        sNameCanon - the canonical name for this extractor
        Since:
        12.2.1.4
      • PofExtractor

        public PofExtractor​(Class<E> clz,
                            PofNavigator navigator)
        Constructs a PofExtractor based on a POF navigator.

        This constructor is equivalent to:

           PofExtractor extractor =
               new PofExtractor(clz, navigator, VALUE);
         

        Parameters:
        clz - the required class of the extracted value or null if the class is to be inferred from the serialized state
        navigator - POF navigator
      • PofExtractor

        public PofExtractor​(Class<E> clz,
                            PofNavigator navigator,
                            int nTarget)
        Constructs a PofExtractor based on a POF navigator and the entry extraction target.
        Parameters:
        clz - the required class of the extracted value or null if the class is to be inferred from the serialized state
        navigator - POF navigator
        nTarget - one of the AbstractExtractor.VALUE or AbstractExtractor.KEY values
      • PofExtractor

        public PofExtractor​(Class<E> clz,
                            PofNavigator navigator,
                            int nTarget,
                            String sNameCanon)
        Constructs a PofExtractor based on a POF navigator while providing its canonical name.
        Parameters:
        clz - the required class of the extracted value or null if the class is to be inferred from the serialized state
        navigator - POF navigator
        nTarget - one of the AbstractExtractor.VALUE or AbstractExtractor.KEY values
        sNameCanon - canonical name for this extractor
        Since:
        12.2.1.4
      • PofExtractor

        public PofExtractor​(Class<E> clz,
                            PofNavigator navigator,
                            String sNameCanon)
        Constructs a VALUE PofExtractor based on a POF navigator while providing its canonical name.
        Parameters:
        clz - the required class of the extracted value or null if the class is to be inferred from the serialized state
        navigator - POF navigator
        sNameCanon - canonical name for this extractor
        Since:
        12.2.1.4
    • Method Detail

      • extractFromEntry

        public E extractFromEntry​(Map.Entry entry)
        Extracts the value from the passed Entry object.

        It is expected that this extractor will only be used against POF-encoded entries implementing BinaryEntry interface.

        Overrides:
        extractFromEntry in class AbstractExtractor<T,​E>
        Parameters:
        entry - an Entry object to extract a value from
        Returns:
        the extracted value
        Throws:
        UnsupportedOperationException - if the specified Entry is not a POF-encoded BinaryEntry or the serializer is not a PofContext
        ClassCastException - if the extracted value is incompatible with the specified class
      • getNavigator

        public PofNavigator getNavigator()
        Obtain the POF navigator for this extractor.
        Returns:
        the POF navigator
      • getClassExtracted

        public Class<E> getClassExtracted()
        Obtain the Class of the extracted value.
        Returns:
        the expected Class
      • equals

        public boolean equals​(Object o)
        Compare the PofExtractor with another object to determine equality.

        AbstractExtractor.equals(Object) contract takes precedence when applicable, falling back to implementation specific equals when this and o have non-null canonical name.

        Two PofExtractor objects are considered equal iff their navigators are equal and they have the same target (key or value).

        Specified by:
        equals in interface Comparator<T>
        Specified by:
        equals in interface ValueExtractor<T,​E>
        Overrides:
        equals in class AbstractExtractor<T,​E>
        Parameters:
        o - the reference object with which to compare
        Returns:
        true iff this PofExtractor and the passed object are equivalent
      • toString

        public String toString()
        Return a human-readable description for this PofExtractor.
        Overrides:
        toString in class Object
        Returns:
        a String description of the PofExtractor
      • readExternal

        public void readExternal​(PofReader in)
                          throws IOException
        Restore the contents of a user type instance by reading its state using the specified PofReader object.
        Specified by:
        readExternal in interface PortableObject
        Parameters:
        in - the PofReader from which to read the object's state
        Throws:
        IOException - if an I/O error occurs
      • writeExternal

        public void writeExternal​(PofWriter out)
                           throws IOException
        Save the contents of a POF user type instance by writing its state using the specified PofWriter object.
        Specified by:
        writeExternal in interface PortableObject
        Parameters:
        out - the PofWriter to which to write the object's state
        Throws:
        IOException - if an I/O error occurs
      • getPofTypeId

        protected int getPofTypeId​(PofContext ctx)
        compute the expected pof type id based on the class.
        Parameters:
        ctx - pof context
        Returns:
        pof type id or T_UNKNOWN if the class is null.