1b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato/*
2b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * ProGuard -- shrinking, optimization, obfuscation, and preverification
3b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *             of Java bytecode.
4b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
5b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Copyright (c) 2002-2009 Eric Lafortune (eric@graphics.cornell.edu)
6b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
7b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * This program is free software; you can redistribute it and/or modify it
8b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * under the terms of the GNU General Public License as published by the Free
9b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Software Foundation; either version 2 of the License, or (at your option)
10b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * any later version.
11b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
12b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * This program is distributed in the hope that it will be useful, but WITHOUT
13b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * more details.
16b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
17b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * You should have received a copy of the GNU General Public License along
18b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * with this program; if not, write to the Free Software Foundation, Inc.,
19b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */
21b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratopackage proguard.classfile.editor;
22b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
23b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport proguard.classfile.*;
24b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport proguard.classfile.attribute.annotation.*;
25b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport proguard.classfile.attribute.annotation.visitor.ElementValueVisitor;
26b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
27b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato/**
28b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * This AnnotationVisitor adds all element values that it visits to the given
29b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * target annotation default attribute, annotation, or element value.
30b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
31b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * @author Eric Lafortune
32b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */
33b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratopublic class ElementValueAdder
34b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimplements   ElementValueVisitor
35b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato{
36b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private static final ElementValue[] EMPTY_ELEMENT_VALUES = new ElementValue[0];
37b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
38b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
39b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final ProgramClass               targetClass;
40b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final AnnotationDefaultAttribute targetAnnotationDefaultAttribute;
41b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
42b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final ConstantAdder       constantAdder;
43b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final ElementValuesEditor elementValuesEditor;
44b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
45b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
46b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    /**
47b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * Creates a new ElementValueAdder that will copy element values into the
48b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * given target annotation default attribute value.
49b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     */
50b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public ElementValueAdder(ProgramClass               targetClass,
51b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                             AnnotationDefaultAttribute targetAnnotationDefaultAttribute,
52b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                             boolean                    replaceElementValues)
53b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
54b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        this.targetClass                      = targetClass;
55b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        this.targetAnnotationDefaultAttribute = targetAnnotationDefaultAttribute;
56b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
57b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        constantAdder       = new ConstantAdder(targetClass);
58b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        elementValuesEditor = null;
59b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
60b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
61b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
62b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    /**
63b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * Creates a new ElementValueAdder that will copy element values into the
64b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * given target annotation.
65b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     */
66b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public ElementValueAdder(ProgramClass targetClass,
67b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                             Annotation   targetAnnotation,
68b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                             boolean      replaceElementValues)
69b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
70b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        this.targetClass                      = targetClass;
71b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        this.targetAnnotationDefaultAttribute = null;
72b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
73b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        constantAdder       = new ConstantAdder(targetClass);
74b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        elementValuesEditor = new ElementValuesEditor(targetClass,
75b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                      targetAnnotation,
76b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                      replaceElementValues);
77b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
78b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
79b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
80b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    /**
81b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * Creates a new ElementValueAdder that will copy element values into the
82b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * given target element value.
83b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     */
84b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public ElementValueAdder(ProgramClass      targetClass,
85b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                             ArrayElementValue targetArrayElementValue,
86b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                             boolean           replaceElementValues)
87b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
88b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        this.targetClass                      = targetClass;
89b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        this.targetAnnotationDefaultAttribute = null;
90b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
91b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        constantAdder       = new ConstantAdder(targetClass);
92b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        elementValuesEditor = new ElementValuesEditor(targetClass,
93b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                      targetArrayElementValue,
94b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                      replaceElementValues);
95b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
96b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
97b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
98b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    // Implementations for ElementValueVisitor.
99b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
100b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitConstantElementValue(Clazz clazz, Annotation annotation, ConstantElementValue constantElementValue)
101b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
102b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Create a copy of the element value.
103b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        ConstantElementValue newConstantElementValue =
104b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            new ConstantElementValue(constantElementValue.u1tag,
105b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                     constantElementValue.u2elementNameIndex == 0 ? 0 :
106b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                     constantAdder.addConstant(clazz, constantElementValue.u2elementNameIndex),
107b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                     constantAdder.addConstant(clazz, constantElementValue.u2constantValueIndex));
108b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
109b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        newConstantElementValue.referencedClass  = constantElementValue.referencedClass;
110b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        newConstantElementValue.referencedMethod = constantElementValue.referencedMethod;
111b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
112b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Add it to the target.
113b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        addElementValue(newConstantElementValue);
114b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
115b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
116b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
117b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitEnumConstantElementValue(Clazz clazz, Annotation annotation, EnumConstantElementValue enumConstantElementValue)
118b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
119b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Create a copy of the element value.
120b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        EnumConstantElementValue newEnumConstantElementValue =
121b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            new EnumConstantElementValue(enumConstantElementValue.u2elementNameIndex == 0 ? 0 :
122b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                         constantAdder.addConstant(clazz, enumConstantElementValue.u2elementNameIndex),
123b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                         constantAdder.addConstant(clazz, enumConstantElementValue.u2typeNameIndex),
124b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                         constantAdder.addConstant(clazz, enumConstantElementValue.u2constantNameIndex));
125b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
126b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        newEnumConstantElementValue.referencedClass  = enumConstantElementValue.referencedClass;
127b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        newEnumConstantElementValue.referencedMethod = enumConstantElementValue.referencedMethod;
128b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
129b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // TODO: Clone array.
130b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        newEnumConstantElementValue.referencedClasses = enumConstantElementValue.referencedClasses;
131b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
132b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Add it to the target.
133b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        addElementValue(newEnumConstantElementValue);
134b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
135b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
136b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
137b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitClassElementValue(Clazz clazz, Annotation annotation, ClassElementValue classElementValue)
138b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
139b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Create a copy of the element value.
140b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        ClassElementValue newClassElementValue =
141b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            new ClassElementValue(classElementValue.u2elementNameIndex == 0 ? 0 :
142b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                  constantAdder.addConstant(clazz, classElementValue.u2elementNameIndex),
143b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                  constantAdder.addConstant(clazz, classElementValue.u2classInfoIndex));
144b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
145b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        newClassElementValue.referencedClass  = classElementValue.referencedClass;
146b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        newClassElementValue.referencedMethod = classElementValue.referencedMethod;
147b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
148b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // TODO: Clone array.
149b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        newClassElementValue.referencedClasses = classElementValue.referencedClasses;
150b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
151b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Add it to the target.
152b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        addElementValue(newClassElementValue);
153b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
154b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
155b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
156b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitAnnotationElementValue(Clazz clazz, Annotation annotation, AnnotationElementValue annotationElementValue)
157b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
158b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Create a copy of the element value.
159b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        AnnotationElementValue newAnnotationElementValue =
160b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            new AnnotationElementValue(annotationElementValue.u2elementNameIndex == 0 ? 0 :
161b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                       constantAdder.addConstant(clazz, annotationElementValue.u2elementNameIndex),
162b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                       new Annotation());
163b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
164b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        newAnnotationElementValue.referencedClass  = annotationElementValue.referencedClass;
165b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        newAnnotationElementValue.referencedMethod = annotationElementValue.referencedMethod;
166b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
167b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        annotationElementValue.annotationAccept(clazz,
168b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                new AnnotationAdder(targetClass,
169b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                                    newAnnotationElementValue));
170b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
171b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Add it to the target.
172b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        addElementValue(newAnnotationElementValue);
173b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
174b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
175b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
176b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitArrayElementValue(Clazz clazz, Annotation annotation, ArrayElementValue arrayElementValue)
177b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
178b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Create a copy of the element value.
179b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        ArrayElementValue newArrayElementValue =
180b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            new ArrayElementValue(arrayElementValue.u2elementNameIndex == 0 ? 0 :
181b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                  constantAdder.addConstant(clazz, arrayElementValue.u2elementNameIndex),
182b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                  0,
183b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                  arrayElementValue.u2elementValuesCount > 0 ?
184b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                      new ElementValue[arrayElementValue.u2elementValuesCount] :
185b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                      EMPTY_ELEMENT_VALUES);
186b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
187b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        newArrayElementValue.referencedClass  = arrayElementValue.referencedClass;
188b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        newArrayElementValue.referencedMethod = arrayElementValue.referencedMethod;
189b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
190b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        arrayElementValue.elementValuesAccept(clazz,
191b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                              annotation,
192b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                              new ElementValueAdder(targetClass,
193b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                                    newArrayElementValue,
194b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                                    false));
195b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
196b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Add it to the target.
197b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        addElementValue(newArrayElementValue);
198b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
199b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
200b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
201b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    // Small utility methods.
202b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
203b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private void addElementValue(ElementValue newElementValue)
204b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
205b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // What's the target?
206b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        if (targetAnnotationDefaultAttribute != null)
207b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        {
208b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            // Simply set the completed element value.
209b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            targetAnnotationDefaultAttribute.defaultValue = newElementValue;
210b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        }
211b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        else
212b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        {
213b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            // Add it to the target.
214b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            elementValuesEditor.addElementValue(newElementValue);
215b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        }
216b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
217b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato}