Class MetaFile

  • All Implemented Interfaces:
    org.apache.jena.atlas.lib.Closeable, org.apache.jena.atlas.lib.Sync

    public class MetaFile
    extends java.lang.Object
    implements org.apache.jena.atlas.lib.Sync, org.apache.jena.atlas.lib.Closeable
    Abstraction and many convenience operations on metadata. Metadata is recorded in Java properties style - not RDF - because it's relative to the file or context used. Keys and values are always strings.
    • Constructor Summary

      Constructors 
      Constructor Description
      MetaFile​(java.lang.String label, java.lang.String fn)
      Create a MetaFile
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void checkMetadata​(java.lang.String key, java.lang.String expected)
      Check property has the value given - throw exception if not.
      void checkOrSetMetadata​(java.lang.String key, java.lang.String expected)
      Check property is an expected value or set if missing
      void clear()
      Clear all properties.
      void close()  
      void dump​(java.io.PrintStream output)
      Debugging
      void ensurePropertySet​(java.lang.String key, java.lang.String expected)
      Set property if not already set.
      boolean existsMetaData()
      Does this metafile exist on disk? (In-memory MetaFiles always exist)
      void flush()
      Write to backing file if changed
      java.lang.String getFilename()  
      java.lang.String getOrSetDefault​(java.lang.String key, java.lang.String expected)
      Get property or the default value - also set the default value if not present
      java.lang.String getProperty​(java.lang.String key)
      Get the property value or null.
      java.lang.String getProperty​(java.lang.String key, java.lang.String defaultString)
      Get the property value or return supplied default.
      int getPropertyAsInteger​(java.lang.String key)
      Get the property value and parse as an integer
      int getPropertyAsInteger​(java.lang.String key, int defaultValue)
      Get the property value and parse as an integer or return default value.
      java.lang.String[] getPropertySplit​(java.lang.String key)
      Get property as a string and split on ",".
      java.lang.String[] getPropertySplit​(java.lang.String key, java.lang.String defaultString)
      Get property as a string and split on ",", using the default string if not present in the MetaFile.
      boolean hasProperty​(java.lang.String key)
      Test for the presence of a property
      boolean propertyEquals​(java.lang.String key, java.lang.String value)
      Test whether a property has a value.
      void setProperty​(java.lang.String key, int value)
      Set property, turning integer into a string.
      void setProperty​(java.lang.String key, java.lang.String value)
      Set property
      void sync()  
      • Methods inherited from class java.lang.Object

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

      • MetaFile

        public MetaFile​(java.lang.String label,
                        java.lang.String fn)
        Create a MetaFile
        Parameters:
        label - Convenience label.
        fn - On disk filename; Names.memName for in-memory
    • Method Detail

      • existsMetaData

        public boolean existsMetaData()
        Does this metafile exist on disk? (In-memory MetaFiles always exist)
      • getFilename

        public java.lang.String getFilename()
      • hasProperty

        public boolean hasProperty​(java.lang.String key)
        Test for the presence of a property
      • getProperty

        public java.lang.String getProperty​(java.lang.String key)
        Get the property value or null.
      • getProperty

        public java.lang.String getProperty​(java.lang.String key,
                                            java.lang.String defaultString)
        Get the property value or return supplied default.
      • getPropertyAsInteger

        public int getPropertyAsInteger​(java.lang.String key)
        Get the property value and parse as an integer
      • getPropertyAsInteger

        public int getPropertyAsInteger​(java.lang.String key,
                                        int defaultValue)
        Get the property value and parse as an integer or return default value.
      • getPropertySplit

        public java.lang.String[] getPropertySplit​(java.lang.String key)
        Get property as a string and split on ",".
      • getPropertySplit

        public java.lang.String[] getPropertySplit​(java.lang.String key,
                                                   java.lang.String defaultString)
        Get property as a string and split on ",", using the default string if not present in the MetaFile.
      • setProperty

        public void setProperty​(java.lang.String key,
                                java.lang.String value)
        Set property
      • setProperty

        public void setProperty​(java.lang.String key,
                                int value)
        Set property, turning integer into a string.
      • propertyEquals

        public boolean propertyEquals​(java.lang.String key,
                                      java.lang.String value)
        Test whether a property has a value. Null tests equal to not present.
      • ensurePropertySet

        public void ensurePropertySet​(java.lang.String key,
                                      java.lang.String expected)
        Set property if not already set.
      • getOrSetDefault

        public java.lang.String getOrSetDefault​(java.lang.String key,
                                                java.lang.String expected)
        Get property or the default value - also set the default value if not present
      • checkOrSetMetadata

        public void checkOrSetMetadata​(java.lang.String key,
                                       java.lang.String expected)
        Check property is an expected value or set if missing
      • checkMetadata

        public void checkMetadata​(java.lang.String key,
                                  java.lang.String expected)
        Check property has the value given - throw exception if not.
      • clear

        public void clear()
        Clear all properties.
      • flush

        public void flush()
        Write to backing file if changed
      • dump

        public void dump​(java.io.PrintStream output)
        Debugging
      • sync

        public void sync()
        Specified by:
        sync in interface org.apache.jena.atlas.lib.Sync
      • close

        public void close()
        Specified by:
        close in interface org.apache.jena.atlas.lib.Closeable