001/* 002 * (C) Copyright 2006-2010 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Bogdan Stefanescu 016 * Thierry Delprat 017 */ 018package org.nuxeo.apidoc.introspection; 019 020import java.util.ArrayList; 021import java.util.Collection; 022import java.util.List; 023 024import org.nuxeo.apidoc.api.BaseNuxeoArtifact; 025import org.nuxeo.apidoc.api.ExtensionInfo; 026import org.nuxeo.apidoc.api.ExtensionPointInfo; 027import org.nuxeo.apidoc.api.VirtualNodesConsts; 028import org.nuxeo.apidoc.documentation.DocumentationHelper; 029 030public class ExtensionPointInfoImpl extends BaseNuxeoArtifact implements ExtensionPointInfo { 031 032 protected final ComponentInfoImpl component; 033 034 protected final String name; 035 036 protected final Collection<ExtensionInfo> extensions = new ArrayList<ExtensionInfo>(); 037 038 protected final List<Class<?>> spi = new ArrayList<Class<?>>(); 039 040 protected String[] descriptors; 041 042 protected String documentation; 043 044 public ExtensionPointInfoImpl(ComponentInfoImpl component, String name) { 045 this.name = name; 046 this.component = component; 047 } 048 049 @Override 050 public ComponentInfoImpl getComponent() { 051 return component; 052 } 053 054 @Override 055 public String getComponentId() { 056 return component.getId(); 057 } 058 059 @Override 060 public String getName() { 061 return name; 062 } 063 064 public void setDescriptors(String[] descriptors) { 065 this.descriptors = descriptors; 066 } 067 068 @Override 069 public String[] getDescriptors() { 070 return descriptors; 071 } 072 073 @Override 074 public Collection<ExtensionInfo> getExtensions() { 075 return extensions; 076 } 077 078 public void addExtension(ExtensionInfoImpl xt) { 079 extensions.add(xt); 080 } 081 082 public void setDocumentation(String documentation) { 083 this.documentation = documentation; 084 } 085 086 @Override 087 public String getDocumentation() { 088 return documentation; 089 } 090 091 @Override 092 public String getDocumentationHtml() { 093 return DocumentationHelper.getHtml(getDocumentation()); 094 } 095 096 public void addSpi(List<Class<?>> spi) { 097 this.spi.addAll(spi); 098 } 099 100 @Override 101 public String getId() { 102 return component.getId() + "--" + name; 103 } 104 105 @Override 106 public String getVersion() { 107 return component.getVersion(); 108 } 109 110 @Override 111 public String getArtifactType() { 112 return TYPE_NAME; 113 } 114 115 @Override 116 public String getLabel() { 117 return name + " (" + component.getId() + ")"; 118 } 119 120 @Override 121 public String getHierarchyPath() { 122 return component.getHierarchyPath() + "/" + VirtualNodesConsts.ExtensionPoints_VNODE_NAME + "/" + getId(); 123 } 124 125}