edu.uky.rch.ept.data
Interface ITextAccessMethods

All Known Subinterfaces:
IDataAccessMethods, IDataSourceDriver
All Known Implementing Classes:
DataFactory, DataSourceDriver, Project, Repository

public interface ITextAccessMethods

This interface defines all the text data access methods. Wherever addresses are involved in creating new resources, all non-existing collections in the specified path to the resource will be created automatically.

All the methods throw the following exceptions:

Author:
Sandeep Bodapati

Method Summary
 String getText(String address, int beginIndex, int endIndex)
          Retrieves the specified text data from the resource at the given address.
 void insertText(String address, int atIndex, String newContent)
          Inserts the new text content into the resource starting at the index specified.
 void replaceText(String address, int beginIndex, int endIndex, String newContent)
          Replaces the specified text with the new content.
 boolean storeText(String address, String content, boolean force)
          Creates a new text resource and writes the given content into it.
 

Method Detail

getText

public String getText(String address,
                      int beginIndex,
                      int endIndex)
               throws MalformedAddressException,
                      ResourceNotFoundException,
                      IndexOutOfBoundsException,
                      IOException
Retrieves the specified text data from the resource at the given address. The text data is read starting from the beginIndex to the character at index endIndex-1. Thus the length of the substring returned is endIndex-beginIndex. If endIndex is EOF, then the contents will be read till the end of the resource.

Parameters:
address - address of the resource
beginIndex - the beginning index, inclusive.
endIndex - the endIndex, exclusive.
Returns:
the specified text data from the resource
Throws:
ResourceNotFoundException - if the resource doesnt exist
IndexOutOfBoundsException - if the beginIndex is negative, or beginIndex is larger than endIndex and endIndex is not EOF.
MalformedAddressException
IOException

storeText

public boolean storeText(String address,
                         String content,
                         boolean force)
                  throws MalformedAddressException,
                         IOException
Creates a new text resource and writes the given content into it.

Parameters:
address - the address of the resource
content - the data to be written
force - if true then the resource is overwritten if it already exists
Returns:
true if the resource did not exist and was created successfully, false otherwise
Throws:
MalformedAddressException
IOException

insertText

public void insertText(String address,
                       int atIndex,
                       String newContent)
                throws MalformedAddressException,
                       ResourceNotFoundException,
                       IndexOutOfBoundsException,
                       IOException
Inserts the new text content into the resource starting at the index specified. If atIndex is greater than the length of the resource or is EOF, the new text will be appended to the resource

Parameters:
address - the address of the resource
atIndex - offset from the beginning of the resource
newContent - text to be inserted
Throws:
ResourceNotFoundException - if the resource doesnt exist
IndexOutOfBoundsException - if the atIndex is negative and not EOF
MalformedAddressException
IOException

replaceText

public void replaceText(String address,
                        int beginIndex,
                        int endIndex,
                        String newContent)
                 throws MalformedAddressException,
                        ResourceNotFoundException,
                        IndexOutOfBoundsException,
                        IOException
Replaces the specified text with the new content. The text that is replaced starts from beginIndex and ends at endIndex-1. If endIndex is EOF, then the text till the end of the resource will be replaced.

Parameters:
address - address of the resource
beginIndex - beginning index, inclusive
endIndex - end index, exclusive
newContent - new content to replace the text
Throws:
ResourceNotFoundException - if the resource doesnt exist
IndexOutOfBoundsException - if the beginIndex is negative, or beginIndex is larger than endIndex and endIndex is not EOF.
MalformedAddressException
IOException