001    /* MBEL: The Microsoft Bytecode Engineering Library
002     * Copyright (C) 2003 The University of Arizona
003     * http://www.cs.arizona.edu/mbel/license.html
004     *
005     * This library is free software; you can redistribute it and/or
006     * modify it under the terms of the GNU Lesser General Public
007     * License as published by the Free Software Foundation; either
008     * version 2.1 of the License, or (at your option) any later version.
009     * 
010     * This library is distributed in the hope that it will be useful,
011     * but WITHOUT ANY WARRANTY; without even the implied warranty of
012     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013     * Lesser General Public License for more details.
014     * 
015     * You should have received a copy of the GNU Lesser General Public
016     * License along with this library; if not, write to the Free Software
017     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
018     */
019    
020    package edu.arizona.cs.mbel.mbel;
021    
022    /** Represents a managed resource. Managed resources can be embedded in the current module, 
023      * or found in another assembly, or in a File that is reference by this module.
024      * Resources all have a logical name associated with them.
025      * @author Michael Stepp
026      */
027    public abstract class ManifestResource implements edu.arizona.cs.mbel.signature.ManifestResourceAttributes{
028       private long Flags;
029       private String Name;
030       private java.util.Vector manifestResourceAttributes;
031       
032       /** Makes a new ManifestResource with the given name and flags
033         * @param name the logical name of this resource
034         * @param flags a bit vector of flags (defined in ManifestResourceAttributes)
035         */
036       protected ManifestResource(String name, long flags){
037          Name = name;
038          Flags = flags;
039          
040          manifestResourceAttributes = new java.util.Vector(10);
041       }
042       
043       /** Adds a CustomAttribute to this ManifestResource
044         */
045       public void addManifestResourceAttribute(CustomAttribute ca){
046          if (ca!=null)
047             manifestResourceAttributes.add(ca);
048       }
049       /** Returns a non-null array of CustomAttributes on this ManifestResource
050         */
051       public CustomAttribute[] getManifestResourceAttributes(){
052          CustomAttribute[] cas = new CustomAttribute[manifestResourceAttributes.size()];
053          for (int i=0;i<cas.length;i++)
054             cas[i] = (CustomAttribute)manifestResourceAttributes.get(i);
055          return cas;   
056       }
057       /** Removes a CustomAttribute from this ManifestResource
058         */
059       public void removeManifestResourceAttribute(CustomAttribute ca){
060          if (ca!=null)
061             manifestResourceAttributes.remove(ca);
062       }
063       
064       /** Returns the logical name of this ManifestResource
065         */
066       public String getName(){
067          return Name;
068       }
069       /** Sets the logical name of this ManifestResource
070         */
071       public void setName(String name){
072          Name = name;
073       }
074       /** Returns the bit vector of flags for this resource (defined in ManifestResourceAttributes)
075         */
076       public long getFlags(){
077          return Flags;
078       }
079       
080       /** Compares 2 ManifestResources.
081         * Returns true iff the name and flags are equal
082         */
083       public boolean equals(Object o){
084          if (o==null || !(o instanceof ManifestResource))
085             return false;
086          ManifestResource res = (ManifestResource)o;
087          return (Name.equals(res.Name) && Flags==res.Flags);
088       }
089       
090    //   public abstract void output();
091    }