\r
try\r
{\r
-\r
BufferedReader in = null;\r
- try{\r
- URL url = new URL(file);\r
- in = new BufferedReader(new InputStreamReader(url.openStream()));\r
+ java.io.InputStream is = getClass().getResourceAsStream("/" + file);\r
+ if (is != null)\r
+ {\r
+ in = new BufferedReader(new java.io.InputStreamReader(is));\r
}\r
- catch(java.net.MalformedURLException ex)\r
+ else\r
{\r
- in = new BufferedReader(new FileReader(file));\r
+ try\r
+ {\r
+ URL url = new URL(file);\r
+ in = new BufferedReader(new InputStreamReader(url.openStream()));\r
+ }\r
+ catch (java.net.MalformedURLException ex)\r
+ {\r
+ in = new BufferedReader(new FileReader(file));\r
+ }\r
}\r
\r
-\r
String line, label, description, token;\r
int graphStyle, index;\r
SequenceI refSeq = null;\r
formats.addElement("PFAM");\r
}\r
\r
+\r
+ public static String FILE = "File";\r
+ public static String URL = "URL";\r
+ public static String PASTE = "Paste";\r
+ public static String CLASSLOADER = "ClassLoader";\r
+\r
AlignFile afile = null;\r
\r
/**\r
afile = new PfamFile(inFile, type);\r
}\r
\r
+\r
return afile.getSeqsAsArray();\r
}\r
catch (Exception e)\r
public class FileParse\r
{\r
public File inFile;\r
- public int fileSize;\r
- public int noLines;\r
protected String type;\r
protected BufferedReader dataIn;\r
\r
{\r
this.type = type;\r
\r
- if (type.equals("File"))\r
+ if (type.equals(AppletFormatAdapter.FILE))\r
{\r
this.inFile = new File(fileStr);\r
- this.fileSize = (int) inFile.length();\r
-\r
dataIn = new BufferedReader(new FileReader(fileStr));\r
}\r
- else if (type.equals("URL"))\r
+ else if (type.equals(AppletFormatAdapter.URL))\r
{\r
URL url = new URL(fileStr);\r
- this.fileSize = 0;\r
dataIn = new BufferedReader(new InputStreamReader(url.openStream()));\r
}\r
- else if (type.equals("Paste"))\r
+ else if (type.equals(AppletFormatAdapter.PASTE))\r
{\r
dataIn = new BufferedReader(new StringReader(fileStr));\r
}\r
+ else if (type.equals(AppletFormatAdapter.CLASSLOADER))\r
+ {\r
+ java.io.InputStream is = getClass().getResourceAsStream("/" + fileStr);\r
+ if (is != null)\r
+ {\r
+ dataIn = new BufferedReader(new java.io.InputStreamReader(is));\r
+ }\r
+ }\r
}\r
\r
public String nextLine()\r
throws IOException\r
{\r
- String next = dataIn.readLine();\r
-\r
- if (next != null)\r
- {\r
- noLines++;\r
- }\r
-\r
- return next;\r
+ return dataIn.readLine();\r
}\r
}\r
*\r
* @return DOCUMENT ME!\r
*/\r
- public static String Identify(String file, String protocol)\r
+ public String Identify(String file, String protocol)\r
{\r
String reply = "PFAM";\r
String error = "FILE NOT FOUND";\r
-\r
try\r
{\r
BufferedReader reader = null;\r
\r
- if (protocol.equalsIgnoreCase("File"))\r
+ if (protocol.equals(AppletFormatAdapter.FILE))\r
{\r
- reader = new BufferedReader(new FileReader(file));\r
+ reader = new BufferedReader(new FileReader(file));\r
}\r
- else if (protocol.equalsIgnoreCase("URL"))\r
+ else if (protocol.equals(AppletFormatAdapter.URL))\r
{\r
- error = "URL NOT FOUND";\r
- URL url = new URL(file);\r
- reader = new BufferedReader(new InputStreamReader(\r
- url.openStream()));\r
+ error = "URL NOT FOUND";\r
+ URL url = new URL(file);\r
+ reader = new BufferedReader(new InputStreamReader(\r
+ url.openStream()));\r
\r
}\r
- else if (protocol.equalsIgnoreCase("Paste"))\r
+ else if (protocol.equals(AppletFormatAdapter.PASTE))\r
+ {\r
+ reader = new BufferedReader(new StringReader(file));\r
+ }\r
+ else if (protocol.equals(AppletFormatAdapter.CLASSLOADER))\r
{\r
- reader = new BufferedReader(new StringReader(file));\r
+ java.io.InputStream is = getClass().getResourceAsStream("/" +\r
+ file);\r
+ reader = new BufferedReader(new java.io.InputStreamReader(is));\r
}\r
\r
String data;\r