| 1 19 package org.java.plugin.registry.xml; 20 21 import java.util.ArrayList ; 22 import java.util.Collection ; 23 import java.util.Collections ; 24 import java.util.Iterator ; 25 import java.util.List ; 26 27 import org.apache.commons.logging.Log; 28 import org.apache.commons.logging.LogFactory; 29 import org.java.plugin.registry.Documentation; 30 import org.java.plugin.registry.Identity; 31 32 35 class DocumentationImpl implements Documentation { 36 39 protected static Log log = LogFactory.getLog(DocumentationImpl.class); 40 41 private final Identity identity; 42 private final ModelDocumentation model; 43 private List references; 44 45 DocumentationImpl(final Identity anIdentity, 46 final ModelDocumentation aModel) { 47 identity = anIdentity; 48 model = aModel; 49 if ((model.getCaption() == null) 50 || (model.getCaption().trim().length() == 0)) { 51 model.setCaption(""); } 53 references = new ArrayList (model.getReferences().size()); 54 for (Iterator it = model.getReferences().iterator(); it.hasNext();) { 55 references.add(new ReferenceImpl( 56 (ModelDocumentationReference) it.next())); 57 } 58 references = Collections.unmodifiableList(references); 59 if (model.getText() == null) { 60 model.setText(""); } 62 if (log.isDebugEnabled()) { 63 log.debug("object instantiated: " + this); } 65 } 66 67 70 public String getCaption() { 71 return model.getCaption(); 72 } 73 74 77 public String getText() { 78 return model.getText(); 79 } 80 81 84 public Collection getReferences() { 85 return references; 86 } 87 88 91 public Identity getDeclaringIdentity() { 92 return identity; 93 } 94 95 private class ReferenceImpl implements Reference { 96 private final ModelDocumentationReference modelRef; 97 98 ReferenceImpl(final ModelDocumentationReference aModel) { 99 modelRef = aModel; 100 if ((modelRef.getCaption() == null) 101 || (modelRef.getCaption().trim().length() == 0)) { 102 modelRef.setCaption(""); } 104 if ((modelRef.getPath() == null) 105 || (modelRef.getPath().trim().length() == 0)) { 106 modelRef.setPath(""); } 108 if (log.isDebugEnabled()) { 109 log.debug("object instantiated: " + this); } 111 } 112 113 116 public String getCaption() { 117 return modelRef.getCaption(); 118 } 119 120 123 public String getRef() { 124 return modelRef.getPath(); 125 } 126 127 130 public Identity getDeclaringIdentity() { 131 return DocumentationImpl.this.getDeclaringIdentity(); 132 } 133 } 134 } 135 | Popular Tags |