Carsten Ziegeler | 55c96d3 | 2012-06-13 12:03:35 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.apache.felix.scrplugin.description; |
| 20 | |
Carsten Ziegeler | 9452bb2 | 2012-06-13 13:08:05 +0000 | [diff] [blame] | 21 | import org.apache.felix.scrplugin.annotations.ScannedAnnotation; |
Carsten Ziegeler | 55c96d3 | 2012-06-13 12:03:35 +0000 | [diff] [blame] | 22 | |
| 23 | |
| 24 | /** |
| 25 | * <code>AbstractDescription</code> is the base class for all descriptions. |
| 26 | * |
| 27 | * @see ComponentDescription |
| 28 | * @see ServiceDescription |
| 29 | * @see ReferenceDescription |
| 30 | * @see PropertyDescription |
| 31 | */ |
| 32 | public abstract class AbstractDescription { |
| 33 | |
| 34 | /** The corresponding annotation from the class file. */ |
| 35 | protected final ScannedAnnotation annotation; |
| 36 | |
Carsten Ziegeler | 9a496fe | 2012-06-27 06:20:28 +0000 | [diff] [blame] | 37 | private final String annotationPrefix; |
| 38 | |
| 39 | private String sourceLocation; |
| 40 | |
Carsten Ziegeler | 55c96d3 | 2012-06-13 12:03:35 +0000 | [diff] [blame] | 41 | /** |
| 42 | * Create a new abstract description |
| 43 | * @param annotation The corresponding annotation. |
| 44 | */ |
| 45 | public AbstractDescription(final ScannedAnnotation annotation) { |
| 46 | this.annotation = annotation; |
Carsten Ziegeler | 9a496fe | 2012-06-27 06:20:28 +0000 | [diff] [blame] | 47 | if ( annotation == null ) { |
| 48 | this.annotationPrefix = ""; |
| 49 | } else { |
| 50 | this.annotationPrefix = "@" + annotation.getSimpleName(); |
| 51 | } |
| 52 | this.sourceLocation = "<unknown>"; |
Carsten Ziegeler | 55c96d3 | 2012-06-13 12:03:35 +0000 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Get the annotation. |
| 57 | * @return The annotation or <code>null</code> |
| 58 | */ |
| 59 | public ScannedAnnotation getAnnotation() { |
| 60 | return this.annotation; |
| 61 | } |
Carsten Ziegeler | 9a496fe | 2012-06-27 06:20:28 +0000 | [diff] [blame] | 62 | |
| 63 | public void setSource(final String location) { |
| 64 | this.sourceLocation = location; |
| 65 | } |
| 66 | |
| 67 | public String getSource() { |
| 68 | return this.sourceLocation; |
| 69 | } |
| 70 | |
| 71 | public String getIdentifier() { |
| 72 | return this.annotationPrefix; |
| 73 | } |
Carsten Ziegeler | 547de0c | 2012-06-28 11:22:40 +0000 | [diff] [blame] | 74 | |
| 75 | public abstract AbstractDescription clone(); |
Carsten Ziegeler | 55c96d3 | 2012-06-13 12:03:35 +0000 | [diff] [blame] | 76 | } |