java.lang.Object
com._1c.g5.v8.dt.internal.platform.services.core.profiles.Profile
All Implemented Interfaces:
IProfile
Direct Known Subclasses:
ProfileDependenciesModule.TestableProfile

public class Profile extends Object implements IProfile
Implementation of IProfile.
  • Field Details

  • Constructor Details

    • Profile

      public Profile(Path location)
      Constructor of Profile.
      Parameters:
      location - the path to profile file in file-system, cannot be null
  • Method Details

    • setValue

      public void setValue(String key, Value value)
      Description copied from interface: IProfile
      Associate a generic Value with the specified key in this profile. Key consist of path to target folder and key name, all splitted with / delimiter.
      Specified by:
      setValue in interface IProfile
      Parameters:
      key - the value key, cannot be null
      value - the value to associate, cannot be null
    • remove

      public void remove(String key)
      Description copied from interface: IProfile
      Removes the value associated with the specified key in this profile, if any. Key consist of path to target folder and key name, all splitted with / delimiter.
      Specified by:
      remove in interface IProfile
      Parameters:
      key - the value key, cannot be null
    • getValue

      public <T extends Value> T getValue(String key)
      Description copied from interface: IProfile
      Returns the generic Value associated with the specified key in this profile. Key consist of path to target folder and key name, all splitted with / delimiter.
      Specified by:
      getValue in interface IProfile
      Parameters:
      key - the value key, cannot be null
      Returns:
      the value or null if the profile has no value associated with key
    • getStringValue

      public String getStringValue(String key)
      Description copied from interface: IProfile
      Returns the string value associated with the specified key in this profile. Key consist of path to target folder and key name, all splitted with / delimiter.

      This is convenience method that executes IProfile.getValue(String) method and extracts actual value.

      Specified by:
      getStringValue in interface IProfile
      Parameters:
      key - the value key, cannot be null
      Returns:
      the value or null if the profile has no value associated with key
    • setStringValue

      public void setStringValue(String key, String value)
      Description copied from interface: IProfile
      Associate a String value with the specified key in this profile. Key consist of path to target folder and key name, all splitted with / delimiter. This is convenience method that wraps actual value and executes IProfile.setValue(String, Value).
      Specified by:
      setStringValue in interface IProfile
      Parameters:
      key - the value key, cannot be null
      value - the value to associate, cannot be null
    • getBooleanValue

      public Boolean getBooleanValue(String key)
      Description copied from interface: IProfile
      Returns the boolean value associated with the specified key in this profile. Key consist of path to target folder and key name, all splitted with / delimiter.

      This is convenience method that executes IProfile.getValue(String) method and extracts actual value.

      Specified by:
      getBooleanValue in interface IProfile
      Parameters:
      key - the value key, cannot be null
      Returns:
      the value or null if the profile has no value associated with key
    • setBooleanValue

      public void setBooleanValue(String key, boolean value)
      Description copied from interface: IProfile
      Associate a boolean value with the specified key in this profile. Key consist of path to target folder and key name, all splitted with / delimiter. This is convenience method that wraps actual value and executes IProfile.setValue(String, Value).
      Specified by:
      setBooleanValue in interface IProfile
      Parameters:
      key - the value key, cannot be null
      value - the value to associate, cannot be null
    • getNumberValue

      public BigDecimal getNumberValue(String key)
      Description copied from interface: IProfile
      Returns the BigDecimal value associated with the specified key in this profile. Key consist of path to target folder and key name, all splitted with / delimiter.

      This is convenience method that executes IProfile.getValue(String) method and extracts actual value.

      Specified by:
      getNumberValue in interface IProfile
      Parameters:
      key - the value key, cannot be null
      Returns:
      the value or null if the profile has no value associated with key
    • setNumberValue

      public void setNumberValue(String key, BigDecimal value)
      Description copied from interface: IProfile
      Associate a BigDecimal value with the specified key in this profile. Key consist of path to target folder and key name, all splitted with / delimiter. This is convenience method that wraps actual value and executes IProfile.setValue(String, Value).
      Specified by:
      setNumberValue in interface IProfile
      Parameters:
      key - the value key, cannot be null
      value - the value to associate, cannot be null
    • flush

      public void flush() throws IOException
      Description copied from interface: IProfile
      Flush the profile. All profile changes will be applied to the underlying resources.
      Specified by:
      flush in interface IProfile
      Throws:
      IOException - if an I/0 error occurred
    • sync

      public void sync() throws IOException
      Description copied from interface: IProfile
      Ensures that future reads from this profile reflect any changes that were saved to the profile resource (from any sourcees - DT IDE or 1C:Enterprise processes) prior to the sync invocation.

      All changes will be cleared.

      Specified by:
      sync in interface IProfile
      Throws:
      IOException - if an I/0 error occurred
    • delete

      public void delete() throws IOException
      Description copied from interface: IProfile
      Delete this profile and underlying resource. Once a profile has been deleted, attempting any method on the corresponding instance will fail with an IllegalStateException.
      Specified by:
      delete in interface IProfile
      Throws:
      IOException - if an I/0 error occurred
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • checkState

      protected void checkState()
      Check current state of the profile.
      Throws:
      IllegalStateException - if state is incorrect
    • readRootFolder

      protected ProfileFolder readRootFolder(Path location) throws IOException
      Reads root folder in the target file-sytem location. Root folder will contain entire folders structure. If file with the given location does not exist, it will be created.
      Parameters:
      location - the path to profile file in file-system, cannot be null
      Throws:
      IOException - if an I/O error occurred during folder read
    • parseKey

      protected Pair<ProfileFolder,String> parseKey(String key, boolean createIfAbsent)
      Parse a profile key into the pofile folder and value key.
      Parameters:
      key - the value key, cannot be null
      createIfAbsent - whether need to create all nonexistent necessary parent folders if absent
      Returns:
      the pair of: profile folder and key or null, if absent and createIfAbsent is false
    • toChild

      protected String toChild(String parentPath, String relativePath)
      Construct path to child folder from the parent folder by its path and relative path.
      Parameters:
      parentPath - the parent path, can be null for root folder
      relativePath - the relative path, cannot be null
      Returns:
      the path to child folder, never null