AnnotationVisibility.java revision b3abca4c90929e31e6a8c52bc0178c44e3e53c6b
159907c4d8f6fc8aacfdaa0273bd7a9c140fbb45fChris Lattner/* 259907c4d8f6fc8aacfdaa0273bd7a9c140fbb45fChris Lattner * [The "BSD licence"] 359907c4d8f6fc8aacfdaa0273bd7a9c140fbb45fChris Lattner * Copyright (c) 2010 Ben Gruver (JesusFreke) 459907c4d8f6fc8aacfdaa0273bd7a9c140fbb45fChris Lattner * All rights reserved. 50bc735ffcfb223c0186419547abaa5c84482663eChris Lattner * 60bc735ffcfb223c0186419547abaa5c84482663eChris Lattner * Redistribution and use in source and binary forms, with or without 759907c4d8f6fc8aacfdaa0273bd7a9c140fbb45fChris Lattner * modification, are permitted provided that the following conditions 859907c4d8f6fc8aacfdaa0273bd7a9c140fbb45fChris Lattner * are met: 959907c4d8f6fc8aacfdaa0273bd7a9c140fbb45fChris Lattner * 1. Redistributions of source code must retain the above copyright 101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump * notice, this list of conditions and the following disclaimer. 1159907c4d8f6fc8aacfdaa0273bd7a9c140fbb45fChris Lattner * 2. Redistributions in binary form must reproduce the above copyright 1259907c4d8f6fc8aacfdaa0273bd7a9c140fbb45fChris Lattner * notice, this list of conditions and the following disclaimer in the 1359907c4d8f6fc8aacfdaa0273bd7a9c140fbb45fChris Lattner * documentation and/or other materials provided with the distribution. 1459907c4d8f6fc8aacfdaa0273bd7a9c140fbb45fChris Lattner * 3. The name of the author may not be used to endorse or promote products 152d88708cbe4e4ec5e04e4acb6bd7f5be68557379John McCall * derived from this software without specific prior written permission. 1659907c4d8f6fc8aacfdaa0273bd7a9c140fbb45fChris Lattner * 17199c3d6cd16aebbb9c7f0d42af9d922c9628bf70Ken Dyck * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18384aff8b94bb0d1ad6c5667b90621e5699815bb2John McCall * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19c4a1dea2dc56bd1357ec91b829a0b9e68229a13eDaniel Dunbar * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2055fc873017f10f6f566b182b70f6fc22aefa3464Chandler Carruth * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21be0ee875d8a91c031a085cbbd73ad9e8dc1aa8ffDavid Blaikie * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 222324512285caac0332bbbc6e4cab6245d2a370a1Ted Kremenek * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 237ff22b259d4d4729f701679e3a7f0e242365e07fTed Kremenek * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24f8c4921c73d73123e2b79221ad4f1775ce984cfdMike Stump * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25f8c4921c73d73123e2b79221ad4f1775ce984cfdMike Stump * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2655fc873017f10f6f566b182b70f6fc22aefa3464Chandler Carruth * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 273f6f51e28231f65de9c2dd150a2d757b2162cfa3Jordan Rose */ 2855fc873017f10f6f566b182b70f6fc22aefa3464Chandler Carruth 2955fc873017f10f6f566b182b70f6fc22aefa3464Chandler Carruthpackage org.jf.dexlib; 3059907c4d8f6fc8aacfdaa0273bd7a9c140fbb45fChris Lattner 3155fc873017f10f6f566b182b70f6fc22aefa3464Chandler Carruthpublic enum AnnotationVisibility { 3255fc873017f10f6f566b182b70f6fc22aefa3464Chandler Carruth BUILD((byte)0, "build"), 3355fc873017f10f6f566b182b70f6fc22aefa3464Chandler Carruth RUNTIME((byte)1, "runtime"), 3455fc873017f10f6f566b182b70f6fc22aefa3464Chandler Carruth SYSTEM((byte)2, "system"); 35f8c4921c73d73123e2b79221ad4f1775ce984cfdMike Stump 36f8c4921c73d73123e2b79221ad4f1775ce984cfdMike Stump public final byte value; 3755fc873017f10f6f566b182b70f6fc22aefa3464Chandler Carruth public final String visibility; 38cb5620c9b213f4bd323912159fdddda35e258a14Dmitri Gribenko private AnnotationVisibility(byte value, String visibility) { 393bfc5f49e0e37e235bb0d33bcbcb36af9d1f84abTom Care this.value = value; 40a1f3dba77b7418575c1ff539ffa74ebaa068280cZhongxing Xu this.visibility = visibility; 4159907c4d8f6fc8aacfdaa0273bd7a9c140fbb45fChris Lattner } 42781472fe99a120098c631b0cbe33c89f8cef5e70John McCall 4359907c4d8f6fc8aacfdaa0273bd7a9c140fbb45fChris Lattner public static AnnotationVisibility fromByte(byte value) { 4460800081361b0ffc114877b8abbc81cb57b4edf6Chris Lattner switch (value) { 4560800081361b0ffc114877b8abbc81cb57b4edf6Chris Lattner case (byte)0: 4608f92e3a5dead1f1ee656678a7f06e43279d6e50Chris Lattner return BUILD; 474e4d08403ca5cfd4d558fa2936215d3a4e5a528dDavid Blaikie case (byte)1: 4860800081361b0ffc114877b8abbc81cb57b4edf6Chris Lattner return RUNTIME; 4960800081361b0ffc114877b8abbc81cb57b4edf6Chris Lattner case (byte)2: 508e10f3b9cc1db43645bbc2999eb163af8997d468John McCall return SYSTEM; 518e10f3b9cc1db43645bbc2999eb163af8997d468John McCall default: 528e10f3b9cc1db43645bbc2999eb163af8997d468John McCall throw new RuntimeException("Invalid annotation visibility value: " + value); 538e10f3b9cc1db43645bbc2999eb163af8997d468John McCall } 548e10f3b9cc1db43645bbc2999eb163af8997d468John McCall } 558e10f3b9cc1db43645bbc2999eb163af8997d468John McCall} 568e10f3b9cc1db43645bbc2999eb163af8997d468John McCall