public class FileName extends TrianaType implements AsciiComm
The motivation behind this class is to deal simply with these two file types so that triana can import data from the internet as transparently as a local disk file. These are the only real protocols we use. I'm sure there are others but we've not included them here.
Modifier and Type | Field and Description |
---|---|
static int |
HTTP |
static int |
INVALID |
static int |
LOCAL |
NOT_CONNECTED, NOT_READY, OUT_OF_RANGE
Constructor and Description |
---|
FileName()
Creates a new empty FileName.
|
FileName(java.io.File fn)
Creates a new FileName from another File object
|
FileName(java.lang.String fn)
Creates a new FileName from a string containing the full path and name of the file.
|
FileName(java.lang.String path,
java.lang.String fn)
Creates a new FileName from a string containing the specified path and name of the file.
|
FileName(java.net.URL url) |
Modifier and Type | Method and Description |
---|---|
void |
add(FileName fn)
Adds the filename to the list of filenames.
|
void |
copyData(TrianaType source)
This method does nothing here, but is required by TrianaType.
|
TrianaType |
copyMe()
This is one of the most important methods of Triana data.
|
void |
copyParameters(TrianaType source)
Method to copy the data for this class.
|
boolean |
equals(java.lang.Object fn)
This function returns true if the specified object fn is the same type and has the same contents as
this object
|
FileName |
get(int i)
Gets the ith filename in this list of filenames.
|
java.lang.String |
getDocumentTitle() |
java.lang.String |
getFile() |
java.lang.String |
getFileNoPath()
Returns a reference to this FileName not including any path information
|
int |
getFileType() |
static java.lang.String |
getHTMLTitle(java.lang.String fn) |
int[] |
getLineNumbers()
Gets the line number within this file
|
java.lang.String |
getPath()
Returns a reference to the path of this file name
|
boolean |
hasMultiple() |
void |
inputFromStream(java.io.BufferedReader dis)
This function is used when Triana types want to be able to receive ASCII data from the output of other programs.
|
static boolean |
isHTTP(java.lang.String file) |
void |
outputToStream(java.io.PrintWriter dos)
This function is used when Triana types want to be able to send their data via an output stream to other programs
using strings.
|
void |
setFile(java.lang.String file)
Sets the file to the given string and works out if its a HTTP address or not
|
void |
setLineNumbers(int[] ln)
Sets the interesting line numbers within the file which units can use to display the file at the appropriate
place.
|
int |
size()
Gets the number of filenames in list filenames.
|
java.lang.String |
toString() |
protected void |
updateObsoletePointers() |
containerSize, dataExists, deleteFromContainer, getDataContainer, getFromContainer, getSequenceNumber, insertIntoContainer, inspectDataContainer, setDataContainer, setSequenceNumber
public static final int INVALID
public static final int LOCAL
public static final int HTTP
public FileName()
public FileName(java.lang.String fn)
fn
- the full path and name of file.public FileName(java.lang.String path, java.lang.String fn)
path
- the full path.fn
- name of file.public FileName(java.io.File fn)
fn
- a file object representing the file.public FileName(java.net.URL url)
public void add(FileName fn)
public boolean hasMultiple()
public FileName get(int i)
public int size()
public void setLineNumbers(int[] ln)
public int[] getLineNumbers()
public static boolean isHTTP(java.lang.String file)
public void setFile(java.lang.String file)
public java.lang.String getFile()
public java.lang.String getDocumentTitle()
public static java.lang.String getHTMLTitle(java.lang.String fn)
public java.lang.String getFileNoPath()
public java.lang.String getPath()
public int getFileType()
public boolean equals(java.lang.Object fn)
equals
in class java.lang.Object
public TrianaType copyMe()
TrianaType
To override, the programmer should not invoke the super.copyMe method. Instead, create an object of the current type and call methods copyData and copyParameters. If these have been written correctly, then they will do the copying. The code should createTool, for type YourType:
YourType y = null; try { y = (YourType)getClass().newInstance(); y.copyData( this ); y.copyParameters( this ); y.setLegend( this.getLegend() ); } catch (IllegalAccessException ee) { System.out.println("Illegal Access: " + ee.getMessage()); } catch (InstantiationException ee) { System.out.println("Couldn't be instantiated: " + ee.getMessage()); } return y;
The copied object's data should be identical to the original. The method here modifies only one item: a String indicating that the object was created as a copy is added to the description StringVector.
copyMe
in class TrianaType
TrianaType.copyMe()
public void copyData(TrianaType source)
copyData
in class TrianaType
source
- The object being copied frompublic void copyParameters(TrianaType source)
copyParameters
in class TrianaType
source
- The object being copied frompublic void outputToStream(java.io.PrintWriter dos) throws java.io.IOException
This method must be overridden in every subclass that defines new data or parameters. The overriding method should first call
super.outputToStream(dos)to get output from superior classes, and then new parameters defined for the current subclass must be output. Moreover, subclasses that first dimension their data arrays must explicitly transfer these data arrays.
outputToStream
in interface AsciiComm
dos
- The data output streamjava.io.IOException
public void inputFromStream(java.io.BufferedReader dis) throws java.io.IOException
This method must be overridden in every subclass that defines new data or parameters. The overriding method should first call
super.inputFromStream(dis)to get input from superior classes, and then new parameters defined for the current subclass must be input. Moreover, subclasses that first dimension their data arrays must explicitly transfer these data arrays.
inputFromStream
in interface AsciiComm
dis
- The data input streamjava.io.IOException
protected void updateObsoletePointers()
updateObsoletePointers
in class TrianaType
public java.lang.String toString()
toString
in class java.lang.Object