Save This Page
Home » openjdk-7 » net » sf » rvpf » metadata » [javadoc | source]
    1   /**
    2    * Related Values Processing Framework.
    3    * 
    4    * Copyright (C) 2003 Serge Brisson.
    5    * 
    6    * This software is distributable under LGPL license.
    7    * See details at the bottom of this file.
    8    * 
    9    * $Header: /cvsroot/rvpf/RVPF/java/src/net/sf/rvpf/metadata/ProxyEntity.java,v 1.11 2003/10/21 02:11:44 sfb Exp $
   10    */
   11   package net.sf.rvpf.metadata;
   12   
   13   /** Proxy Entity.
   14    * 
   15    * @author Serge Brisson
   16    * @version $Revision: 1.11 $
   17    */
   18   public abstract class ProxyEntity extends ParamsEntity implements Proxied {
   19   
   20       // Public Instance Properties.
   21   
   22       /** Sets the ClassDef.
   23        * 
   24        * @param classDef The ClassDef.
   25        */
   26       public void setClassDef(ClassDefEntity classDef) {
   27           this.classDef = classDef;
   28       }
   29   
   30       // Protected Instance Properties.
   31   
   32       /** Gets the Proxied instance.
   33        * 
   34        * @return The Proxied instance.
   35        */
   36       protected Proxied getInstance() {
   37           return this.instance;
   38       }
   39   
   40       /** Sets the Proxied instance.
   41        * 
   42        * @param instance The Proxied instance.
   43        */
   44       public void setInstance(Proxied instance) {
   45           this.instance = instance;
   46       }
   47   
   48       /** Gets the Metadata.
   49        * 
   50        * @return The Metadata.
   51        */
   52       protected Metadata getMetadata() {
   53           return this.metadata;
   54       }
   55   
   56       // Public Instance Methods.
   57   
   58       /** Asks if the proxied entity implements an interface.
   59        *
   60        * @param name The name of the ClassDef representing the interface.
   61        * @return True if the interface is implemented.
   62        */
   63       public boolean is(String name) {
   64           if (this.classDef == null) return false;
   65   
   66           return this.classDef.is(name);
   67       }
   68   
   69       /** Sets up the Proxied object.
   70        * <p>
   71        * Note: this method must be prepared to be called redundantly.
   72        * Such calls happen during the normal setup of the points
   73        * in a Processor.
   74        * 
   75        * @param metadata The Metadata.
   76        * @return True if successful.
   77        */
   78       public boolean setUp(Metadata metadata) {
   79           return setUp(metadata, getParams());
   80       }
   81   
   82       /**
   83        */
   84       public synchronized boolean setUp(Metadata metadata, Params params) {
   85           if (getMetadata() == null) {
   86               this.metadata = metadata;
   87               if (this.instance == null)
   88                   this.instance = (Proxied) this.classDef.createInstance();
   89               if (!getInstance().setUp(metadata, params)) return false;
   90           }
   91   
   92           return true;
   93       }
   94   
   95       /**
   96        */
   97       public void tearDown() {
   98           if (getMetadata() != null) {
   99               this.instance.tearDown();
  100               this.instance = null;
  101               this.metadata = null;
  102           }
  103       }
  104   
  105       // Instance Attributes.
  106   
  107       private ClassDefEntity classDef = null;
  108       private Proxied instance = null;
  109       private Metadata metadata = null;
  110   }
  111   
  112   // $Log: ProxyEntity.java,v $
  113   // Revision 1.11  2003/10/21 02:11:44  sfb
  114   // Made 'setUp' cope with use of 'setInstance'.
  115   //
  116   // Revision 1.10  2003/10/20 17:59:44  sfb
  117   // Added 'setInstance'.
  118   //
  119   // Revision 1.9  2003/09/19 16:18:28  sfb
  120   // Refactored DefEntity.
  121   //
  122   
  123   /*
  124    * This is free software; you can redistribute it and/or modify
  125    * it under the terms of the GNU Lesser General Public License
  126    * as published by the Free Software Foundation; either version 2.1
  127    * of the License, or (at your option) any later version.
  128    *
  129    * This software is distributed in the hope that it will be useful,
  130    * but WITHOUT ANY WARRANTY; without even the implied warranty of
  131    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  132    * Lesser General Public License for more details.
  133    *
  134    * You should have received a copy of the GNU Lesser General Public
  135    * License along with this software; if not, write to the Free Software
  136    * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  137    */

Save This Page
Home » openjdk-7 » net » sf » rvpf » metadata » [javadoc | source]