Back to index

wims  3.65+svn20090927
Count.java
Go to the documentation of this file.
00001 package rene.zirkel.construction;
00002 
00003 import java.util.*;
00004 
00011 public class Count
00012 {      static Vector Counts=new Vector();
00013        int N,BackupN;
00014        boolean Fixed=false;
00015        public Count ()
00016        {      reset();
00017               Counts.addElement(this);
00018        }
00019        public synchronized int next ()
00020        {      if (Fixed) return 0;
00021               N++; return N;
00022        }
00023        public synchronized void reset ()
00024        {      N=0;
00025        }
00026        public synchronized void setAlternate (boolean flag)
00027        {      if (flag) { BackupN=N; N=0; }
00028               else N=BackupN;
00029        }
00030        static synchronized public void resetAll ()
00031        {      Enumeration e=Counts.elements();
00032               while (e.hasMoreElements())
00033                      ((Count)e.nextElement()).reset();
00034        }
00035        static synchronized public void setAllAlternate (boolean flag)
00036        {      Enumeration e=Counts.elements();
00037               while (e.hasMoreElements())
00038                      ((Count)e.nextElement()).setAlternate(flag);
00039        }
00040        public synchronized void fix (boolean flag)
00041        {      Fixed=flag;
00042        }
00043        static synchronized public void fixAll (boolean flag)
00044        {      Enumeration e=Counts.elements();
00045               while (e.hasMoreElements())
00046                      ((Count)e.nextElement()).fix(flag);
00047        }
00048 }