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 032import com.fasterxml.jackson.annotation.JsonIgnoreType; 033 034@JsonIgnoreType 035public class ExtensionPointInfoImpl extends BaseNuxeoArtifact implements ExtensionPointInfo { 036 037 protected final ComponentInfoImpl component; 038 039 protected final String name; 040 041 protected final Collection<ExtensionInfo> extensions = new ArrayList<>(); 042 043 protected final List<Class<?>> spi = new ArrayList<>(); 044 045 protected String[] descriptors; 046 047 protected String documentation; 048 049 public ExtensionPointInfoImpl(ComponentInfoImpl component, String name) { 050 this.name = name; 051 this.component = component; 052 } 053 054 @Override 055 public ComponentInfoImpl getComponent() { 056 return component; 057 } 058 059 @Override 060 public String getComponentId() { 061 return component.getId(); 062 } 063 064 @Override 065 public String getName() { 066 return name; 067 } 068 069 public void setDescriptors(String[] descriptors) { 070 this.descriptors = descriptors; 071 } 072 073 @Override 074 public String[] getDescriptors() { 075 return descriptors; 076 } 077 078 @Override 079 public Collection<ExtensionInfo> getExtensions() { 080 return extensions; 081 } 082 083 public void addExtension(ExtensionInfoImpl xt) { 084 extensions.add(xt); 085 } 086 087 public void setDocumentation(String documentation) { 088 this.documentation = documentation; 089 } 090 091 @Override 092 public String getDocumentation() { 093 return documentation; 094 } 095 096 @Override 097 public String getDocumentationHtml() { 098 return DocumentationHelper.getHtml(getDocumentation()); 099 } 100 101 public void addSpi(List<Class<?>> spi) { 102 this.spi.addAll(spi); 103 } 104 105 @Override 106 public String getId() { 107 return component.getId() + "--" + name; 108 } 109 110 @Override 111 public String getVersion() { 112 return component.getVersion(); 113 } 114 115 @Override 116 public String getArtifactType() { 117 return TYPE_NAME; 118 } 119 120 @Override 121 public String getLabel() { 122 return name + " (" + component.getId() + ")"; 123 } 124 125 @Override 126 public String getHierarchyPath() { 127 return component.getHierarchyPath() + "/" + VirtualNodesConsts.ExtensionPoints_VNODE_NAME + "/" + getId(); 128 } 129 130}