Documentation of 'jhplot.io.HFileYAML' Java class.
HFileYAML
jhplot.io

Class HFileYAML



  • public class HFileYAML
    extends java.lang.Object
    Read and write data using YAML Ain't Markup Language using Version 1.2. YAML is a human-friendly, cross language, Unicode based data serialization language designed around the common native data types of agile programming languages. It is broadly useful for programming needs ranging from configuration files to Internet messaging to object persistence to data auditing.

    The data are accumulated in a map and written when you call the method close().

    • Constructor Summary

      Constructors 
      Constructor and Description
      HFileYAML(java.lang.String file)
      Open a YAML file to read objects.
      HFileYAML(java.lang.String file, java.lang.String option)
      Open a YAML file to write or read objects to/from a serialized file in sequential order.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean close()
      Close the file and write the objects as needed.
      void doc()
      Show online documentation.
      int getEntries()
      Get number of processed entries
      java.util.Map<java.lang.String,java.lang.Object> getObjectMap()
      Return objects stored in the form of a map.
      org.yaml.snakeyaml.Yaml getYaml()
      Return Yaml object from the file.
      java.lang.Object read(java.lang.String key)
      Read an object using a key if exits.
      boolean write(java.lang.String key, java.lang.Object ob)
      Add an object using a key.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HFileYAML

        public HFileYAML(java.lang.String file,
                         java.lang.String option)
        Open a YAML file to write or read objects to/from a serialized file in sequential order. If "w" option is set, the old file will be removed. Use close() to flash the buffer and close the file.

        File extension is *.yaml

        You can also insert objects using the keys and read them back. In this case, avoid writing many objects without the keys since the extraction of keys will be very inefficient. Try not mix write/read with keys or without.

        Parameters:
        file - File name
        option - Option to create the file . If "w" - write a file (or read) file, if "r" only read created file.
      • HFileYAML

        public HFileYAML(java.lang.String file)
        Open a YAML file to read objects.
        Parameters:
        file - File name for reading
    • Method Detail

      • getYaml

        public org.yaml.snakeyaml.Yaml getYaml()
        Return Yaml object from the file.
        Returns:
        Yaml object.
      • write

        public boolean write(java.lang.String key,
                             java.lang.Object ob)
        Add an object using a key.
        Parameters:
        key - key to access the object.
        ob - object to be inserted.
        Returns:
        false if the key exits.
      • getObjectMap

        public java.util.Map<java.lang.String,java.lang.Object> getObjectMap()
        Return objects stored in the form of a map.
        Returns:
      • read

        public java.lang.Object read(java.lang.String key)
        Read an object using a key if exits.
        Parameters:
        key -
        Returns:
        returned object.
      • close

        public boolean close()
        Close the file and write the objects as needed.
        Returns:
      • getEntries

        public int getEntries()
        Get number of processed entries
        Returns:
        No of entries
      • doc

        public void doc()
        Show online documentation.

DMelt 3.0 © DataMelt by jWork.ORG