Coverage Report - com.jeantessier.classreader.impl.ElementValueType
 
Classes in this File Line Coverage Branch Coverage Complexity
ElementValueType
100%
23/23
100%
4/4
1.118
ElementValueType$1
100%
2/2
N/A
1.118
ElementValueType$10
100%
2/2
N/A
1.118
ElementValueType$11
100%
2/2
N/A
1.118
ElementValueType$12
100%
2/2
N/A
1.118
ElementValueType$13
100%
2/2
N/A
1.118
ElementValueType$2
100%
2/2
N/A
1.118
ElementValueType$3
100%
2/2
N/A
1.118
ElementValueType$4
100%
2/2
N/A
1.118
ElementValueType$5
100%
2/2
N/A
1.118
ElementValueType$6
100%
2/2
N/A
1.118
ElementValueType$7
100%
2/2
N/A
1.118
ElementValueType$8
100%
2/2
N/A
1.118
ElementValueType$9
100%
2/2
N/A
1.118
 
 1  
 /*
 2  
  *  Copyright (c) 2001-2009, Jean Tessier
 3  
  *  All rights reserved.
 4  
  *
 5  
  *  Redistribution and use in source and binary forms, with or without
 6  
  *  modification, are permitted provided that the following conditions
 7  
  *  are met:
 8  
  *
 9  
  *      * Redistributions of source code must retain the above copyright
 10  
  *        notice, this list of conditions and the following disclaimer.
 11  
  *
 12  
  *      * Redistributions in binary form must reproduce the above copyright
 13  
  *        notice, this list of conditions and the following disclaimer in the
 14  
  *        documentation and/or other materials provided with the distribution.
 15  
  *
 16  
  *      * Neither the name of Jean Tessier nor the names of his contributors
 17  
  *        may be used to endorse or promote products derived from this software
 18  
  *        without specific prior written permission.
 19  
  *
 20  
  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 21  
  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 22  
  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 23  
  *  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR
 24  
  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 25  
  *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 26  
  *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 27  
  *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 28  
  *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 29  
  *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 30  
  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 31  
  */
 32  
 
 33  
 package com.jeantessier.classreader.impl;
 34  
 
 35  
 import java.io.*;
 36  
 
 37  33
 public enum ElementValueType {
 38  1
     BYTE(com.jeantessier.classreader.ElementValueType.BYTE) {
 39  
         public ElementValue create(ConstantPool constantPool, DataInput in) throws IOException {
 40  2
             return new ByteConstantElementValue(constantPool, in);
 41  
         }
 42  
     },
 43  
 
 44  1
     CHAR(com.jeantessier.classreader.ElementValueType.CHAR) {
 45  
         public ElementValue create(ConstantPool constantPool, DataInput in) throws IOException {
 46  1
             return new CharConstantElementValue(constantPool, in);
 47  
         }
 48  
     },
 49  
 
 50  1
     DOUBLE(com.jeantessier.classreader.ElementValueType.DOUBLE) {
 51  
         public ElementValue create(ConstantPool constantPool, DataInput in) throws IOException {
 52  1
             return new DoubleConstantElementValue(constantPool, in);
 53  
         }
 54  
     },
 55  
 
 56  1
     FLOAT(com.jeantessier.classreader.ElementValueType.FLOAT) {
 57  
         public ElementValue create(ConstantPool constantPool, DataInput in) throws IOException {
 58  1
             return new FloatConstantElementValue(constantPool, in);
 59  
         }
 60  
     },
 61  
 
 62  1
     INTEGER(com.jeantessier.classreader.ElementValueType.INTEGER) {
 63  
         public ElementValue create(ConstantPool constantPool, DataInput in) throws IOException {
 64  1
             return new IntegerConstantElementValue(constantPool, in);
 65  
         }
 66  
     },
 67  
 
 68  1
     LONG(com.jeantessier.classreader.ElementValueType.LONG) {
 69  
         public ElementValue create(ConstantPool constantPool, DataInput in) throws IOException {
 70  1
             return new LongConstantElementValue(constantPool, in);
 71  
         }
 72  
     },
 73  
 
 74  1
     SHORT(com.jeantessier.classreader.ElementValueType.SHORT) {
 75  
         public ElementValue create(ConstantPool constantPool, DataInput in) throws IOException {
 76  1
             return new ShortConstantElementValue(constantPool, in);
 77  
         }
 78  
     },
 79  
 
 80  1
     BOOLEAN(com.jeantessier.classreader.ElementValueType.BOOLEAN) {
 81  
         public ElementValue create(ConstantPool constantPool, DataInput in) throws IOException {
 82  1
             return new BooleanConstantElementValue(constantPool, in);
 83  
         }
 84  
     },
 85  
 
 86  1
     STRING(com.jeantessier.classreader.ElementValueType.STRING) {
 87  
         public ElementValue create(ConstantPool constantPool, DataInput in) throws IOException {
 88  1
             return new StringConstantElementValue(constantPool, in);
 89  
         }
 90  
     },
 91  
 
 92  1
     ENUM(com.jeantessier.classreader.ElementValueType.ENUM) {
 93  
         public ElementValue create(ConstantPool constantPool, DataInput in) throws IOException {
 94  4
             return new EnumElementValue(constantPool, in);
 95  
         }
 96  
     },
 97  
 
 98  1
     CLASS(com.jeantessier.classreader.ElementValueType.CLASS) {
 99  
         public ElementValue create(ConstantPool constantPool, DataInput in) throws IOException {
 100  1
             return new ClassElementValue(constantPool, in);
 101  
         }
 102  
     },
 103  
 
 104  1
     ANNOTATION(com.jeantessier.classreader.ElementValueType.ANNOTATION) {
 105  
         public ElementValue create(ConstantPool constantPool, DataInput in) throws IOException {
 106  1
             return new AnnotationElementValue(constantPool, in);
 107  
         }
 108  
     },
 109  
 
 110  1
     ARRAY(com.jeantessier.classreader.ElementValueType.ARRAY) {
 111  
         public ElementValue create(ConstantPool constantPool, DataInput in) throws IOException {
 112  2
             return new ArrayElementValue(constantPool, in);
 113  
         }
 114  
     };
 115  
 
 116  
     private final com.jeantessier.classreader.ElementValueType elementValueType;
 117  
 
 118  13
     ElementValueType(com.jeantessier.classreader.ElementValueType elementValueType) {
 119  13
         this.elementValueType = elementValueType;
 120  13
     }
 121  
 
 122  
     public char getTag() {
 123  273
         return elementValueType.getTag();
 124  
     }
 125  
 
 126  
     public abstract ElementValue create(ConstantPool constantPool, DataInput in) throws IOException;
 127  
 
 128  
     public static ElementValueType forTag(char tag) {
 129  19
         ElementValueType result = null;
 130  
 
 131  266
         for (ElementValueType elementValueType : values()) {
 132  247
             if (elementValueType.getTag() == tag) {
 133  18
                 result = elementValueType;
 134  
             }
 135  
         }
 136  
 
 137  19
         return result;
 138  
     }
 139  
 }