01: /*****************************************************************************
02: * Java Plug-in Framework (JPF)
03: * Copyright (C) 2004-2007 Dmitry Olshansky
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
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: *****************************************************************************/package org.java.plugin.registry.xml;
19:
20: import org.java.plugin.registry.Documentation;
21: import org.java.plugin.registry.Identity;
22: import org.java.plugin.registry.ManifestProcessingException;
23: import org.java.plugin.registry.PluginDescriptor;
24: import org.java.plugin.registry.PluginElement;
25: import org.java.plugin.registry.PluginFragment;
26:
27: /**
28: * @version $Id$
29: */
30: abstract class PluginElementImpl<T extends PluginElement<T>> extends
31: IdentityImpl implements PluginElement<T> {
32: private final PluginDescriptor descriptor;
33: private final PluginFragment fragment;
34: private DocumentationImpl<T> doc;
35:
36: protected PluginElementImpl(final PluginDescriptor descr,
37: final PluginFragment aFragment, final String id,
38: final ModelDocumentation modelDoc)
39: throws ManifestProcessingException {
40: super (id);
41: descriptor = descr;
42: fragment = aFragment;
43: if (modelDoc != null) {
44: doc = new DocumentationImpl(this , modelDoc);
45: }
46: }
47:
48: /**
49: * @see org.java.plugin.registry.xml.IdentityImpl#isEqualTo(
50: * org.java.plugin.registry.Identity)
51: */
52: @Override
53: protected boolean isEqualTo(final Identity idt) {
54: if (!getClass().getName().equals(idt.getClass().getName())) {
55: return false;
56: }
57: return getDeclaringPluginDescriptor().equals(
58: ((PluginElementImpl) idt)
59: .getDeclaringPluginDescriptor())
60: && getId().equals(idt.getId());
61: }
62:
63: /**
64: * @see org.java.plugin.registry.PluginElement#getDeclaringPluginDescriptor()
65: */
66: public PluginDescriptor getDeclaringPluginDescriptor() {
67: return descriptor;
68: }
69:
70: /**
71: * @see org.java.plugin.registry.PluginElement#getDeclaringPluginFragment()
72: */
73: public PluginFragment getDeclaringPluginFragment() {
74: return fragment;
75: }
76:
77: /**
78: * @see org.java.plugin.registry.Documentable#getDocumentation()
79: */
80: public Documentation<T> getDocumentation() {
81: return doc;
82: }
83:
84: /**
85: * @see org.java.plugin.registry.Documentable#getDocsPath()
86: */
87: public String getDocsPath() {
88: return (fragment != null) ? fragment.getDocsPath() : descriptor
89: .getDocsPath();
90: }
91: }
|