• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (C) 2003 Vladimir Roubtsov. All rights reserved.
2  *
3  * This program and the accompanying materials are made available under
4  * the terms of the Common Public License v1.0 which accompanies this distribution,
5  * and is available at http://www.eclipse.org/legal/cpl-v10.html
6  *
7  * $Id: IItemMetadata.java,v 1.1.1.1 2004/05/09 16:57:37 vlad_r Exp $
8  */
9 package com.vladium.emma.report;
10 
11 // ----------------------------------------------------------------------------
12 /**
13  * @author Vlad Roubtsov, (C) 2003
14  */
15 public
16 interface IItemMetadata
17 {
18     // public: ................................................................
19 
20     // note: order is in sync with Factory init code
21     int TYPE_ID_ALL         = 0;
22     int TYPE_ID_PACKAGE     = 1;
23     int TYPE_ID_SRCFILE     = 2;
24     int TYPE_ID_CLASS       = 3;
25     int TYPE_ID_METHOD      = 4;
26 
getTypeID()27     int getTypeID ();
getTypeName()28     String getTypeName ();
29 
30     /**
31      * Using a long is only ok for less than 64 global attributes, but this limit
32      * seems ok for a long time to come.
33      *
34      * @return bitmask for valid attributes
35      */
getAttributeIDs()36     long getAttributeIDs ();
37 
38     abstract class Factory
39     {
getTypeMetadata(final int typeID)40         public static IItemMetadata getTypeMetadata (final int typeID)
41         {
42             if ((typeID < TYPE_ID_ALL) || (typeID > TYPE_ID_METHOD))
43                 throw new IllegalArgumentException ("invalid type ID: " + typeID);
44 
45             return METADATA [typeID];
46         }
47 
getAllTypes()48         public static IItemMetadata [] getAllTypes ()
49         {
50             return METADATA;
51         }
52 
Factory()53         private Factory () {}
54 
55 
56         private static final IItemMetadata [] METADATA; // set in <clinit>
57 
58         static
59         {
60             // this establishes the mapping TYPE_ID_xxx->metadata for type xxx:
61 
62             METADATA = new IItemMetadata []
63             {
64                 AllItem.getTypeMetadata (),
65                 PackageItem.getTypeMetadata (),
66                 SrcFileItem.getTypeMetadata (),
67                 ClassItem.getTypeMetadata (),
68                 MethodItem.getTypeMetadata (),
69             };
70         }
71 
72     } // end of nested class
73 
74 
75 } // end of interface
76 // ----------------------------------------------------------------------------