1 23 package org.objectweb.jorm.metainfo.api; 24 25 import org.objectweb.jorm.metainfo.api.ClassMapping; 26 import org.objectweb.jorm.metainfo.api.PrimitiveElementMapping; 27 28 import java.io.PrintStream ; 29 import java.util.Iterator ; 30 31 37 public abstract class MappingPrinter { 38 39 public final static String TAB = " "; 40 41 46 public boolean canPrint(MappingStructure pem) { 47 return false; 48 } 49 50 public abstract void print(String p, PrimitiveElementMapping pem, PrintStream out); 51 52 public void print(String p, ClassMapping cm, PrintStream out) { 53 NameDef nd = (NameDef) cm.getIdentifierMapping().getLinkedMO(); 54 out.println(p + "The name def '" 55 + nd.getName() 56 + "' is used for the class"); 57 Iterator it = cm.getReferenceMappings().iterator(); 58 while (it.hasNext()) { 59 nd = (NameDef) ((ReferenceMapping) it.next()).getLinkedMO(); 60 out.println(p + "The name def '" 61 + nd.getName() 62 + "' is used for the reference '" 63 + ((TypedElement) nd.getParent()).getName() + "'"); 64 } 65 it = cm.getParentClassMappings().iterator(); 66 if (!it.hasNext()) { 67 out.println(p + "No ParentClassMapping"); 68 } else { 69 while (it.hasNext()) { 70 print(p + TAB, (ParentClassMapping) it.next(), out); 71 } 72 } 73 } 74 75 public void print(String p, ParentClassMapping pcm, PrintStream out) { 76 out.println(p + "Super class: " + pcm.getMOClass().getFQName() 77 + ", RuleName: " + pcm.getRuleName()); 78 } 79 80 public void print(String p, GenClassMapping gcm, PrintStream out) { 81 NameDef nd = (NameDef) gcm.getIdentifierMapping().getLinkedMO(); 82 out.println(p + "The name def '" 83 + nd.getName() 84 + "' is used for the generic class '" 85 + ((GenClassRef) gcm.getLinkedMO()).getGenClassId() + "'"); 86 87 ReferenceMapping rm = gcm.getReferenceMapping(); 88 if (rm != null) { 89 nd = (NameDef) rm.getLinkedMO(); 90 out.println(p + "The name def '" 91 + nd.getName() 92 + "' is used for the element of the generic class '" 93 + ((GenClassRef) gcm.getLinkedMO()).getGenClassId() + "'"); 94 } 95 } 96 } 97 | Popular Tags |