Methods Summary |
---|
public void | create(java.lang.String aliasName, java.lang.String value)
mMap.put( aliasName, value );
save();
|
public void | delete(java.lang.String aliasName)
mMap.remove( aliasName );
save();
|
public java.lang.String | get(java.lang.String aliasName)
return( (String)mMap.get( aliasName ) );
|
public java.util.Set | getNames()
return( mMap.keySet() );
|
public void | load(java.io.File theFile)
mFilename = theFile.getPath();
final FileReader in = new FileReader( theFile );
while ( true )
{
final String pair = readLine( in );
if ( pair == null )
break;
final int separatorOffset = pair.indexOf( '=" );
final String name = pair.substring( 0, separatorOffset );
final String value = pair.substring( separatorOffset + 1, pair.length() );
create( name, value );
}
in.close();
|
private java.lang.String | readLine(java.io.FileReader in)
StringBuffer buf = new StringBuffer();
while ( true )
{
final int i =in.read();
if ( i < 0 )
{
return( null );
}
final char theChar = (char)i;
if ( theChar == '\n" || theChar == '\r" )
{
// ignore blank lines
if ( buf.length() == 0 )
continue;
break;
}
buf.append( theChar );
}
return( buf.toString() );
|
public void | save()
if ( mFilename != null )
{
save( new File( mFilename ) );
}
|
public void | save(java.io.File theFile)
mFilename = theFile.getPath();
final Set names = getNames();
final Iterator iter = names.iterator();
final String [] pairs = new String [ names.size() ];
for( int i = 0; i < pairs.length; ++i )
{
final String name = (String)iter.next();
pairs[ i ] = name + "=" + get( name );
}
final FileWriter out = new FileWriter( theFile );
for( int i = 0; i < pairs.length; ++i )
{
out.write( pairs[ i ] + "\n" );
}
out.close();
|