Package org.eolang

Class Data.ToPhi

  • All Implemented Interfaces:
    Data, Phi
    Enclosing interface:
    Data

    public static final class Data.ToPhi
    extends Object
    implements Phi
    Makes a Phi out of a primitive Java object, like String or Integer.

    This is more convenient than making EOstring, then making EObytes fill it up with data and then injecting bytes to string. This class is used in Java tests mostly for the sake of brevity. In auto-generated Java code we do: Phi bytes = Phi.Φ.take("org.eolang.bytes").copy(); Phi attached = new PhWith(bytes, 0, new byte[] {...}); Phi str = Phi.Φ.take("org.eolang.string").copy(); Phi applied = new PhWith(str, 0, attached); return applied;

    Since:
    0.1
    • Constructor Detail

      • ToPhi

        public ToPhi​(Object obj)
        Ctor.
        Parameters:
        obj - Data
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • copy

        public Phi copy()
        Description copied from interface: Phi
        Make a copy, leaving it at the same parent.
        Specified by:
        copy in interface Phi
        Returns:
        A copy
      • hasRho

        public boolean hasRho()
        Description copied from interface: Phi
        Returns true if object has bound rho attribute.
        Specified by:
        hasRho in interface Phi
        Returns:
        True if object has rho bound attribute
      • take

        public Phi take​(String name)
        Description copied from interface: Phi
        Take object by name of the attribute.
        Specified by:
        take in interface Phi
        Parameters:
        name - The name of the attribute
        Returns:
        The object
      • put

        public void put​(int pos,
                        Phi obj)
        Description copied from interface: Phi
        Put object by position of the attribute.
        Specified by:
        put in interface Phi
        Parameters:
        pos - The position of the attribute.
        obj - The object to put
      • put

        public void put​(String name,
                        Phi obj)
        Description copied from interface: Phi
        Put object by name of the attribute.
        Specified by:
        put in interface Phi
        Parameters:
        name - The name of the attribute.
        obj - The object to put
      • locator

        public String locator()
        Description copied from interface: Phi
        Get code locator of the phi.
        Specified by:
        locator in interface Phi
        Returns:
        String containing code locator
      • forma

        public String forma()
        Description copied from interface: Phi
        Get forma of the phi.
        Specified by:
        forma in interface Phi
        Returns:
        Forma of it as String.
      • delta

        public byte[] delta()
        Description copied from interface: Data
        Take the data.
        Specified by:
        delta in interface Data
        Returns:
        The data