Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one
   * or more contributor license agreements.  See the NOTICE file
   * distributed with this work for additional information
   * regarding copyright ownership.  The ASF licenses this file
   * to you under the Apache License, Version 2.0 (the
   * "License"); you may not use this file except in compliance
   * with the License.  You may obtain a copy of the License at
   *
  *   http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
 package org.apache.felix.scrplugin.annotations;
 
 import java.util.Map;

Base class for all annotation.
 
 public abstract class ScannedAnnotation {

    
The fully qualified class name
 
     protected final String name;

    
The annotation values.
 
     protected final Map<StringObjectvalues;

    
Create a new description

Parameters:
name The fully qualified class name of the annotation
values The properties of the annotation (optional)
 
     public ScannedAnnotation(final String namefinal Map<StringObjectvalues) {
         this. = name;
         this. = values;
     }

    
Get the fully qualified class name of the annotation.

Returns:
The fully qualified class name of the annotation.
 
     public String getName() {
         return ;
     }

    
Get the simple name of the annotation
 
     public String getSimpleName() {
         final int pos = .lastIndexOf('.');
         return .substring(pos + 1);
     }

    
Check if a value exists for this annotation. This method can be used to check whether a value exists, even if the value is null.

Parameters:
paramName The property name
Returns:
true If a value exists.
 
     public boolean hasValue(final String paramName) {
         if (  != null ) {
             return .containsKey(paramName);
         }
         return false;
     }

    
Get a property value of the annotation.

Parameters:
paramName The property name.
Returns:
The value of the property or null
 
     public Object getValue(final String paramName) {
         if (  != null ) {
             return .get(paramName);
         }
         return null;
     }

    
Get a boolean value of the annotation

Parameters:
name The property name
defaultValue A default value if the property is not set
Returns:
The property value or the default value.
 
     public boolean getBooleanValue(final String namefinal boolean defaultValue) {
         final Object val = this.getValue(name);
         if ( val != null ) {
             return ((Booleanval).booleanValue();
         }
         return defaultValue;
     }

    
Get an integer value of the annotation

Parameters:
name The property name
defaultValue A default value if the property is not set
Returns:
The property value or the default value.
    public int getIntegerValue(final String namefinal int defaultValue) {
        final Object val = this.getValue(name);
        if ( val != null ) {
            return ((Integerval).intValue();
        }
        return defaultValue;
    }

    
Get a long value of the annotation

Parameters:
name The property name
defaultValue A default value if the property is not set
Returns:
The property value or the default value.
    public long getLongValue(final String namefinal long defaultValue) {
        final Object val = this.getValue(name);
        if ( val != null ) {
            return ((Longval).intValue();
        }
        return defaultValue;
    }

    
Get a string value of the annotation

Parameters:
name The property name
defaultValue A default value if the property is not set
Returns:
The property value or the default value.
    public String getStringValue(final String namefinal String defaultValue) {
        final Object val = this.getValue(name);
        if ( val != null && val.toString().trim().length() > 0 ) {
            return val.toString().trim();
        }
        return defaultValue;
    }

    
Get an enumeration value of the annotation

Parameters:
name The property name
defaultValue A default value if the property is not set
Returns:
The property value or the default value.
    public String getEnumValue(final String namefinal String defaultValue) {
        final Object val = this.getValue(name);
        if ( val != null ) {
            if ( val instanceof String[] ) {
                return ((String[])val)[1];
            }
            if ( val instanceof String[][] ) {
                return ((String[][])val)[0][1];
            }
            return val.toString();
        }
        return defaultValue;
    }
    @Override
    public String toString() {
        return "AnnotationDescription [name=" +  + ", values=" + 
                + "]";
    }
New to GrepCode? Check out our FAQ X