1 /*************************************************************************************** 2 * Copyright (c) Jonas Bonér, Alexandre Vasseur. All rights reserved. * 3 * http://aspectwerkz.codehaus.org * 4 * ---------------------------------------------------------------------------------- * 5 * The software in this package is published under the terms of the LGPL license * 6 * a copy of which has been included with this distribution in the license.txt file. * 7 **************************************************************************************/ 8 package org.codehaus.aspectwerkz.annotation; 9 10 import java.io.ObjectInputStream; 11 import java.io.Serializable; 12 13 /*** 14 * Untyped annotation proxy. <p/>To be used with JavDoc-style, pure string based, one value only type of annotations. 15 * 16 * @author <a href="mailto:jboner@codehaus.org">Jonas Bonér </a> 17 * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a> 18 */ 19 public class UntypedAnnotationProxy implements Annotation, Serializable { 20 /*** 21 * The full value of the annotation. 22 */ 23 protected String m_value = ""; 24 25 /*** 26 * The name of the annotation. 27 */ 28 protected String m_name; 29 30 /*** 31 * Returns the value. 32 * 33 * @return the value 34 */ 35 public String getValue() { 36 return m_value; 37 } 38 39 /*** 40 * Returns the name. 41 * 42 * @return 43 */ 44 public String getName() { 45 return m_name; 46 } 47 48 /*** 49 * Sets the name of the annotation, the '@[name]'. 50 * 51 * @param name 52 */ 53 public void setName(final String name) { 54 m_name = name; 55 } 56 57 /*** 58 * Sets the string single value of this untyped annotation 59 * 60 * @param value 61 */ 62 public void setValue(final String value) { 63 m_value = value; 64 } 65 66 /*** 67 * Checks if the annotation is typed or not. 68 * 69 * @return boolean 70 */ 71 public boolean isTyped() { 72 return false; 73 } 74 75 /*** 76 * Set the value of the annotation given its full representation 77 * as @Foo , lskdlksdl"k"lk"l. 78 * 79 * @param name 80 * @param value 81 */ 82 public void initialize(final String name, final String value) { 83 setName(name); 84 setValue(value); 85 } 86 87 /*** 88 * Provides custom deserialization. 89 * 90 * @param stream the object input stream containing the serialized object 91 * @throws Exception in case of failure 92 */ 93 private void readObject(final ObjectInputStream stream) throws Exception { 94 ObjectInputStream.GetField fields = stream.readFields(); 95 m_value = (String) fields.get("m_value", null); 96 m_name = (String) fields.get("m_name", null); 97 } 98 }