001
002package gudusoft.gsqlparser.pp.para;
003
004import java.util.Hashtable;
005import java.util.Map;
006
007public class GFmtOptFactory
008{
009
010        /**
011         * all the instances, the key is the session id.
012         */
013        private volatile static Map<String, GFmtOpt> objs = new Hashtable<String, GFmtOpt>( );
014
015        /**
016         * create an new instance
017         * 
018         * @param sessionId
019         *            the session id
020         * @return the new option instance
021         */
022        public static GFmtOpt newInstance( String sessionId )
023        {
024                if ( !objs.containsKey( sessionId ) )
025                {
026                        synchronized ( GFmtOptFactory.class )
027                        {
028                                if ( !objs.containsKey( sessionId ) )
029                                {
030                                        objs.put( sessionId, new GFmtOpt( sessionId ) );
031                                }
032                        }
033                }
034
035                return objs.get( sessionId );
036        }
037
038        public static GFmtOpt newInstance( )
039        {
040                return newInstance( Long.valueOf( Thread.currentThread( ).getId( ) )
041                                .toString( ) );
042        }
043
044}