001/* 002 * (C) Copyright 2006-2010 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Bogdan Stefanescu 018 * Thierry Delprat 019 */ 020package org.nuxeo.apidoc.introspection; 021 022import java.util.ArrayList; 023import java.util.Collection; 024import java.util.List; 025 026import org.nuxeo.apidoc.api.BaseNuxeoArtifact; 027import org.nuxeo.apidoc.api.ExtensionInfo; 028import org.nuxeo.apidoc.api.ExtensionPointInfo; 029import org.nuxeo.apidoc.api.VirtualNodesConsts; 030import org.nuxeo.apidoc.documentation.DocumentationHelper; 031 032public class ExtensionPointInfoImpl extends BaseNuxeoArtifact implements ExtensionPointInfo { 033 034 protected final ComponentInfoImpl component; 035 036 protected final String name; 037 038 protected final Collection<ExtensionInfo> extensions = new ArrayList<ExtensionInfo>(); 039 040 protected final List<Class<?>> spi = new ArrayList<Class<?>>(); 041 042 protected String[] descriptors; 043 044 protected String documentation; 045 046 public ExtensionPointInfoImpl(ComponentInfoImpl component, String name) { 047 this.name = name; 048 this.component = component; 049 } 050 051 @Override 052 public ComponentInfoImpl getComponent() { 053 return component; 054 } 055 056 @Override 057 public String getComponentId() { 058 return component.getId(); 059 } 060 061 @Override 062 public String getName() { 063 return name; 064 } 065 066 public void setDescriptors(String[] descriptors) { 067 this.descriptors = descriptors; 068 } 069 070 @Override 071 public String[] getDescriptors() { 072 return descriptors; 073 } 074 075 @Override 076 public Collection<ExtensionInfo> getExtensions() { 077 return extensions; 078 } 079 080 public void addExtension(ExtensionInfoImpl xt) { 081 extensions.add(xt); 082 } 083 084 public void setDocumentation(String documentation) { 085 this.documentation = documentation; 086 } 087 088 @Override 089 public String getDocumentation() { 090 return documentation; 091 } 092 093 @Override 094 public String getDocumentationHtml() { 095 return DocumentationHelper.getHtml(getDocumentation()); 096 } 097 098 public void addSpi(List<Class<?>> spi) { 099 this.spi.addAll(spi); 100 } 101 102 @Override 103 public String getId() { 104 return component.getId() + "--" + name; 105 } 106 107 @Override 108 public String getVersion() { 109 return component.getVersion(); 110 } 111 112 @Override 113 public String getArtifactType() { 114 return TYPE_NAME; 115 } 116 117 @Override 118 public String getLabel() { 119 return name + " (" + component.getId() + ")"; 120 } 121 122 @Override 123 public String getHierarchyPath() { 124 return component.getHierarchyPath() + "/" + VirtualNodesConsts.ExtensionPoints_VNODE_NAME + "/" + getId(); 125 } 126 127}