Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/flexstor/flexdbserver/services/asset/OPITypesDat.java


1   /*
2    * OPITypesDat.java
3    *
4    * Copyright $Date: 2003/08/11 02:22:28 $ FLEXSTOR.net Inc.
5    *
6    * This work is licensed for use and distribution under license terms found at
7    * http://www.flexstor.org/license.html
8    *
9    */
10  
11  package com.flexstor.flexdbserver.services.asset;
12  
13  import java.util.Vector;
14  
15  import com.flexstor.common.importprocessor.TextFile;
16  
17  
18  /**
19  *
20  *
21  */
22  public class OPITypesDat extends TextFile
23  {
24    protected Vector vFileData = null;
25    
26    /**
27    *
28    * @param sFile The path and name of the text file containing the opi/types
29    */
30    public OPITypesDat(String sFile)
31    {
32      super(sFile);
33      
34      vFileData = new Vector();  
35      
36      copyToVector();
37    } // constructor
38      
39      
40    /**
41    *
42    * @param sOpiType The OPI type to search for
43    * @param sAssetType The asset type to search for
44    * @return True if the asset type specified was found in the Opi section specified
45    */
46    public boolean isTypeSupported(String sOpiType, String sAssetType)
47    {
48      if ((vFileData == null) || (vFileData.size() == 0))
49      {
50        return false;  
51      }
52      
53      boolean bSectionFound = false;
54      for (int i=0; i<vFileData.size(); i++)
55      {
56        // Get the next text line
57        String sLine = (String)vFileData.elementAt(i);
58        if (sLine.equals("") == false)
59        {
60          // Determine if this line is a section header
61          String sSection = checkForSection(sLine);
62          
63          if (sSection != null)
64          {          
65            // The line is a section header
66            if (bSectionFound == true)
67            {
68              // The specified section was already found, so this section header
69              // must indicate the end of the section and the type was not found in it
70              return false;
71            }
72          
73            // Is this the specified section name?
74            if (sSection.trim().equalsIgnoreCase(sOpiType) == true)
75            {
76              bSectionFound = true;
77            }          
78          } // sSection != null if
79        
80          else
81          {
82            // The line is not a section header, so it must be a file type
83            // Only check it if we are in the appropriate section
84            if ((bSectionFound == true) && (sLine.trim().equalsIgnoreCase(sAssetType) == true) )
85            {
86              return true;   
87            }
88          } // sSection != null else
89        } // sLine = "" if    
90      } // for
91      
92    // The vector was traversed without premature exit meaning that
93    // neither the file type or the section header were found
94    return false;
95    } // isTypeSupported
96  
97    /**
98    *
99    *
100   */
101   protected boolean copyToVector()
102     {
103     if (this.streamOK() == false)
104       {
105       return false;
106       }
107     
108     // Read each line & put it in the vector
109     while(true)
110       {
111       // Get the next line
112       String sLine = this.getLine();
113        if (this.readOK() == false)
114         {
115         this.close();
116         return false;
117         }          
118  
119       // Check for EOF
120       if (sLine == null)
121         {
122         this.close();
123         return true;
124         }
125         
126       // Put the line in the vector
127       vFileData.addElement(sLine);
128       
129       } // while
130     } // copyToVector
131 
132 
133 
134 } // OPITypesDat