1 42 43 package org.jfree.xml.generator.model; 44 45 import java.util.ArrayList ; 46 import java.util.HashMap ; 47 48 import org.jfree.util.Log; 49 50 53 public class DescriptionModel { 54 55 56 private ArrayList sources; 57 58 59 private ArrayList classes; 60 61 62 private HashMap classesMap; 63 64 65 private MappingModel mappingModel; 66 67 68 private Comments modelComments; 69 70 71 private HashMap includeComments; 72 73 76 public DescriptionModel() { 77 this.classes = new ArrayList (); 78 this.classesMap = new HashMap (); 79 this.mappingModel = new MappingModel(); 80 this.sources = new ArrayList (); 81 this.includeComments = new HashMap (); 82 } 83 84 89 public void addClassDescription(final ClassDescription cd) { 90 this.classesMap.put(cd.getObjectClass(), cd); 91 if (!this.classes.contains(cd)) { 92 this.classes.add(cd); 93 } 94 } 95 96 101 public void removeClassDescription(final ClassDescription cd) { 102 this.classesMap.remove(cd.getObjectClass()); 103 this.classes.remove(cd); 104 } 105 106 113 public ClassDescription get(final int index) { 114 return (ClassDescription) this.classes.get(index); 115 } 116 117 124 public ClassDescription get(final Class key) { 125 return (ClassDescription) this.classesMap.get(key); 126 } 127 128 133 public int size() { 134 return this.classes.size(); 135 } 136 137 142 public MappingModel getMappingModel() { 143 return this.mappingModel; 144 } 145 146 151 public void addSource(final String source) { 152 this.sources.add(source); 153 } 154 155 160 public String [] getSources() { 161 return (String []) this.sources.toArray(new String [this.sources.size()]); 162 } 163 164 167 public void prune() { 168 final ClassDescription[] cds = (ClassDescription[]) this.classes.toArray(new ClassDescription[0]); 169 for (int i = 0; i < cds.length; i++) { 170 if (cds[i].isUndefined()) { 171 removeClassDescription(cds[i]); 172 Log.debug("Pruned: " + cds[i].getName()); 173 } 174 } 175 } 176 177 183 public void addIncludeComment(final String source, final Comments comments) { 184 this.includeComments.put(source, comments); 185 } 186 187 194 public Comments getIncludeComment(final String source) { 195 return (Comments) this.includeComments.get(source); 196 } 197 198 203 public Comments getModelComments() { 204 return this.modelComments; 205 } 206 207 212 public void setModelComments(final Comments modelComments) { 213 Log.debug ("Model: Comment set: " + modelComments); 214 this.modelComments = modelComments; 215 } 216 217 } 218 | Popular Tags |