KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > java > plugin > registry > xml > DocumentationImpl


1 /*****************************************************************************
2  * Java Plug-in Framework (JPF)
3  * Copyright (C) 2004-2006 Dmitry Olshansky
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *****************************************************************************/

19 package org.java.plugin.registry.xml;
20
21 import java.util.ArrayList JavaDoc;
22 import java.util.Collection JavaDoc;
23 import java.util.Collections JavaDoc;
24 import java.util.Iterator JavaDoc;
25 import java.util.List JavaDoc;
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 /**
33  * @version $Id: DocumentationImpl.java,v 1.2 2006/06/05 18:16:43 ddimon Exp $
34  */

35 class DocumentationImpl implements Documentation {
36     /**
37      * Logger object.
38      */

39     protected static Log log = LogFactory.getLog(DocumentationImpl.class);
40
41     private final Identity identity;
42     private final ModelDocumentation model;
43     private List JavaDoc 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(""); //$NON-NLS-1$
52
}
53         references = new ArrayList JavaDoc(model.getReferences().size());
54         for (Iterator JavaDoc 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(""); //$NON-NLS-1$
61
}
62         if (log.isDebugEnabled()) {
63             log.debug("object instantiated: " + this); //$NON-NLS-1$
64
}
65     }
66
67     /**
68      * @see org.java.plugin.registry.Documentation#getCaption()
69      */

70     public String JavaDoc getCaption() {
71         return model.getCaption();
72     }
73
74     /**
75      * @see org.java.plugin.registry.Documentation#getText()
76      */

77     public String JavaDoc getText() {
78         return model.getText();
79     }
80
81     /**
82      * @see org.java.plugin.registry.Documentation#getReferences()
83      */

84     public Collection JavaDoc getReferences() {
85         return references;
86     }
87
88     /**
89      * @see org.java.plugin.registry.Documentation#getDeclaringIdentity()
90      */

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(""); //$NON-NLS-1$
103
}
104             if ((modelRef.getPath() == null)
105                     || (modelRef.getPath().trim().length() == 0)) {
106                 modelRef.setPath(""); //$NON-NLS-1$
107
}
108             if (log.isDebugEnabled()) {
109                 log.debug("object instantiated: " + this); //$NON-NLS-1$
110
}
111         }
112
113         /**
114          * @see org.java.plugin.registry.Documentation.Reference#getCaption()
115          */

116         public String JavaDoc getCaption() {
117             return modelRef.getCaption();
118         }
119
120         /**
121          * @see org.java.plugin.registry.Documentation.Reference#getRef()
122          */

123         public String JavaDoc getRef() {
124             return modelRef.getPath();
125         }
126
127         /**
128          * @see org.java.plugin.registry.Documentation.Reference#getDeclaringIdentity()
129          */

130         public Identity getDeclaringIdentity() {
131             return DocumentationImpl.this.getDeclaringIdentity();
132         }
133     }
134 }
135
Popular Tags