Package jpicedt.format.input.util
Class Pool
- java.lang.Object
-
- jpicedt.format.input.util.Pool
-
public class Pool extends java.lang.ObjectOffers a means for expressions belonging to the parser-tree to share variables across the tree. In addition to storing persistent data in some predefined public fields, this class also acts as a hashtable, and may thus store key/value pairs of objects of any class (these may be PicAttributeSet's, etc...), which may be shared across the whole parser-tree.- Since:
- jpicedt 1.3
- Version:
- $Id: Pool.java,v 1.5.2.1 2007/09/02 11:56:14 reynal Exp $
- Author:
- Sylvain Reynal
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPool.KeyEnforces use of strong typing for keys being pushed in the map .
-
Field Summary
Fields Modifier and Type Field Description static Pool.KeyCURRENT_OBJ_ATTRIBUTESKey used to fetch the attribute set attached to the current element "currentObj"PicGroupcurrentGroupeither the main drawing, or a subgroup ; each new parsed Element should be added to this groupElementcurrentObjConvenience used to share information (e.g.java.lang.StringBuffernotParseda string that stores commands that couldn't be parsed in the current context (e.g.java.util.StackpicGroupStacka fifo-like stack used to store the main drawing and its subgroups ; each time a "begin group" is encountered, the current PicGroup is pushed onto the stack, and a new PicGroup is instanciated, which then represents the current PicGroup ; the opposite operations are executed in the reverse order when a "end group" is found.
-
Constructor Summary
Constructors Constructor Description Pool()Simply call reinit()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectget(Pool.Key key)Return the value associated with the given keyPicAttributeSetgetAttributeSet(Pool.Key key)Convenience for retrieving a "PicAttributeSet" value ; can be used in conjunction with static methods defined in jpicedt.graphic.model.StyleConstants to retrieve attributes values with less burden.doublegetDouble(Pool.Key key)Convenience for retrieving a "double" value from the pool's hashmapdoubleput(Pool.Key key, double d)Convenience for storing a "double" value into the pool's hashmapjava.lang.Objectput(Pool.Key key, java.lang.Object value)Associates the specified value with the given key in the pool's hashmapvoidreinit()Reset public fields values.voidsetAttribute(Pool.Key key, PicAttributeName name, java.lang.Object value)Add a name/value attribute pair to the attribute set with the given key, i.e.java.lang.StringtoString()
-
-
-
Field Detail
-
currentGroup
public PicGroup currentGroup
either the main drawing, or a subgroup ; each new parsed Element should be added to this group
-
picGroupStack
public java.util.Stack picGroupStack
a fifo-like stack used to store the main drawing and its subgroups ; each time a "begin group" is encountered, the current PicGroup is pushed onto the stack, and a new PicGroup is instanciated, which then represents the current PicGroup ; the opposite operations are executed in the reverse order when a "end group" is found.
-
currentObj
public Element currentObj
Convenience used to share information (e.g. parameters, location, ...) across expressions acting on the same element. Generally, an InstanciationExpression reinits "currentObj" to an instance of an Element of the proper type, then ensuing expression modify this element's attributes and/or geometry.
-
notParsed
public java.lang.StringBuffer notParsed
a string that stores commands that couldn't be parsed in the current context (e.g. in the text file to be parsed) so that we can keep track of these commands (e.g. to be able to include them again when it comes to saving the text file to disk)
-
CURRENT_OBJ_ATTRIBUTES
public static final Pool.Key CURRENT_OBJ_ATTRIBUTES
Key used to fetch the attribute set attached to the current element "currentObj"- See Also:
#get(String)
-
-
Method Detail
-
reinit
public void reinit()
Reset public fields values.
-
put
public java.lang.Object put(Pool.Key key, java.lang.Object value)
Associates the specified value with the given key in the pool's hashmap- Returns:
- old value for the given key, if any.
-
get
public java.lang.Object get(Pool.Key key)
Return the value associated with the given key
-
getDouble
public double getDouble(Pool.Key key)
Convenience for retrieving a "double" value from the pool's hashmap
-
put
public double put(Pool.Key key, double d)
Convenience for storing a "double" value into the pool's hashmap- Returns:
- the old value, if any, for convenience
-
getAttributeSet
public PicAttributeSet getAttributeSet(Pool.Key key)
Convenience for retrieving a "PicAttributeSet" value ; can be used in conjunction with static methods defined in jpicedt.graphic.model.StyleConstants to retrieve attributes values with less burden.- Parameters:
key- if CURRENT_OBJ_ATTRIBUTES, retrieves the attribute set of the current Element in the pool ; any other key is acceptable as long as it corresponds to a valid entry in the Pool's hashtable, that is, it has been previously pushed in the Pool usingput(key, value).
-
setAttribute
public void setAttribute(Pool.Key key, PicAttributeName name, java.lang.Object value)
Add a name/value attribute pair to the attribute set with the given key, i.e. either CURRENT_OBJ_ATTRIBUTES for "currentObj", or any other key refering to an attribute set previously pushed in the Pool (e.g. PsTricks registers,...)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- Returns:
- a text description of this Pool for debugging purpose
-
-