Changeset 3637
- Timestamp:
- Aug 7, 2007, 11:17:37 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/src/docbook/developerdoc/plugin_developer.xml
r3609 r3637 1778 1778 try 1779 1779 { 1780 ffp.nextSection(); 1780 1781 FlatFileParser.LineType result = ffp.parseHeaders(); 1781 return result != FlatFileParser.LineType.UNKNOWN; 1782 if (result == FlatFileParser.LineType.UNKNOWN) 1783 { 1784 return false; 1785 } 1786 else 1787 { 1788 return isImportable(ffp); 1789 } 1782 1790 } 1783 1791 catch (IOException ex) … … 1937 1945 <listitem> 1938 1946 <para> 1939 Implement the <methodname>Plugin.getAbout()</methodname> and 1940 <methodname>Plugin.getMainType()</methodname> methods. See 1947 Implement the <methodname>Plugin.getAbout()</methodname> method. See 1941 1948 <xref linkend="plugin_developer.api.interfaces.plugin" /> for more information. 1942 1949 </para> … … 2054 2061 ffp.setMinDataColumns(12); 2055 2062 return ffp; 2063 } 2064 </programlisting> 2065 </listitem> 2066 </varlistentry> 2067 2068 <varlistentry> 2069 <term> 2070 <methodsynopsis language="java"> 2071 <modifier>protected</modifier> 2072 <type>boolean</type> 2073 <methodname>isImportable</methodname> 2074 <methodparam> 2075 <type>FlatFileParser</type> 2076 <parameter>ffp</parameter> 2077 </methodparam> 2078 <exceptionname>IOException</exceptionname> 2079 </methodsynopsis> 2080 </term> 2081 <listitem> 2082 <para> 2083 This method is called from the <methodname>isImportable(InputStream)</methodname> 2084 method, AFTER <methodname>FlatFileParser.nextSection()</methodname> and 2085 <methodname>FlatFileParser.parseHeaders()</methodname> has been called 2086 a single time and if the <methodname>parseHeaders</methodname> method didn't 2087 stop on an unknown line. The default implementation of this method always returns 2088 TRUE, since obviously some data has been found. A subclass may override this method 2089 if it wants to do more checks, for example, make that a certain header is present 2090 with a certain value. It may also continut parsing the file. Here is a code example from 2091 the <classname>PrintMapFlatFileImporter</classname> which checks if a 2092 <constant>FormatName</constant> header is present and contains either 2093 <constant>TAM</constant> or <constant>MwBr</constant>. 2094 </para> 2095 2096 <programlisting> 2097 /** 2098 Check that the file is a TAM or MwBr file. 2099 @return TRUE if a FormatName header is present and contains "TAM" or "MwBr", FALSE 2100 otherwise 2101 */ 2102 @Override 2103 protected boolean isImportable(FlatFileParser ffp) 2104 { 2105 String formatName = ffp.getHeader("FormatName"); 2106 return formatName != null && 2107 (formatName.contains("TAM") || formatName.contains("MwBr")); 2056 2108 } 2057 2109 </programlisting> -
trunk/src/plugins/core/net/sf/basedb/plugins/AbstractFlatFileImporter.java
r3626 r3637 493 493 FlatFileParser ffp = getInitializedFlatFileParser(); 494 494 ffp.setInputStream(in, getCharset()); 495 ffp.setDefaultNumberFormat(getNumberFormat()); 495 496 try 496 497 { 498 ffp.nextSection(); 497 499 FlatFileParser.LineType result = ffp.parseHeaders(); 498 return result != FlatFileParser.LineType.UNKNOWN; 500 if (result == FlatFileParser.LineType.UNKNOWN) 501 { 502 return false; 503 } 504 else 505 { 506 return isImportable(ffp); 507 } 499 508 } 500 509 catch (IOException ex) … … 657 666 658 667 /** 668 This method is called by the {@link #isImportable(InputStream)} method after 669 {@link FlatFileParser#nextSection()} and {@link FlatFileParser#parseHeaders()} 670 has been called and if data has been found. Thus, the default implementation of this 671 method always returns TRUE. Subclasses may override this method to do more checks, for 672 example to make sure certain headers are present or parse more data from the file. 673 674 @param ffp The FlatFileParser object used to parse the file 675 @return Always TRUE 676 @since 2.4 677 */ 678 protected boolean isImportable(FlatFileParser ffp) 679 throws IOException 680 { 681 return true; 682 } 683 684 /** 659 685 Called just before parsing of the file begins. A subclass 660 686 may override this method if it needs to initialise some -
trunk/src/plugins/core/net/sf/basedb/plugins/IlluminaRawDataImporter.java
r3626 r3637 321 321 } 322 322 323 /** 324 Check that the first line contains the text "Illumina" 325 @return TRUE if the first line contains "Illumina", FALSE 326 otherwise 327 */ 328 @Override 329 protected boolean isImportable(FlatFileParser ffp) 330 { 331 String firstLine = ffp.getLineCount() >= 1 ? ffp.getLine(0).line() : null; 332 return firstLine != null && firstLine.contains("Illumina") ; 333 } 323 334 324 335 @Override -
trunk/src/plugins/core/net/sf/basedb/plugins/PrintMapFlatFileImporter.java
r3628 r3637 275 275 ------------------------------------------- 276 276 */ 277 /** 278 Check that the file is a TAM or MwBr file. 279 @return TRUE if a FormatName header is present and contains "TAM" or "MwBr", FALSE 280 otherwise 281 */ 282 @Override 283 protected boolean isImportable(FlatFileParser ffp) 284 { 285 String formatName = ffp.getHeader("FormatName"); 286 return formatName != null && (formatName.contains("TAM") || formatName.contains("MwBr")); 287 } 277 288 278 289 /**
Note: See TracChangeset
for help on using the changeset viewer.