diff --git a/src/fr/devinsy/xid/FilePresenters.java b/src/fr/devinsy/xid/FilePresenters.java new file mode 100644 index 0000000..67f8724 --- /dev/null +++ b/src/fr/devinsy/xid/FilePresenters.java @@ -0,0 +1,184 @@ +/* + * Copyright 2009 Christian Momon, All rights reserved. + * This file is free software under the terms of the GNU Library General Public License + * as published by the Free Software Foundation version 2 or any later version. + */ + +package fr.devinsy.xid; + + +import java.util.Vector; + + +/** + * + */ +public class FilePresenters extends Vector +{ + private static final long serialVersionUID = 7058868685681354293L; + static protected org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger (FilePresenters.class); + + + /** + * + */ + public FilePresenters () + { + super (); + } + + + /** + * + */ + public FilePresenters (FilePresenters source) + { + super (); + for (FilePresenter presenter : source) + { + this.add(presenter); + } + } + + + /** + * + */ + public boolean exists (String source) + { + boolean result; + + + if (this.getBySource(source) == null) + { + result = false; + } + else + { + result = true; + } + + // + return(result); + } + + + /** + * + */ + public FilePresenter getByIndex (int id) + { + FilePresenter result; + + result = this.get(id); + + // + return(result); + } + + + /** + * + */ + public FilePresenter getBySource (String source) + { + FilePresenter result; + + if (source == null) + { + result = null; + } + else + { + result = null; + boolean ended = false; + int presenterIndex = 0; + while (!ended) + { + if (presenterIndex < this.size()) + { + FilePresenter presenter = this.get(presenterIndex); + + if (presenter.source().equals(source)) + { + result = presenter; + ended = true; + } + else + { + presenterIndex += 1; + } + } + else + { + ended = true; + result = null; + } + } + } + + // + return(result); + } + + + /** + * + */ + public int getIndexOf (String source) + { + int result; + + if (source == null) + { + result = -1; + } + else + { + result = -1; + boolean ended = false; + int presenterIndex = 0; + while (!ended) + { + if (presenterIndex < this.size()) + { + FilePresenter presenter = this.get(presenterIndex); + + if (presenter.source().equals(source)) + { + result = presenterIndex; + ended = true; + } + else + { + presenterIndex += 1; + } + } + else + { + ended = true; + result = -1; + } + } + } + + // + return(result); + } + + + /** + * + */ + public String toString() + { + String result; + + result = ""; + + // + return(result); + } +} + +// //////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/src/fr/devinsy/xid/FilePresentersProxy.java b/src/fr/devinsy/xid/FilePresentersProxy.java new file mode 100644 index 0000000..51fd1c8 --- /dev/null +++ b/src/fr/devinsy/xid/FilePresentersProxy.java @@ -0,0 +1,74 @@ +package fr.devinsy.xid; + + +import java.io.File; +import java.text.*; +import java.util.*; + + +/** + * + */ +public class FilePresentersProxy +{ + static private org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger (FilePresentersProxy.class); + + + private static FilePresentersProxy instance = null; + protected FilePresenters presenters = null; + + /** + * + */ + protected FilePresentersProxy () throws Exception + { + this.presenters = new FilePresenters(); + } + + + /** + * + */ + public static FilePresentersProxy instance () throws Exception + { + FilePresentersProxy result; + + if (FilePresentersProxy.instance == null) + { + instance = new FilePresentersProxy (); + } + + result = instance; + + // + return (result); + } + + + /** + * + */ + public FilePresenter getBySource(String source) throws Exception + { + FilePresenter result; + + if (source == null) + { + result = null; + } + else + { + result = this.presenters.getBySource(source); + if (result == null) + { + result = new FilePresenter(source); + this.presenters.add(result); + } + } + + // + return (result); + } +} + +// //////////////////////////////////////////////////////////////////////// \ No newline at end of file