net.aerith.misao.catalog.io
Class FileReader

java.lang.Object
  |
  +--net.aerith.misao.catalog.io.CatalogReader
        |
        +--net.aerith.misao.catalog.io.FileReader
Direct Known Subclasses:
AstrometricaReader, Bsc5Reader, CgcsReader, CgoReader, CssReader, ExtraGalacticReader, GcssReader, Gcvs2000Reader, GcvsReader, GspcReader, HicReader, HipparcosReader, IrasFscReader, IrasPscReader, LandoltReader, LoneosPhotometryReader, McgReader, MisVReader, MpcFormatReader, Msx5cReader, MsxReader, NewvarReader, Ngc2000Reader, NsvReader, NsvSupplementReader, PgcReader, SampleReader, SaoReader, StmReader, SupernovaReader, TychoReader, UgcReader, WrReader

public class FileReader
extends CatalogReader

The FileReader is a base class to read a star catalog file. It has a method createStar to create a CatalogStar object from one line record of the file, which must be overrided in the subclasses.

When the filename ends with ".gz" suffix, it opens the file through GZIPInputStream.

The (x,y) position is also set properly so that (0,0) represents the specified R.A. and Decl. to open method and (1,1) represents the position 1 deg to the west and 1 deg to the north.


Field Summary
protected  CircumArea circum_area
          The circum area to read stars.
protected  long current_block
          The index of the current block.
protected  long current_index
          The index of the star in the current block.
protected  java.io.BufferedReader reader
          The input stream reader.
 
Fields inherited from class net.aerith.misao.catalog.io.CatalogReader
center_coor, date, limiting_mag, url_set
 
Constructor Summary
protected FileReader()
          Constructs an empty FileReader.
 
Method Summary
 void close()
          Closes a catalog.
 CatalogStar createStar(java.lang.String record)
          Creates a CatalogStar object from the specified one line record in the file.
 long getBlockCount()
          Gets the number of blocks in a file.
 long getBlockSize()
          Gets the number of records in a block.
 java.lang.String getName()
          Gets the catalog name.
 long getRecordSize()
          Gets the characters of a record.
 boolean isFile()
          Checks if the catalog data is a file.
 void open(Coor coor, double fov)
          Opens a catalog.
 boolean overlapsBlock()
          Checks if the current block is overlapping on the specified circum area.
 CatalogStar readNext()
          Reads one data from the opened catalog.
 
Methods inherited from class net.aerith.misao.catalog.io.CatalogReader
addURL, getDateLimit, getDateLimitMessage, getFovLimit, getFovLimitMessage, getHelpMessage, getMaximumPositionErrorInArcsec, hasDateLimit, hasFovLimit, isDateDependent, isInDirectory, open, read, setDate, setDefaultURL, setLimitingMagnitude, supportsExamination
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

reader

protected java.io.BufferedReader reader
The input stream reader.

circum_area

protected CircumArea circum_area
The circum area to read stars.

current_block

protected long current_block
The index of the current block.

current_index

protected long current_index
The index of the star in the current block.
Constructor Detail

FileReader

protected FileReader()
Constructs an empty FileReader.
Method Detail

getName

public java.lang.String getName()
Gets the catalog name. It must be unique among all subclasses.
Overrides:
getName in class CatalogReader
Returns:
the catalog name.

isFile

public boolean isFile()
Checks if the catalog data is a file.
Overrides:
isFile in class CatalogReader
Returns:
true if the catalog data is a file.

createStar

public CatalogStar createStar(java.lang.String record)
Creates a CatalogStar object from the specified one line record in the file. If some more records are required to create a star object, it returns null. This method must be overrided in the subclasses.
Parameters:
record - the one line record in the file.
Returns:
the star object.

open

public void open(Coor coor,
                 double fov)
          throws java.io.IOException,
                 java.io.FileNotFoundException,
                 CdromNotFoundException
Opens a catalog. This method must be invoked at first.
Overrides:
open in class CatalogReader
Parameters:
coor - the R.A. and Decl. of the center.
fov - the field of view to read in degree.
Throws:
java.io.IOException - if a file cannot be accessed.
java.io.FileNotFoundException - if a file does not exists in any URL, and the file is in any CD-ROMs.
CdromNotFoundException - if a file does not exists in any URL, and the file is in a CD-ROM.

readNext

public CatalogStar readNext()
                     throws java.io.IOException,
                            java.io.FileNotFoundException,
                            CdromNotFoundException,
                            QueryFailException
Reads one data from the opened catalog. After this method is invoked, the cursor is promoted to tne next star. When every data is read, it returns null.

The check of the R.A. and Decl. is also judged in this method, however, no check of magnitude is judged because some catalog stars have no significant magnitude. subclasses.

Overrides:
readNext in class CatalogReader
Returns:
a star data.
Throws:
java.io.IOException - if a file cannot be accessed.
java.io.FileNotFoundException - if a file does not exists in any URL, and the file is in any CD-ROMs.
CdromNotFoundException - if a file does not exists in any URL, and the file is in a CD-ROM.
QueryFailException - if the query to the server is failed.

close

public void close()
           throws java.io.IOException
Closes a catalog. This method must be invoked finally.
Overrides:
close in class CatalogReader
Throws:
java.io.IOException - if a file cannot be accessed.

getBlockCount

public long getBlockCount()
Gets the number of blocks in a file. If 0, it means the file is not separated into blocks. It must be overrided in the subclasses if neccessary.
Returns:
the size of a block.

getBlockSize

public long getBlockSize()
Gets the number of records in a block. If 0, it means the file is not separated into blocks. It must be overrided in the subclasses if neccessary.
Returns:
the size of a block.

getRecordSize

public long getRecordSize()
Gets the characters of a record. If 0, it means the record size is not constant, so the reader skips the specified lines while reading one line by one. Otherwise, the reader skips the specified characters at one time. It must be overrided in the subclasses if neccessary.
Returns:
the size of a record.

overlapsBlock

public boolean overlapsBlock()
Checks if the current block is overlapping on the specified circum area.
Returns:
true if the current block is overlapping on the specified circum area.