1 22 package org.jboss.beans.metadata.plugins; 23 24 import java.util.Collections ; 25 import java.util.Iterator ; 26 import java.util.Stack ; 27 28 import org.jboss.beans.metadata.spi.MetaDataVisitor; 29 import org.jboss.beans.metadata.spi.MetaDataVisitorNode; 30 import org.jboss.beans.metadata.spi.ValueMetaData; 31 import org.jboss.reflect.spi.TypeInfo; 32 import org.jboss.util.JBossObject; 33 import org.jboss.util.JBossStringBuilder; 34 35 41 public class AbstractValueMetaData extends JBossObject implements ValueMetaData, TypeProvider 42 { 43 46 protected Object value; 47 48 51 public AbstractValueMetaData() 52 { 53 } 54 55 60 public AbstractValueMetaData(Object value) 61 { 62 this.value = value; 63 } 64 65 public Object getValue() 66 { 67 return value; 68 } 69 70 public void setValue(Object value) 71 { 72 this.value = value; 73 flushJBossObjectCache(); 74 } 75 76 public Object getUnderlyingValue() 77 { 78 return value; 79 } 80 81 public Object getValue(TypeInfo info, ClassLoader cl) throws Throwable 82 { 83 return value; 84 } 85 86 public void initialVisit(MetaDataVisitor visitor) 87 { 88 visitor.initialVisit(this); 89 } 90 91 public void describeVisit(MetaDataVisitor vistor) 92 { 93 vistor.describeVisit(this); 94 } 95 96 public Class getType(MetaDataVisitor visitor, MetaDataVisitorNode previous) throws Throwable 97 { 98 Stack <MetaDataVisitorNode> visitorNodeStack = visitor.visitorNodeStack(); 99 MetaDataVisitorNode node = visitorNodeStack.pop(); 101 try 102 { 103 if (node instanceof TypeProvider) 104 { 105 TypeProvider typeProvider = (TypeProvider) node; 106 return typeProvider.getType(visitor, this); 107 } 108 else 109 { 110 throw new IllegalArgumentException (TypeProvider.ERROR_MSG); 111 } 112 } 113 finally 114 { 115 visitorNodeStack.push(node); 116 } 117 } 118 119 public Iterator <? extends MetaDataVisitorNode> getChildren() 120 { 121 if (value instanceof MetaDataVisitorNode) 122 return Collections.singletonList((MetaDataVisitorNode) value).iterator(); 123 return null; 124 } 125 126 public void toString(JBossStringBuilder buffer) 127 { 128 buffer.append("value=").append(value); 129 } 130 131 public void toShortString(JBossStringBuilder buffer) 132 { 133 buffer.append(value); 134 } 135 } 136 | Popular Tags |