blob: b2dd8fc1294073638abf804ff45f540be0f80648 [file] [log] [blame]
Carsten Ziegeler55c96d32012-06-13 12:03:35 +00001/*
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 */
19package org.apache.felix.scrplugin.description;
20
Carsten Ziegeler9452bb22012-06-13 13:08:05 +000021import org.apache.felix.scrplugin.annotations.ScannedAnnotation;
Carsten Ziegeler55c96d32012-06-13 12:03:35 +000022
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 */
32public abstract class AbstractDescription {
33
34 /** The corresponding annotation from the class file. */
35 protected final ScannedAnnotation annotation;
36
Carsten Ziegeler9a496fe2012-06-27 06:20:28 +000037 private final String annotationPrefix;
38
39 private String sourceLocation;
40
Carsten Ziegeler55c96d32012-06-13 12:03:35 +000041 /**
42 * Create a new abstract description
43 * @param annotation The corresponding annotation.
44 */
45 public AbstractDescription(final ScannedAnnotation annotation) {
46 this.annotation = annotation;
Carsten Ziegeler9a496fe2012-06-27 06:20:28 +000047 if ( annotation == null ) {
48 this.annotationPrefix = "";
49 } else {
50 this.annotationPrefix = "@" + annotation.getSimpleName();
51 }
52 this.sourceLocation = "<unknown>";
Carsten Ziegeler55c96d32012-06-13 12:03:35 +000053 }
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 Ziegeler9a496fe2012-06-27 06:20:28 +000062
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 Ziegeler547de0c2012-06-28 11:22:40 +000074
75 public abstract AbstractDescription clone();
Carsten Ziegeler55c96d32012-06-13 12:03:35 +000076}