com.ptc.windchill.cadx.common.preference
Class ParamPropReader

java.lang.Object
  extended bycom.ptc.windchill.cadx.common.preference.ParamPropReader
Direct Known Subclasses:
UserPrefReader

public class ParamPropReader
extends Object


Nested Class Summary
 class ParamPropReader.SectionProperties
           
 
Field Summary
private  BufferedReader buf
           
static String comment
           
private  String currentSectionName
           
private  ParamPropReader.SectionProperties currentStore
           
(package private) static boolean debug
           
private  boolean dirty
           
private  Hashtable hash
           
private  String location
           
private  String locationOld
           
private  String locationTmp
           
private  File origFile
          This method can be used to write the correct properties object at its "location" (provided write permissions are available).
private static String RESOURCE
           
private  Vector secReadSeq
           
private static String space
           
private  File tmpFile
          This method can be used to write the correct properties object at its "location" (provided write permissions are available).
 
Constructor Summary
ParamPropReader(InputStream stream, URL loc)
           
ParamPropReader(String loc)
          constructor where empty reader is created
ParamPropReader(URL loc)
           
 
Method Summary
 void addParameter(String key, String val, String section)
           
private  String checkSectionName(String sec)
           
private  File createBackUp()
          This method a backup copy of the original $datasource.ini file in $datasource.ini.old and returns a file handle for $datasource.ini.old.
 void deleteParameter(String key, String val, String section)
           
private  void deleteTmpFile(File file)
          This method deletes the file passed to it, catching any security exceptions and displaying an error message if the exception is caught.
 void dump()
           
 String[] getAllSectionKeyVals(String secName)
           
private  String getLocationOld()
           
private  OutputStream getOutputStream(String urlLoc)
           
 String getPropValue(String key)
           
 String getPropValueFromSection(String key, String secName)
           
 Enumeration getSectionKeys(String secName)
           
 Enumeration getSections()
           
private  void processLine(String line)
          The file is in ini file format hence data is arranged as Sections and key value pairs like following example [file] IniName=User:shaijosh [explorer] mode=gmode registry_port=2009 registry_server=santoor ....
private  void readProperties()
          the readProperties() method is also state defined as follows: readState: Condition (entry from state) 0 : initialized 1 : started default section (0) 2 : readKeyValue (1, 3) 3 : got new Section (2)
private  void recoverOrigFile()
          This method copies the backup of the original $datasource.ini file, $datasource.ini.old, to $datasource.ini.
 void save(File file, File origFile)
           
 boolean writeIniFile()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

static final boolean debug
See Also:
Constant Field Values

buf

private BufferedReader buf

hash

private Hashtable hash

secReadSeq

private Vector secReadSeq

currentStore

private ParamPropReader.SectionProperties currentStore

currentSectionName

private String currentSectionName

location

private String location

locationOld

private String locationOld

locationTmp

private String locationTmp

dirty

private boolean dirty

comment

public static final String comment
See Also:
Constant Field Values

space

private static final String space
See Also:
Constant Field Values

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

origFile

private File origFile
This method can be used to write the correct properties object at its "location" (provided write permissions are available).


tmpFile

private File tmpFile
This method can be used to write the correct properties object at its "location" (provided write permissions are available).

Constructor Detail

ParamPropReader

public ParamPropReader(URL loc)
                throws IOException

ParamPropReader

public ParamPropReader(String loc)
constructor where empty reader is created


ParamPropReader

public ParamPropReader(InputStream stream,
                       URL loc)
Method Detail

addParameter

public void addParameter(String key,
                         String val,
                         String section)

deleteParameter

public void deleteParameter(String key,
                            String val,
                            String section)

readProperties

private void readProperties()
                     throws IOException
the readProperties() method is also state defined as follows: readState: Condition (entry from state) 0 : initialized 1 : started default section (0) 2 : readKeyValue (1, 3) 3 : got new Section (2)

Throws:
IOException

checkSectionName

private String checkSectionName(String sec)

processLine

private void processLine(String line)
The file is in ini file format hence data is arranged as Sections and key value pairs like following example [file] IniName=User:shaijosh [explorer] mode=gmode registry_port=2009 registry_server=santoor .... ; Comment starts with `;` and the line is ignored following it


getPropValue

public String getPropValue(String key)

getPropValueFromSection

public String getPropValueFromSection(String key,
                                      String secName)

getSections

public Enumeration getSections()

getSectionKeys

public Enumeration getSectionKeys(String secName)

getAllSectionKeyVals

public String[] getAllSectionKeyVals(String secName)

dump

public void dump()

writeIniFile

public boolean writeIniFile()
                     throws IOException
Throws:
IOException

save

public void save(File file,
                 File origFile)

createBackUp

private File createBackUp()
                   throws IOException
This method a backup copy of the original $datasource.ini file in $datasource.ini.old and returns a file handle for $datasource.ini.old.

Throws:
IOException

deleteTmpFile

private void deleteTmpFile(File file)
                    throws IOException
This method deletes the file passed to it, catching any security exceptions and displaying an error message if the exception is caught.

Throws:
IOException

recoverOrigFile

private void recoverOrigFile()
                      throws IOException
This method copies the backup of the original $datasource.ini file, $datasource.ini.old, to $datasource.ini. If $datasource.ini exists then no copy occurs.

Throws:
IOException

getOutputStream

private OutputStream getOutputStream(String urlLoc)

getLocationOld

private String getLocationOld()