package CUTexamples; import java.io.ByteArrayOutputStream; import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; import java.util.logging.SimpleFormatter; import java.util.logging.StreamHandler; import Sequenic.T3.SuiteUtils.Inference.LogInterceptor; public class TriFloatsWithLogging { private List members = new LinkedList() ; private String name ; private int updates ; public TriFloatsWithLogging(String name) { this.name = name ; updates = 0 ; } private final static ExtendedLogger comment = new ExtendedLogger(Logger.getLogger(TriFloatsWithLogging.class.getName())) ; public boolean add(Float x) { comment.with("x is null").If(x==null).send() ; if (x > 1.5f) { comment.with("x is too big!").send() ; return false ; } if (members.contains(x)) { comment.with("x is already in the buffer").send() ; return false ; } if (members.size() >= 3) { comment.with("buffer is full").send() ; return false ; } members.add(x) ; updates++ ; return true ; } public boolean remove(Float x) { if (members.contains(x)) { members.remove(new Float(x)) ; updates++ ; return true ; } return false ; } public static void main(String[] args) throws Exception { // LOGGER.setLevel(Level.SEVERE); TriFloatsWithLogging t = new TriFloatsWithLogging("bla") ; Logger loggerx = Logger.getLogger(TriFloatsWithLogging.class.getName()); LogInterceptor interceptor = new LogInterceptor(loggerx) ; //ByteArrayOutputStream stream = new ByteArrayOutputStream() ; //StreamHandler h = new StreamHandler(stream,new SimpleFormatter()) ; //loggerx.addHandler(h); t.add(10f) ; t.add(1f) ; t.add(1f) ; //interceptor.flush(); System.out.println(interceptor.toString()) ; interceptor.clear(); t.add(1f) ; System.out.println(interceptor.toString()) ; } }