net.quartzware
Class ResBundle

java.lang.Object
  |
  +--net.quartzware.ResBundle
All Implemented Interfaces:
RBListener

public class ResBundle
extends java.lang.Object
implements RBListener

Encapsulates the data and functions of a 'resource bundle'.


Constructor Summary
ResBundle(Entry[] entries, java.lang.String suffix, java.io.File file, boolean loose)
          Constructs a ResBundle from the given array of entries
ResBundle(java.lang.String suffix, java.io.File file, boolean loose)
          Default Constructor PRE: none POST: This class is created
ResBundle(java.lang.String suffix, java.io.File file, boolean loose, boolean unique)
          Constructs a ResBundle from the given vector of entries
 
Method Summary
 void addEntry(Entry ent)
          Adds a new key to this ResBundle
 void addRBListener(RBListener list)
          Adds a listener.
 void doSetup()
          Perform setup that is required regardless of the constructor that was used.
 void entryAdded(RBEvent rbe)
           
 void entryChanged(RBEvent rbe)
          Called when one of my parent's entries was changed.
 void entryInserted(RBEvent rbe)
           
 void entryRemoved(RBEvent rbe)
           
 void fireEntryAdded(Entry ent, int index)
          fires an update to all listeners.
 void fireEntryChanged(Entry ent, int index)
          fires an update to all listeners.
 void fireEntryInserted(Entry ent, int index)
          fires an update to all listeners.
 void fireEntryRemoved(Entry ent, int index)
          fires an update to all listeners.
 java.util.Vector getAllEntries()
          Returns all entries held by this ResBundle
 Entry getEntry(int idx)
          Returns the nth entry held by this ResBundle
 java.io.File getFile()
          Gets the filename of this ResBundle
 Entry getParentEntry(java.lang.String key)
          Returns all entries held by this ResBundle
 int getRBListenerCount()
          Returns the number of listeners PRE: none POST: none
 java.lang.String getSuffix()
          Returns suffix of this ResBundle
 void insertEntryAt(Entry ent, int index)
          Inserts a key to this ResBundle
 boolean isDirty()
          Returns whether this editor window has been modified
 boolean isLooseFile()
          Returns whether this EditorWindow represents a loose file.
 int removeEntry(java.lang.String key)
          Removes the entry corresponding to 'key' from this resbundle.
 void remRBListener(RBListener list)
          Removes a listener.
 void setDirty(boolean modified)
          Sets whether this editor window has been modified
 void setEditorWindow(EditorWindow ew)
          Tell this EditorWindow who its parent is.
 void setFile(java.io.File file)
          Sets the filename of this ResBundle
 void setLooseFile(boolean loose)
          Sets whether this EditorWindow represents a loose file.
 void setSuffix(java.lang.String sfx)
          Sets the suffix of this ResBundle
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResBundle

public ResBundle(java.lang.String suffix,
                 java.io.File file,
                 boolean loose)
Default Constructor PRE: none POST: This class is created

ResBundle

public ResBundle(Entry[] entries,
                 java.lang.String suffix,
                 java.io.File file,
                 boolean loose)
Constructs a ResBundle from the given array of entries
Parameters:
entries - an array of entries from which to create this ResBundle PRE: entries does not equal null POST: this class is created

ResBundle

public ResBundle(java.lang.String suffix,
                 java.io.File file,
                 boolean loose,
                 boolean unique)
Constructs a ResBundle from the given vector of entries
Parameters:
entries - a vector of entries from which to create this ResBundle PRE: entries does not equal null POST: this class is created
Method Detail

doSetup

public void doSetup()
Perform setup that is required regardless of the constructor that was used. PRE: none POST: none

getSuffix

public java.lang.String getSuffix()
Returns suffix of this ResBundle
Returns:
the suffix PRE: none POST: suffix is returned

setSuffix

public void setSuffix(java.lang.String sfx)
Sets the suffix of this ResBundle
Parameters:
sfx - the suffix to set PRE: sfx is not null POST: suffix is set

getFile

public java.io.File getFile()
Gets the filename of this ResBundle
Returns:
the filename of this ResBundle PRE: none POST: none

setFile

public void setFile(java.io.File file)
Sets the filename of this ResBundle
Parameters:
the - new filename of this ResBundle PRE: file is not null POST: none

isDirty

public boolean isDirty()
Returns whether this editor window has been modified

setDirty

public void setDirty(boolean modified)
Sets whether this editor window has been modified
Parameters:
whether - this editor window has been modified PRE: none POST: if set to true, this bundle will be saved next time save is pressed

isLooseFile

public boolean isLooseFile()
Returns whether this EditorWindow represents a loose file. PRE: none POST: none

setLooseFile

public void setLooseFile(boolean loose)
Sets whether this EditorWindow represents a loose file. PRE: none POST: none

getParentEntry

public Entry getParentEntry(java.lang.String key)
Returns all entries held by this ResBundle
Returns:
the Entries PRE: key is not equal null POST: the Entry which contains key is returned if it exists, else null is returned

addRBListener

public void addRBListener(RBListener list)
Adds a listener.
Parameters:
list - the listener to add. PRE: list != null POST: list may receive update events.

remRBListener

public void remRBListener(RBListener list)
Removes a listener.
Parameters:
list - the listener to remove. PRE: list != null POST: list will no longer receive update notices

fireEntryAdded

public void fireEntryAdded(Entry ent,
                           int index)
fires an update to all listeners. PRE: none POST: listeners will be notified

fireEntryInserted

public void fireEntryInserted(Entry ent,
                              int index)
fires an update to all listeners. PRE: none POST: listeners will be notified

fireEntryRemoved

public void fireEntryRemoved(Entry ent,
                             int index)
fires an update to all listeners. PRE: none POST: listeners will be notified

fireEntryChanged

public void fireEntryChanged(Entry ent,
                             int index)
fires an update to all listeners. PRE: none POST: listeners will be notified

getRBListenerCount

public int getRBListenerCount()
Returns the number of listeners PRE: none POST: none

getAllEntries

public java.util.Vector getAllEntries()
Returns all entries held by this ResBundle
Returns:
the Entries PRE: none POST: all entries are returned

getEntry

public Entry getEntry(int idx)
Returns the nth entry held by this ResBundle
Parameters:
idx - the index of the entry to return
Returns:
an Entry PRE: idx is in the bounds of the array. POST: the entry is returned

removeEntry

public int removeEntry(java.lang.String key)
Removes the entry corresponding to 'key' from this resbundle.
Parameters:
entries - an array of entries from which to create this ResBundle
Returns:
the index of the removed bundle. PRE: key is not equal to null POST: if entry corresponding to entry is found it is removed.

setEditorWindow

public void setEditorWindow(EditorWindow ew)
Tell this EditorWindow who its parent is.
Parameters:
ew - The parent PRE: none POST: this class has a reference to its parent.

addEntry

public void addEntry(Entry ent)
Adds a new key to this ResBundle
Parameters:
key - the key to add PRE: e does not equal null POST: the entry is added to this resource bundle.

insertEntryAt

public void insertEntryAt(Entry ent,
                          int index)
Inserts a key to this ResBundle
Parameters:
key - the key to add PRE: ent does not equal null POST: the entry is added to this resource bundle.

entryAdded

public void entryAdded(RBEvent rbe)
Specified by:
entryAdded in interface RBListener

entryInserted

public void entryInserted(RBEvent rbe)
Specified by:
entryInserted in interface RBListener

entryRemoved

public void entryRemoved(RBEvent rbe)
Specified by:
entryRemoved in interface RBListener

entryChanged

public void entryChanged(RBEvent rbe)
Called when one of my parent's entries was changed. If I don't overwrite that particular value (i.e., i am unique), then i ignore this event. Else, I inherit this value from my parent, and since he changed, i must change to match. After changing, I then inform my children that _I_ changed.
Specified by:
entryChanged in interface RBListener

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object