com.phoenix_int.aserver.types
Class PHXRawFileArray

java.lang.Object
  extended by com.phoenix_int.aserver.types.PHXSimpleType
      extended by com.phoenix_int.aserver.types.PHXSimpleArray
          extended by com.phoenix_int.aserver.types.PHXRawFileArray
All Implemented Interfaces:
IPHXType, IPHXType2, IPHXUnits

public class PHXRawFileArray
extends PHXSimpleArray

Wraps an array of PHXRawFile variables for the ScriptWrapper utility.

See Also:
PHXSimpleArray

Field Summary
 
Fields inherited from class com.phoenix_int.aserver.types.PHXSimpleArray
_data, _lockDims, _lockResize
 
Constructor Summary
PHXRawFileArray()
           
PHXRawFileArray(java.lang.Object data)
           
 
Method Summary
protected  void _getMetaData(PHXSimpleType v2)
          Worker which takes the meta data from an instance of PHXSimpleType and sets it into our meta data.
protected  void _setMetaData(PHXSimpleType v2)
          Sets a simple type's meta data based on the meta data in this object.
protected  java.lang.Object allocateElement(java.lang.Class elementClass)
          Allocates a single element in a default state.
protected  boolean dataTypeOK(java.lang.Class c)
          Must override this function and return true if the specified class is acceptable as an array element component type.
protected  java.lang.Object elementFromString(java.lang.String val)
          Sub-classes must provide an implementation of this function which converts a string form of a single element to Object form.
 void fromFile(int index)
          loads the file from disk for an element of an 1D array.
 void fromFile(int[] index)
          loads the file from disk for an element of an array.
 void fromFile(int[] index, java.lang.String fileName)
          Sets the filename and then reads from disk for an element of an array.
 void fromFile(int index, java.lang.String fileName)
          Sets the filename and then reads from disk for an element of an 1D array.
 void fromString(int[] index, java.lang.String value)
          converts a String representation to the internal value for an element of an array
 void fromString(int index, java.lang.String value)
          converts a String representation to the internal value for an element of an 1D array
 java.lang.String getBaseName()
          gets the base name of the files stored in the array
 java.lang.String getContents(int index)
          retrieves the contents of the file for an element of an 1D array
 java.lang.String getContents(int[] index)
          retrieves the contents of the file for an element of an array
 java.lang.String getFileExtension(int index)
          Returns the extension of the file for an element of an 1D array
 java.lang.String getFileExtension(int[] index)
          Returns the extension of the file for an element of an array
 boolean getIsBinary()
          Tells whether or not the array contains binary files or not.
 java.lang.String getMimeType()
          get mime type of the files in the array Currently all elements of an array should have the same mime type.
 java.lang.String getName(int index)
          retrieves the name of the file for an element of an 1D array
 java.lang.String getName(int[] index)
          retrieves the name of the file for an element of an array
 java.lang.String getNameCoded(int index)
          retrieves the name of the file in coded form (without $variables replaced) for an element of an 1D array
 java.lang.String getNameCoded(int[] index)
          retrieves the name of the file in coded form (without $variables replaced) for an element of an array
 java.lang.String[] getNames()
          get file names of the elements as an array
 java.lang.String[] getNamesCoded()
          get coded file names of the elements as an array
 java.lang.String getNamesCodedString()
          get coded file names of the elements as a comma separated string
 java.lang.String getNamesString()
          get file names as a comma separated list
 java.lang.String[] getURLs()
          get URLs of the elements as an array
 java.lang.String getURLsString()
          get URLs of the elements as a comma separated string
 PHXRawFile getValue(int index)
          a utility function to return the internal PHXRawFile that represents the array element for the 1D array.
 PHXRawFile getValue(int[] index)
          a utility function to return the internal PHXRawFile that represents the array element for the array.
 boolean hasChanged(int index)
          checks to see if the file has changed since the last time getContents() was called for an element of an 1D array
 boolean hasChanged(int[] index)
          checks to see if the file has changed since the last time getContents() was called for an element of an array
 void markAsRead(int index)
          set markAsRead flag for an element for an 1D array call this function after you manually get the contents of the file.
 void markAsRead(int[] index)
          set markAsRead flag for an element for an array call this function after you manually get the contents of the file.
 void readFile(int index)
          loads the file from disk for an element of an 1D array.
 void readFile(int[] index)
          loads the file from disk for an element of an array.
 void setBaseName(java.lang.String name)
          sets the base name of files for this array
 void setContents(int[] index, java.lang.String contents)
          sets the contents of the file for an array element for an array.
 void setContents(int index, java.lang.String contents)
          sets the contents of the file for an array element for an 1D array.
 void setFileExtension(int[] index, java.lang.String extension)
          Sets the extension of the file for an element of an array It is preferred that you use setName() and let the system automatically figure out the extension based on what you pass in.
 void setFileExtension(int index, java.lang.String extension)
          Sets the extension of the file for an element of an 1D array It is preferred that you use setName() and let the system automatically figure out the extension based on what you pass in.
 void setIsBinary(boolean value)
          Forces elements of this array to be binary or not.
 void setMimeType(java.lang.String value)
          Set mime type the array Currently all elements of an array should have the same mime type.
 void setName(int[] index, java.lang.String name)
          sets the name of the file for an element of an array
 void setName(int index, java.lang.String name)
          sets the name of the file for an element of an 1D array
 void setValue(int[] index, PHXRawFile val)
          a utility function to set the internal PHXRawFile that represents the array element for the array.
 void setValue(int[] index, java.lang.String val)
          a utility function to set the value of an array element for the 1D array.
 void setValue(int index, PHXRawFile val)
          a utility function to set the internal PHXRawFile that represents the array element for the 1D array.
 void setValue(int index, java.lang.String val)
          a utility function to set the value of an array element for the 1D array.
 void toFile(int index)
          writes the file to disk for an element of an 1D array
 void toFile(int[] index)
          writes the file to disk for an element of an array
 void toFile(int[] index, java.lang.String fileName)
          sets the filename and then writes the file to disk for an element of an array.
 void toFile(int index, java.lang.String fileName)
          sets the filename and then writes the file to disk for an element of an 1D array.
 java.lang.String toString(int index)
          converts an element of the 1D array to a string
 java.lang.String toString(int[] index)
          converts an element of the array to a string
 
Methods inherited from class com.phoenix_int.aserver.types.PHXSimpleArray
_getMetaData, _setMetaData, checkRectangular, fromString, fromString, fromString2, generateFor, generateFor, getArray, getArrayElement, getArrayElement, getComponentType, getComponentType, getDimensions, getDimensions, getFirst, getLength, getLength, getLockResize, getnDIndex, getNumDimensions, getNumDimensions, getSelf, incrementIndex, lockDimensions, newIndex, parseIndex, resize, setArray, setArrayElement, setArrayElement, setDimensions, setFirst, setLength, setLength, setLockResize, toString, toString, toString2, toString2, toString2, validElement
 
Methods inherited from class com.phoenix_int.aserver.types.PHXSimpleType
addPropertyChangeListener, getDescription, getEnumTokens, getHasChanged, getUnits, removePropertyChangeListener, setDescription, setHasChanged, setUnits
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PHXRawFileArray

public PHXRawFileArray()

PHXRawFileArray

public PHXRawFileArray(java.lang.Object data)
Method Detail

getName

public java.lang.String getName(int index)
retrieves the name of the file for an element of an 1D array

Parameters:
index - array index
Returns:
the name of the file

getName

public java.lang.String getName(int[] index)
retrieves the name of the file for an element of an array

Parameters:
index - array index
Returns:
the name of the file

getNameCoded

public java.lang.String getNameCoded(int index)
retrieves the name of the file in coded form (without $variables replaced) for an element of an 1D array

Parameters:
index - array index
Returns:
the name of the file in coded form

getNameCoded

public java.lang.String getNameCoded(int[] index)
retrieves the name of the file in coded form (without $variables replaced) for an element of an array

Parameters:
index - array index
Returns:
the name of the file in coded form

getFileExtension

public java.lang.String getFileExtension(int index)
Returns the extension of the file for an element of an 1D array

Parameters:
index - array index
Returns:
extension

getFileExtension

public java.lang.String getFileExtension(int[] index)
Returns the extension of the file for an element of an array

Parameters:
index - array index
Returns:
extension

setFileExtension

public void setFileExtension(int index,
                             java.lang.String extension)
                      throws java.io.IOException
Sets the extension of the file for an element of an 1D array

It is preferred that you use setName() and let the system automatically figure out the extension based on what you pass in. Then, you can use readFile() and writeFile() without passing filenames to those calls. This allows for progress monitoring to work correctly in all cases.

Parameters:
index - array index
extension - file extension
Throws:
java.io.IOException

setFileExtension

public void setFileExtension(int[] index,
                             java.lang.String extension)
                      throws java.lang.Exception
Sets the extension of the file for an element of an array

It is preferred that you use setName() and let the system automatically figure out the extension based on what you pass in. Then, you can use readFile() and writeFile() without passing filenames to those calls. This allows for progress monitoring to work correctly in all cases.

Parameters:
index - array index
extension - file extension
Throws:
java.lang.Exception

setName

public void setName(int index,
                    java.lang.String name)
             throws java.io.IOException
sets the name of the file for an element of an 1D array

Parameters:
index - array index
name - file name
Throws:
java.io.IOException

setName

public void setName(int[] index,
                    java.lang.String name)
             throws java.lang.Exception
sets the name of the file for an element of an array

Parameters:
index - array index
name - file name
Throws:
java.lang.Exception

setBaseName

public void setBaseName(java.lang.String name)
                 throws java.io.IOException
sets the base name of files for this array

Parameters:
name - base name
Throws:
java.io.IOException

getBaseName

public java.lang.String getBaseName()
gets the base name of the files stored in the array

Returns:
the name

getIsBinary

public boolean getIsBinary()
Tells whether or not the array contains binary files or not. Simply switches on whether or not the mime type starts with text. Currently all elements of an array should have the same binaryness.

Returns:
true if the file is binary

setIsBinary

public void setIsBinary(boolean value)
Forces elements of this array to be binary or not. If this causes the mode to change, will set the mime type to text/plain or application/octet-stream as appropriate. Currently all elements of an array should have the same binaryness.


getMimeType

public java.lang.String getMimeType()
get mime type of the files in the array Currently all elements of an array should have the same mime type.

Returns:
mime type

setMimeType

public void setMimeType(java.lang.String value)
Set mime type the array Currently all elements of an array should have the same mime type.


getNames

public java.lang.String[] getNames()
get file names of the elements as an array

Returns:
list of file names

getNamesString

public java.lang.String getNamesString()
get file names as a comma separated list

Returns:
list of file names

getNamesCoded

public java.lang.String[] getNamesCoded()
get coded file names of the elements as an array

Returns:
list of coded file names

getNamesCodedString

public java.lang.String getNamesCodedString()
get coded file names of the elements as a comma separated string

Returns:
list of coded file names

getURLs

public java.lang.String[] getURLs()
get URLs of the elements as an array

Returns:
list of file URLs

getURLsString

public java.lang.String getURLsString()
get URLs of the elements as a comma separated string

Returns:
list of file URLs

setContents

public void setContents(int index,
                        java.lang.String contents)
                 throws java.io.IOException
sets the contents of the file for an array element for an 1D array. The actual file is not modified until the writeFile() method is issued. Remember that when dealing with text files, setContents handles Java style strings, which must be in bare LF, or Unix style newline format. In binary format, setContents should be the base64 encoded data.

Parameters:
index - array index
contents - the contents of the file
Throws:
java.io.IOException

setContents

public void setContents(int[] index,
                        java.lang.String contents)
                 throws java.lang.Exception
sets the contents of the file for an array element for an array. The actual file is not modified until the writeFile() method is issued. Remember that when dealing with text files, setContents handles Java style strings, which must be in bare LF, or Unix style newline format. In binary format, setContents should be the base64 encoded data.

Parameters:
index - array index
contents - the contents of the file
Throws:
java.lang.Exception

getContents

public java.lang.String getContents(int index)
                             throws java.lang.Exception
retrieves the contents of the file for an element of an 1D array

Parameters:
index - array index
Returns:
the contents of the file
Throws:
java.lang.Exception

getContents

public java.lang.String getContents(int[] index)
                             throws java.lang.Exception
retrieves the contents of the file for an element of an array

Parameters:
index - array index
Returns:
the contents of the file
Throws:
java.lang.Exception

fromFile

public void fromFile(int index)
              throws java.io.IOException
loads the file from disk for an element of an 1D array.

Parameters:
index - array index
Throws:
java.io.IOException - thrown if the file can't be loaded.

fromFile

public void fromFile(int[] index)
              throws java.io.IOException
loads the file from disk for an element of an array.

Parameters:
index - array index
Throws:
java.io.IOException - thrown if the file can't be loaded.

readFile

public void readFile(int index)
              throws java.io.IOException
loads the file from disk for an element of an 1D array.

Parameters:
index - array index
Throws:
java.io.IOException - thrown if the file can't be loaded.

readFile

public void readFile(int[] index)
              throws java.io.IOException
loads the file from disk for an element of an array.

Parameters:
index - array index
Throws:
java.io.IOException - thrown if the file can't be loaded.

fromFile

public void fromFile(int index,
                     java.lang.String fileName)
              throws java.io.IOException
Sets the filename and then reads from disk for an element of an 1D array. It is preferred that you use setName() when you create a PHXRawFile and then use readFile() without passing a filename to it. This allows progress monitoring to work correctly in all cases.

Parameters:
index - array index
fileName - file name
Throws:
java.io.IOException - thrown if the file can't be loaded.

fromFile

public void fromFile(int[] index,
                     java.lang.String fileName)
              throws java.io.IOException
Sets the filename and then reads from disk for an element of an array. It is preferred that you use setName() when you create a PHXRawFile and then use readFile() without passing a filename to it. This allows progress monitoring to work correctly in all cases.

Parameters:
index - array index
fileName - file name
Throws:
java.io.IOException - thrown if the file can't be loaded.

markAsRead

public void markAsRead(int index)
set markAsRead flag for an element for an 1D array call this function after you manually get the contents of the file. The function records it's name and timestamp for use with the hasChanged() function

Parameters:
index - array index

markAsRead

public void markAsRead(int[] index)
set markAsRead flag for an element for an array call this function after you manually get the contents of the file. The function records it's name and timestamp for use with the hasChanged() function

Parameters:
index - array index

hasChanged

public boolean hasChanged(int index)
checks to see if the file has changed since the last time getContents() was called for an element of an 1D array

Parameters:
index - array index
Returns:
true if the timestamp of the file is new, or if the file name has changed

hasChanged

public boolean hasChanged(int[] index)
checks to see if the file has changed since the last time getContents() was called for an element of an array

Parameters:
index - array index
Returns:
true if the timestamp of the file is new, or if the file name has changed

toFile

public void toFile(int index,
                   java.lang.String fileName)
            throws java.io.IOException
sets the filename and then writes the file to disk for an element of an 1D array. It is preferred that you use setName() when you create a PHXRawFile and then use writeFile() without passing a filename to it. This allows progress monitoring to work correctly in all cases.

Parameters:
index - array index
fileName - name of the file to write
Throws:
java.io.IOException - thrown if the file can't be written.

toFile

public void toFile(int[] index,
                   java.lang.String fileName)
            throws java.io.IOException
sets the filename and then writes the file to disk for an element of an array. It is preferred that you use setName() when you create a PHXRawFile and then use writeFile() without passing a filename to it. This allows progress monitoring to work correctly in all cases.

Parameters:
index - array index
fileName - name of the file to write
Throws:
java.io.IOException - thrown if the file can't be written.

toFile

public void toFile(int index)
            throws java.io.IOException
writes the file to disk for an element of an 1D array

Parameters:
index - array index
Throws:
java.io.IOException - thrown if the file can't be written.

toFile

public void toFile(int[] index)
            throws java.io.IOException
writes the file to disk for an element of an array

Parameters:
index - array index
Throws:
java.io.IOException - thrown if the file can't be written.

toString

public java.lang.String toString(int index)
converts an element of the 1D array to a string

Overrides:
toString in class PHXSimpleArray
Parameters:
index - array index
Returns:
a String representation of the variable

toString

public java.lang.String toString(int[] index)
converts an element of the array to a string

Overrides:
toString in class PHXSimpleArray
Parameters:
index - array index
Returns:
a String representation of the variable

fromString

public void fromString(int index,
                       java.lang.String value)
converts a String representation to the internal value for an element of an 1D array

Overrides:
fromString in class PHXSimpleArray
Parameters:
index - array index
value - the value to convert

fromString

public void fromString(int[] index,
                       java.lang.String value)
converts a String representation to the internal value for an element of an array

Overrides:
fromString in class PHXSimpleArray
Parameters:
index - array index
value - the value to convert

getValue

public PHXRawFile getValue(int index)
a utility function to return the internal PHXRawFile that represents the array element for the 1D array.

Parameters:
index - array index
Returns:
array element

getValue

public PHXRawFile getValue(int[] index)
a utility function to return the internal PHXRawFile that represents the array element for the array.

Parameters:
index - array index
Returns:
array element

setValue

public void setValue(int index,
                     PHXRawFile val)
a utility function to set the internal PHXRawFile that represents the array element for the 1D array.

Parameters:
index - array index
val - array element to set

setValue

public void setValue(int[] index,
                     PHXRawFile val)
a utility function to set the internal PHXRawFile that represents the array element for the array.

Parameters:
index - array index
val - array element to set

setValue

public void setValue(int index,
                     java.lang.String val)
              throws java.io.IOException
a utility function to set the value of an array element for the 1D array. This is a synomym of setContent().

Parameters:
index - array index
val - value to set
Throws:
java.io.IOException

setValue

public void setValue(int[] index,
                     java.lang.String val)
              throws java.io.IOException
a utility function to set the value of an array element for the 1D array. This is a synomym of setContent().

Parameters:
index - array index
val - value to set
Throws:
java.io.IOException

dataTypeOK

protected boolean dataTypeOK(java.lang.Class c)
Description copied from class: PHXSimpleArray
Must override this function and return true if the specified class is acceptable as an array element component type.

Specified by:
dataTypeOK in class PHXSimpleArray

elementFromString

protected java.lang.Object elementFromString(java.lang.String val)
Description copied from class: PHXSimpleArray
Sub-classes must provide an implementation of this function which converts a string form of a single element to Object form. This is only used when the element type does not implement IPHXType or IPHXType2. For primitives, return the wrapper objects.

Specified by:
elementFromString in class PHXSimpleArray

_getMetaData

protected void _getMetaData(PHXSimpleType v2)
Description copied from class: PHXSimpleArray
Worker which takes the meta data from an instance of PHXSimpleType and sets it into our meta data. Override this in order to add more custom meta data in sub-classes. Be sure to cal super._getMetaData(PHXSimpleType), though!

Overrides:
_getMetaData in class PHXSimpleArray

_setMetaData

protected void _setMetaData(PHXSimpleType v2)
Description copied from class: PHXSimpleArray
Sets a simple type's meta data based on the meta data in this object. Override this to set additional information in sub-classes. Be sure to call super._setMetaData(PHXSimpleType)

Overrides:
_setMetaData in class PHXSimpleArray

allocateElement

protected java.lang.Object allocateElement(java.lang.Class elementClass)
                                    throws java.lang.IllegalAccessException,
                                           java.lang.InstantiationException
Allocates a single element in a default state. This overrides allocateElement to set the common metadata for the newly created element

Overrides:
allocateElement in class PHXSimpleArray
Throws:
java.lang.IllegalAccessException
java.lang.InstantiationException