1 4 package com.tc.object.applicator; 5 6 import com.tc.exception.TCNotSupportedMethodException; 7 import com.tc.object.ClientObjectManager; 8 import com.tc.object.TCClass; 9 import com.tc.object.TCObject; 10 import com.tc.object.TraversedReferences; 11 import com.tc.object.dna.api.DNA; 12 import com.tc.object.dna.api.DNACursor; 13 import com.tc.object.dna.api.DNAWriter; 14 import com.tc.object.dna.api.LiteralAction; 15 import com.tc.object.dna.impl.DNAEncoding; 16 import com.tc.object.tx.optimistic.OptimisticTransactionManager; 17 import com.tc.util.Assert; 18 19 import java.io.IOException ; 20 import java.util.Map ; 21 22 public class LiteralTypesApplicator extends BaseApplicator { 23 24 public LiteralTypesApplicator(TCClass clazz, DNAEncoding encoding) { 25 super(encoding); 26 } 27 28 public TraversedReferences getPortableObjects(Object pojo, TraversedReferences addTo) { 29 return addTo; 32 } 33 34 public void hydrate(ClientObjectManager objectManager, TCObject tcObject, DNA dna, Object po) throws IOException , 35 ClassNotFoundException { 36 DNACursor cursor = dna.getCursor(); 37 Assert.eval(cursor.getActionCount() <= 1); 38 39 if (cursor.next(encoding)) { 40 LiteralAction a = (LiteralAction) cursor.getAction(); 41 Object value = a.getObject(); 42 43 tcObject.setLiteralValue(value); 44 } 45 } 46 47 public void dehydrate(ClientObjectManager objectManager, TCObject tcObject, DNAWriter writer, Object pojo) { 48 if (!objectManager.isPortableInstance(pojo)) { return; } 49 writer.addLiteralValue(pojo); 50 } 51 52 public Object getNewInstance(ClientObjectManager objectManager, DNA dna) throws IOException , ClassNotFoundException { 53 DNACursor cursor = dna.getCursor(); 54 Assert.assertEquals(1, cursor.getActionCount()); 55 56 cursor.next(encoding); 57 LiteralAction a = (LiteralAction) cursor.getAction(); 58 Object value = a.getObject(); 59 60 return value; 61 } 62 63 public Map connectedCopy(Object source, Object dest, Map visited, ClientObjectManager objectManager, 64 OptimisticTransactionManager txManager) { 65 throw new TCNotSupportedMethodException(); 66 } 67 } 68 | Popular Tags |