001 /* 002 * Sonar, open source software quality management tool. 003 * Copyright (C) 2009 SonarSource SA 004 * mailto:contact AT sonarsource DOT com 005 * 006 * Sonar is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 3 of the License, or (at your option) any later version. 010 * 011 * Sonar is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with Sonar; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 019 */ 020 package org.sonar.squid.bytecode.asm; 021 022 import java.util.Collection; 023 import java.util.HashMap; 024 import java.util.Map; 025 026 import org.objectweb.asm.Opcodes; 027 028 public class AsmClass extends AsmUnit { 029 030 private int version; 031 private String className; 032 private String signature; 033 private String superClass; 034 private String[] interfaces; 035 private Map<String, AsmMethod> methods = new HashMap<String, AsmMethod>(); 036 private Map<String, AsmField> fields = new HashMap<String, AsmField>(); 037 038 public AsmClass(int version, int access, String className, String signature, String superClass, String[] interfaces) { 039 super(access); 040 this.version = version; 041 this.className = className; 042 this.signature = signature; 043 this.superClass = superClass; 044 this.interfaces = interfaces; 045 } 046 047 public boolean isAbstract() { 048 return (access & Opcodes.ACC_ABSTRACT) != 0; 049 } 050 051 public boolean isInterface() { 052 return (access & Opcodes.ACC_INTERFACE) != 0; 053 } 054 055 public String getClassName() { 056 return className; 057 } 058 059 public void addMethod(AsmMethod asmMethod) { 060 methods.put(asmMethod.getKey(), asmMethod); 061 } 062 063 public Collection<AsmMethod> getMethods() { 064 return methods.values(); 065 } 066 067 public Collection<AsmField> getFields() { 068 return fields.values(); 069 } 070 071 public void addField(AsmField field) { 072 fields.put(field.getName(), field); 073 } 074 075 public AsmField getField(String fieldName) { 076 return fields.get(fieldName); 077 } 078 079 public AsmMethod getMethod(String key) { 080 return methods.get(key); 081 } 082 }